Actually install Home Assistant container image on Raspberry Pi 5

Submitted by Falken on

My understanding is you shouldn't use linuxserver's Home Assistant image as this is only "HA Core", so you can never use addons. Maybe you don't need them now, maybe you do, but locking yourself in seems poor. 
This is ditto for HA's own Docker instructions, and their "supervised" method is a Bash script of doom that doesn't work and doesn't say why not, when a simple Docker compose file would do, surely. I don't know why Linux Server (etc) haven't done a simple "FROM something, RUN the bash script"...

Sigh. Open source :)
So guess we're learning "lxc" - which turns out to be trivial, and is already there and waiting in Pi's Linux install.

But https://www.home-assistant.io/installation/linux#download-the-appropriate-image is wrong, for the Pi, you want to put "haos_generic-aarch64-13.2.qcow2" in "/var/lib/libvirt/images"

And the first boot is “expected” to fail and you have to go in and manually disable secure boot (see Installing HA OS 12.2 in a virtualized KVM (virtual manager) using rasperry PI 5 and Rasperry pi OS not working)

To make it restart on reboot: virsh autostart haos

For "reasons" lxc runs isolcated NAT'd IPs. And you don't want to do that.

You can add a new real IPs, replacing the crazy NAT solutions others use, easliy by adding a bridge to the PI's main internet connection: http://blog.leifmadsen.com/blog/2016/12/01/create-network-bridge-with-nmcli-for-libvirt/

Then "virsh edit haos" and set <source network='host-bridge'/>

Maintenance

The default image is probably not big enough, even a few backups will fill it. And it'll probably fail to upgrade because there's no space for it to download the internal Docker containers. Yes, the VM runs Docker in Docker. It's fine, don't listen to people who moan it'll be a fraction of a percent slower or less efficient. Working is better than not having it.

Fortunately, it's easy to resize the image at any time, then HAOS itself will do the rest.

You should stop HAOS first : virsh stop haos

root@pi5:~# qemu-img resize /var/lib/libvirt/images/haos_generic-aarch64-13.2.qcow2 +5G 
Image resized. 
root@pi5:~# qemu-img info /var/lib/libvirt/images/haos_generic-aarch64-13.2.qcow2 
image: /var/lib/libvirt/images/haos_generic-aarch64-13.2.qcow2 
file format: qcow2 
virtual size: 11 GiB (11811160064 bytes) 
disk size: 5.44 GiB 
cluster_size: 65536 
Format specific information: 
   compat: 1.1 
   compression type: zlib 
   lazy refcounts: false 
   refcount bits: 16 
   corrupt: false 
   extended l2: false

Restart HAOS and it will now resize itself to make more room

Login to HA image

virsh console https://ostechnix.com/how-to-enable-virsh-console-access-for-kvm-guests/ - root no password

shutdown virsh destroy haos

   and REMOVE virsh undefine haos --nvram