Home Assistante OS in a box
In my brand new mini PC I bought yesterday I wanted to create an instance of HAOS (Home Assistant OS).
Why HAOS?
HAOS is the ready made appliance for Home Assistant.
It’s simply a fully fledged system that just works.
I had different instances of Home Assistant, first in a python VENV, then on docker. And the last time, it was HAOS on a Raspberry PI 3 SD and USB (the first broke, and the second too).
Anyway, HAOS is the best because it has all the option and plugins and addons, the installation is easy, it has no issues, and updates are just a one click matter.
I suggest this approach.
The new setup
Since my RPI3B broke both an sd card and an USB dongle in less than 2 years, I suspect there’s some serious issue with the power rails, so I had to change the hardware. This time, I was looking for something more professional, and I landed on a Mini PC with an Intel N5095.
With 8Gb RAM and 256 Gb SSD, and a 12x12cm form factor, it seemed perfect for this task. I plan to install even other things there, like small python scripts and other fancy experiments.
For this purpose, the base OS is an Ubuntu Server (24LTS) and HAOS run in a KVM Virtual Machine.
I am pretty new with KVM, QEMU and libvirt, and I had a bad experience with Windows, but I was very sure that it perfectly fit for this purpose. Indeed, my problem with Windows and my laptop was due to the fact that to make the network work you mostly need a bridge adapter, and it doesn’t work well when you frequently change from Ethernet to Wifi, and it cannot work on Wifi. But on my new server, it was perfect.
After having installed the Ubuntu Server on the new machine, I logged in using SSH.
The procedure
The recipe is pretty simple. First you need to install kvm/libvirt, then you need to create a bridge, and finally you create a VM with HAOS.
I suppose that you already have KVM and libvirt installed. You can follow any recipe you find in the internet.
I also assume your user is member of the libvirt and kvm groups so you can attach the VM. It is not required, just prepend sudo if you don’t have the permissions.
Preparing the bridge
To prepare the bridge, I used netplan
. It’s already available on the minimal Ubuntu Server, and it is just matter of add a few lines to the already existing netplan config file /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by the datasource. Changes
# to it will not persist across an instance reboot. To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
enp1s0:
dhcp4: true
version: 2
wifis: {}
bridges:
br0:
dhcp4: yes
interfaces:
- enp1s0
parameters:
stp: false
I added all the line after the wifi
entry. My ethenret is named enp1s0
so it create a br0
with this adapter as master.
Run
$ sudo netplan generate
$ sudo netplan apply
Note that the connection will hang, so you need to kill the client and restart. For this reason, be careful and run generate
before apply
.
It is possible that your server will take a different IP. Check on your router.
Creating the Virtual Machine
Then you can import the Virtual machine:
$ sudo virt-install --import --name haos \
--memory 4096 --vcpu 4 --cpu host \
--disk /var/lib/libvirt/images/haos_ova-13.1.qcov2,bus=virtio \
--network bridge=br0,model=virtio \
--osinfo detect=on,require=off \
--graphics=none \
--boot=uefi
It will import the storage specified in the --disk
parameter, emulating it as a virtio
driver, it will assign 4096Gb of ram with 4 virtual CPUs in the host topology (--cpu host
), it will generate a virtio
network adapter tied to the bridge you just created, specify that the OS must be detected, assign no graphics and boot as UEFI.
If you don’t specify the --noautoconsole
parameter (I omitted it), the console will not be attached and displayed in the actual SSH session. In this case, use the escape sequence ^]
to quit the session.
Checking the domain and autostarting it
You can check that your domain (that is, your Virtual Machine) is running using virsh
:
$ virsh list
Id Name State
----------------------
1 haos running
Make it start automatically at boot:
$ virsh autostart haos
No network?
At this point on the console you see that HAOS will not have received an IP from your DHCP server, but your router will have seen it.
The reason is the fact that you need to disable a few things in net filter.
Just create the following file named /etc/sysctl.d/30-bridge.conf
:
net.bridge.bridge-nf-call-ip6tables=0
net.bridge.bridge-nf-call-iptables=0
net.bridge.bridge-nf-call-arptables=0
And also a udev rule named /etc/udev/rules.d/99-bridge.rules
:
ACTION=="add", SUBSYSTEM=="module", KERNEL=="br_netfilter", RUN+="/sbin/sysctl -p /etc/sysctl.d/30-bridge.conf"
This will set the options above every time the br_netfilter module is loaded into memory.
You can enable it immediately by calling
$ sudo /sbin/sysctl -p /etc/sysctl.d/30-bridge.conf
Reboot HAOS and you should have your machine on the same lan.
Point your browser to port 8123, and you should be able to onboarding into your new Home Assistant!