June 07, 2025

Home Assistant with VirtualBox or Proxmox or Ubuntu KVM ???

After using Home Assistant (HA) for a while, I’ve realised it could improve my home automation, despite using Apple HomeKit.

I tested HA, including Node-RED and other ’Add-ons’, on a Raspberry Pi 3 (RPi) and found that its computational power wasn’t enough for optimal performance.

The following setup could be any computer but I recently bought an Apple Mac Mini M4, replacing my 2018 (M18) model, so  the M18 was really a great candidate for my HA setup.

The preferred method of running HA is through the HA Operating System (HAOS), which optimises the user experience and simplifies the automation process.

Intro
The M18 processor is currently operating satisfactorily, and Virtual Machines for Mac OS are available, suggesting that HAOS could potentially be employed. However, I have developed a growing preference for Ubuntu due to its resource-efficient nature.

A second consideration is that not all resources allocated to the M18 need to be dedicated solely to HA.

After extensive research, I believe that ChatGPT has provided a comprehensive and insightful conclusion to this matter.

Option Verdict Notes
Ubuntu + VirtualBox ⚠️ OK, but not ideal Easy to set up but adds overhead and complexity. Not designed for 24/7 VM hosting.
Ubuntu + KVM/QEMU  Better Much more efficient and stable. Keep Ubuntu and get near-Proxmox performance.
Proxmox VE directly ✅✅ Best Maximum performance, ideal for always-on services, no desktop bloat. Most professional setup.

Proxmox seems to be the best variant but then you replace the OS with their own.(A Debian variant)

So my choice was erasing the M18:s, could also be any standard Intel hardware, hard disc and then installing Ubuntu Desktop 24.04 LTS with Linux KVM.

The M18 will run headless and I will use RDP for remote access.

Installation
Check HW
After the Ubuntu installation, running something else than a M18, check if your hardware can handle KVM. In a terminal use "egrep -c '(vmx|svm)' /proc/cpuinfo". If the result is >= 1 it's OK to proceed.

Ethernet interface
Use command "ip addr" to get the ethernet interface info and, among other interfaces, something like this will show
:
:
2: enp4s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 68:fe:f7:0c:ae:f9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.68.124/24 brd 192.168.68.255 scope global dynamic noprefixroute enp4s0
:
:
write down the interface name matching your info. (In my case "enp4s0")

The KVM image
Download the HAOS KVM image, "*.qcow2" and extract it.

Install KVM and Virtual manager
Start with an update "sudo apt update" and then install

sudo apt install -y qemu-kvm libvirt-daemon-system libvirt-clients bridge-utils virt-manager

Add logged-in user to KVM and libvirt

sudo adduser $USER libvirt && sudo adduser $USER kvm

then search for "Virtual Machine Manager" in the "Applications menu", start the application and then; 
  • Click "Create a new virtual machine".
  • Select "Import existing disk image", click on "Forward"
  • Provide the path to the "qcow2" image above
  • Chose OS typing "Generic...." and pick "Generic or unknown OS. Usage is not recommended.", click on "Forward"
  • Add "Memory => 4096", "CPUs => 2", click on "Forward"
  • Add "Name => HA
  • Check the box for "Customize configuration before install", click on "Finish"
  • Under "Overview =>Firmware" Select "UEFI x86_64: …. "
Make sure to select a non-secureboot version of OVMF (does not contain the word secure, secboot, etc.)
  • Under "NIC...." => "Network source => Macvtap"
  • "Device name" => The interface name retrieved above.(In my case "enp4s0"), click on "Apply"
With this approach you don't have to bridge the network interface !!!!
  • Under "Boot options" check the box "Start virtual machine on.....", click on "Apply"
  • Click "Add Hardware" (bottom left) and size the disk image.
  • Under "Channel" select "Name => org.qemu.guest_agent.0."
  • and "Device type => UNIX socket (unix)", click on "Finish"
  • Finally, select "Begin Installation"(upper left corner).
This shall start up HA and after a wile be accessed at "http://homeassistant.local:8123"

Remarks
Autostart
If running a standard Intel hardware this set up is probably made in the BIOS.

I'm running the M18 standalone and it's important that it autostarts after a power failure. Here is one article and I checked method 2 and 3. A way to start is checking, method 2, with command 

lspci | grep LPC
00:1f.0 ISA bridge: Intel Corporation Cannon Lake LPC Controller (rev 10)
sudo setpci -v -s 00:1f.0 0xa4.b
[sudo] password for "user": 
0000:00:1f.0 @a4 = 00 =>  Set for autorestart

Or in Mac OS, method 3, check with 

pmset -g

System-wide power settings:

Currently in use:

 standby              0

 Sleep On Power Button 1

 autorestart          0   =>  Not set for autorestart 

 powernap             1

 networkoversleep     0

 disksleep            10

 sleep                1 (sleep prevented by powerd, bluetoothd)

 ttyskeepawake        1

 displaysleep         10

 tcpkeepalive         1

 lowpowermode         0

 womp                 1


and then change with "pmset autorestart 1"

Bluetooth
In the mentioned M18 the Bluetooth receiver is a PCIe, not an USB, connected one. 

PCI passthrough is complex, risky, and would passthrough both Wi-Fi and Bluetooth, possibly breaking network on your host.

The recommended solution is to use a Bluetooth Proxy 

or 

buying a USB Bluetooth adapter approved by HA and then using a USB passthrough to the guest.

Or just skip Bluetooth ?

No comments:

Post a Comment

Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !