Skip to content

Instantly share code, notes, and snippets.

@peterpme
Last active March 17, 2023 22:10
Show Gist options
  • Save peterpme/8ae92918cec01b79ac2c25d4de5f0cfa to your computer and use it in GitHub Desktop.
Save peterpme/8ae92918cec01b79ac2c25d4de5f0cfa to your computer and use it in GitHub Desktop.
Home Assistant OS with Ubuntu 20.04 (Linux) using KVM and Nortek USB for Z-Wave / ZHA
## Home Assistant OS (Latest as of July 17th, 2021)
## Installation using Ubuntu 20.04 Server and KVM
## Thanks to:
# https://gist.github.com/dsbaars/82a31303f50da08edb422fdc15031257
# https://community.home-assistant.io/t/install-home-assistant-os-with-kvm-on-ubuntu-headless-cli-only/254941
# /var/lib/libvirt/images/hassos-vm
## Everything lives here
mkdir -vp /var/lib/libvirt/images/hassos-vm && cd /var/lib/libvirt/images/hassos-vm
# See netplan config below, apply with "sudo netplan apply"
# If you already have docker running, your bridge might not work as expected because it manages your iptables rules in a way which causes problems with forwarding, below command will fix that
sudo iptables -P FORWARD ACCEPT
# Install HassOS with the QCOW2 image from https://www.home-assistant.io/hassio/installation/#alternative-install-on-a-generic-linux-host
# The below command also allows you to log in using VNC, useful for debugging
sudo virt-install --name hassos --graphics vnc,listen=0.0.0.0 --memory=2048 --vcpus=2 --disk=/var/homeassistant/hassos_ova-4.11.qcow2,format=qcow2 --boot uefi --import --os-variant=debian9 --network=bridge=br0
# ------------
# ATTACH USB DEVICES (e.g. zwave)
# -----------
# See zwave.xml below for an example
virsh attach-device hassos --file usb_stick_nortek.xml --persistent
# ------------
# RESIZE IMAGE
# -----------
# The default disk size is only 5 GB, you can extend it with the commands below
# 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
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x10c4'/>
<product id='0x8a2a'/>
</source>
</hostdev>
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x1a86'/>
<product id='0xe024'/>
</source>
</hostdev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment