Home Assistant on FreeBSD

After working for a couple of months the SD card in the HomeAssistant RaspberryPi died. Annoying. Of course without a suitable replacement how do we get the HA working again?

We have a small server in the house that runs FreeBSD so that seemed like a good solution apart from the lack of docker support to install HA. However, after spending some time with web searches, the HA forums and wiki pages, it turns out to be possible. The following shows what I did and might help someone else.

NB. I don't claim to be an expert and suggestions for improvements are welcome :-)

My system is FreeBSD  12.2 and uses vm-bhyve

For simplicity, all of these commands are issued as root. I use sudo, so

$ sudo su

Install the packages that are needed.

# pkg install qemu-utils
# pkg install vm-bhyve
# pkg install phyve-firmware

Setup the VM.

# zfs create <zfs pool>/vm
# sysrc vm_enable="YES"
# sysrc vm_dir="zfs:<zfs pool>/vm"
# vm init

# vm switch create public
# vm switch add public em0

# cp /usr/local/share/examples/vm-bhyve/* <zfs pool>/vm/.templates/

Download the HA image. I found the current version from their installation page, Alternative. There may well be an easier way, but I couldn't get it to fetch via the vm commands I tried due to SSL verification issues.

# fetch --no-verify-peer https://github.com/home-assistant/operating-system/releases/download/5.11/hassos_ova-5.11.qcow2.xz
# unxz hassos_ova-5.11.qcow2.xz

Create the VM image.

# vm image create -d hass hassos_ova-5.11.qcow2

Checking the image is available (not required but reassuring).

# vm img
DATASTORE           FILENAME
default             hassos_ova-5.11.qcow2

Create the VM. This took quite a while on my machine...

# vm create -t debian -c 4 -s 200G -m 4GB -i hassos_ova-5.11.qcow2 hass

The config shouldn't need changed, but I did find that at some point it changed boot method from uefi to grub. I simply adjusted the config.

# vm configure hass
loader="uefi"
cpu=4
memory=4G
network0_type="virtio-net"
network0_switch="public"
disk0_type="ahci-hd"
disk0_name="disk0.img"
uuid="xxxx"
network0_mac="xx"

Finally, time to start it :-)

# vm start hass

Once things settle, check it's running.

# vm list
NAME            DATASTORE  LOADER  CPU  MEMORY  VNC  AUTOSTART  STATE
hass            default    uefi    4    4G      -    No         Running

At this point it's running within the VM and has acquired an IP via DHCP. From here the standard Onboarding instructions for HA can be followed.

It's a full installation and so far everything works. I don't access any hardware devices directly, so that may cause some issues but presently it's all working well.