Skip to content

Instantly share code, notes, and snippets.

@chmutoff
Created February 28, 2021 15:41
Show Gist options
  • Save chmutoff/467b5c7c3d42cdfa06a27d2379f46382 to your computer and use it in GitHub Desktop.
Save chmutoff/467b5c7c3d42cdfa06a27d2379f46382 to your computer and use it in GitHub Desktop.
Home Assistant KVM installation
# Install HassOS with the QCOW2 image from https://www.home-assistant.io/hassio/installation/#alternative-install-on-a-generic-linux-host
virt-install --import --name Home_Assistant \
--memory 4096 --vcpus 1 --cpu host \
--disk hassos_ova.qcow2,format=qcow2,bus=virtio \
--network bridge=br0,model=virtio \
--os-type=linux \
--os-variant=generic \
--graphics vnc,listen=0.0.0.0,port=5903 \
--autostart \
--noautoconsole \
--boot uefi
# Disable netfilter (allow hassos to communicate through the bridge)
sysctl -a | grep nf-call
mcedit /etc/sysctl.d/bridge.conf
net.bridge.bridge-nf-call-ip6tables=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0
mcedit /etc/udev/rules.d/99-bridge.rules
ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/sbin/sysctl -p /etc/sysctl.d/bridge.conf"
sysctl -a | grep nf-call
# ------------
# RESIZE IMAGE
# -----------
apt install libguestfs-tools
# 1) Show all partitions in the QCOW2 image, you probably want /dev/sda8 but make sure you do
sudo virt-filesystems -l -h --all -a hassos_ova-4.11.qcow2
# 2) Resize image, below will increase with 5GB
sudo qemu-img resize hassos_ova-4.11.qcow2 +5G
# 3) Make a copy of the image (required for next step)
cp hassos_ova-4.11.qcow2 hassos_ova-4.11-orig.qcow2
# 4) Resize, this might take a while
sudo virt-resize --expand /dev/sda8 hassos_ova-4.11-orig.qcow2 hassos_ova-4.11.qcow2
# 5) Check if everything went as expected
sudo virt-filesystems -l -h --all -a hassos_ova-4.11.qcow2
<domain type='kvm' id='1'>
<name>Home_Assistant</name>
<uuid>310fb4f8-07bf-4a8d-bd31-f9fc3ee8450d</uuid>
<memory unit='KiB'>4194304</memory>
<currentMemory unit='KiB'>4194304</currentMemory>
<vcpu placement='static'>1</vcpu>
<resource>
<partition>/machine</partition>
</resource>
<os>
<type arch='x86_64' machine='pc-i440fx-3.1'>hvm</type>
<loader readonly='yes' type='pflash'>/usr/share/ovmf/OVMF.fd</loader>
<nvram>/var/lib/libvirt/qemu/nvram/Home_Assistant_VARS.fd</nvram>
<boot dev='hd'/>
</os>
<features>
<acpi/>
<apic/>
</features>
<cpu mode='custom' match='exact' check='full'>
<model fallback='forbid'>IvyBridge</model>
<vendor>Intel</vendor>
<feature policy='require' name='ss'/>
<feature policy='require' name='movbe'/>
<feature policy='require' name='hypervisor'/>
<feature policy='require' name='arat'/>
<feature policy='require' name='tsc_adjust'/>
<feature policy='require' name='umip'/>
<feature policy='require' name='3dnowprefetch'/>
<feature policy='disable' name='xsave'/>
<feature policy='disable' name='avx'/>
<feature policy='disable' name='f16c'/>
<feature policy='disable' name='fsgsbase'/>
<feature policy='disable' name='xsaveopt'/>
</cpu>
<clock offset='utc'>
<timer name='rtc' tickpolicy='catchup'/>
<timer name='pit' tickpolicy='delay'/>
<timer name='hpet' present='no'/>
</clock>
<on_poweroff>destroy</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>destroy</on_crash>
<pm>
<suspend-to-mem enabled='no'/>
<suspend-to-disk enabled='no'/>
</pm>
<devices>
<emulator>/usr/bin/qemu-system-x86_64</emulator>
<disk type='file' device='disk'>
<driver name='qemu' type='qcow2'/>
<source file='/home/anton/home-assistant-vm/hassos_ova.qcow2'/>
<backingStore/>
<target dev='vda' bus='virtio'/>
<alias name='virtio-disk0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
</disk>
<controller type='usb' index='0' model='ich9-ehci1'>
<alias name='usb'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x7'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci1'>
<alias name='usb'/>
<master startport='0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0' multifunction='on'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci2'>
<alias name='usb'/>
<master startport='2'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x1'/>
</controller>
<controller type='usb' index='0' model='ich9-uhci3'>
<alias name='usb'/>
<master startport='4'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x2'/>
</controller>
<controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/>
</controller>
<interface type='bridge'>
<mac address='52:54:00:b7:92:2e'/>
<source bridge='br0'/>
<target dev='vnet0'/>
<model type='virtio'/>
<alias name='net0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
</interface>
<serial type='pty'>
<source path='/dev/pts/0'/>
<target type='isa-serial' port='0'>
<model name='isa-serial'/>
</target>
<alias name='serial0'/>
</serial>
<console type='pty' tty='/dev/pts/0'>
<source path='/dev/pts/0'/>
<target type='serial' port='0'/>
<alias name='serial0'/>
</console>
<input type='tablet' bus='usb'>
<alias name='input0'/>
<address type='usb' bus='0' port='1'/>
</input>
<input type='mouse' bus='ps2'>
<alias name='input1'/>
</input>
<input type='keyboard' bus='ps2'>
<alias name='input2'/>
</input>
<graphics type='vnc' port='5903' autoport='no' listen='0.0.0.0'>
<listen type='address' address='0.0.0.0'/>
</graphics>
<video>
<model type='qxl' ram='65536' vram='65536' vgamem='16384' heads='1' primary='yes'/>
<alias name='video0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
</video>
<memballoon model='virtio'>
<alias name='balloon0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
</memballoon>
</devices>
<seclabel type='dynamic' model='apparmor' relabel='yes'>
<label>libvirt-310fb4f8-07bf-4a8d-bd31-f9fc3ee8450d</label>
<imagelabel>libvirt-310fb4f8-07bf-4a8d-bd31-f9fc3ee8450d</imagelabel>
</seclabel>
<seclabel type='dynamic' model='dac' relabel='yes'>
<label>+64055:+64055</label>
<imagelabel>+64055:+64055</imagelabel>
</seclabel>
</domain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment