Configuring Hassio on Libvert using qcow2 image

Tags: #<Tag:0x00007f73b4e02cc8>

I have Hassio running on KVM using the QCOW2 image and thought i’d share the process i went through here for those that are starting off on the same path!

So initially I wanted to run Home Assistant on Docker! which i got running really easily using the below docker create statement:

`docker create \

–name=home-assistant \

–net=host \

–restart=always \

-v /home/$USER/home_assistant:/config \

-v /etc/localtime:/etc/localtime:ro \

homeassistant/home-assistant:stable

docker start home-assistant`

I also got this working in Rancher and Kubernetes, which is awesome! I really enjoy Kubernetes and getting into my bash terminal as often as i can!

I then learn this doesn’t come with Supervisor Doh! have a read here Superviser on generic linux is on hold for the moment: https://www.home-assistant.io/blog/2020/05/09/deprecating-home-assistant-supervised-on-generic-linux/

I then started my journey on getting this working on a Virtual machine using the provided on the Home Assistant website

I didn’t want to invest in a Raspberry PI just yet and wanting to run this on Linux box i picked the QCOW2 image and started using that, i had some initial issues with this due to the configuration that is required to get the image to boot, and at first i forgot to extract the gz file. Here are some commands to get the image form the site and unzip it.

`wget https://github.com/home-assistant/operating-system/releases/download/4.10/hassos_ova-4.10.qcow2.gz

gunzip hassos_ova-4.10.qcow2.gz`

Cool so once that is done assuming you have virt-manger and kvm installed you can run virt-manager to launch the manger.

Follow the details here to create the VM:

For KVM create a new virtual machine in virt-manager, select “Import existing disk image”, provide the path to the QCOW2 image above, choose “Generic Default” for the operating system, assign at least 2 GB memory and 1 vCPU, check the box for “Customize configuration before install” and select your bridge under “Network Selection”, then under customization select “Overview” -> “Firmware” -> “UEFI x86_64: …”.

I am running Ubuntu 20.04 and was able to boot the image using the below firmware:

<loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>

Besure to “Customize configuration before install” and select this firmware, else the image won’t boot, which was one of the issues i had in the beginning. (My own fault)

Next step once you have this booted is to get the networking working so Hassio is running on your lan and not as part a NAT.

To do this i had to create a new bridged network with a slave selected as the physical network adapter on your machine. To find this physical adapter run ip a s and look for the ip ranges that are for your local lan. in my case it was the 10.0.0.0/24 network CIDR the device this was called eno1. Your device name may be different and so will your CIDR range.

To create the bridge use nmtui, go to Edit a connection > then to add > select bridge.

Give your bridge a profile name, i used brige_home and a device name of nm-bridge1 you will need to select this later when you run virt-manager again to change the network settings

Then add an ethernet slave and give the device name of your physical network card, in my case eno1 it will fill in the MAC address for you so you don’t have to worry about that.

You can leave IPv4 Configuration as since you are most likely running a DHCP server in your network. Set IPv6 to disabled, since most users won’t be using this.

After this your will need to either reboot your host or restart the network service using:

sudo service network-manager restart

Once this is done go back into virt-manager > the VM you created earlier and change the network config to use the nm-bridge1 (the bridge your created earlier), this will place your Hassio on your local network so it can easily connection to all your IOT devices in your home without any natting issues.

Running virsh list will show you all the running VM’s that you have on libvert, it will print out something like the below:

`Id Name State


2 hassio running`

I hope you found this guide helpful in your journey to running Home Assistant with supervisor to take advantage of all its features! If you have any comments or improvements feel free to mention in the comments section.

Blockquote

I’ll share my experience briefly just for information purposes (Ubuntu 20.04 on Intel). I did this with virt-manager a couple of weeks ago. I was able to follow the instructions here for the bullet titled: “For KVM…”. I followed the instructions exactly (except they left the unzip the image part out), including the part “under customization select “Overview” -> “Firmware” -> “UEFI x86_64:” which does the same as you mentioned (uses firmware UEFI x86_64: /usr/share/OVMF/OVMF_CODE.fd)…was amazed that it came up the first time, no issues :slight_smile: :slight_smile:

1 Like

How did you go with getting the VM running on your local network?

I didn’t mention, but I already had a bridge that I created for my VMs. I wanted to have an ability to reach my VMs from the QEMU/KVM host. I created this bridge very similar to what you did.

There is another way that should work to get the VM on your local network w/o NAT. Before I started using this bridge, I would setup my VMs using virt-manager to have the NIC use macvtap with source mode = bridge. This allowed entities on my LAN to be able to reach the VM and vice-versa. The drawback was I was not able to reach the VM from the QEMU/KVM host.

So far following the vague instructions on the home-assistant install page, I was able to install hassos running in a KVM using the provided qcow2 file. I figured out the network bridge part and have that working, but I can not seem to figure out storage. Once my add-ons are install and I enable recorder for history I run out of space within the day. It looks like the image that is installed with the qcow2 file makes a 6Gb volume and I can’t figure out how to make it bigger or put it in a different direction location. I’m hoping somebody here can point me in the right direction. Thanks.

Hi, You can resize the image using qemu-img toolkit, first stop your Hassio Virtual Machine, “virsh shutdown hassio”

To check the current size of your image:

qemu-img info /home/phoenix/hassio/hassos_ova-4.10.qcow2

Mine is also 6GB by default, here is how you can make a backup of the qcow2 image:

cp /home/phoenix/hassio/hassos_ova-4.10.qcow2 /home/phoenix/hassion/hassos_ova-4.10.qcow2.bak

Resize the image and check if the change applied:
qemu-img resize /home/phoenix/hassio/hassos_ova-4.10.qcow2 +10G
qemu-img info /home/phoenix/hassio/hassos_ova-4.10.qcow2 - you should see the image has increased by 10GB

Then fire the machine backup with virsh start hassio.

Enjoy!