Pi to NUC Part 1: Migrating Hass.IO to a Virtual Machine with Proxmox & Docker

As my Home Assistant setup has become increasingly complex, I’ve started to see the limitations of the Raspberry Pi platform. Graphs are slow, and the history and logbook are basically unusable to me. Everything works, but I’d like to be able to use these things with a lot more data and still have everything be snappy in the frontend. My other home server needs have grown as well, so I decided to get an Intel NUC and migrate all of my current servers to either Docker containers or virtual machines with Proxmox.



THE PLAN

I’ve been wanting to learn more about virtualization so this seems like a good way to accomplish that. I have acquired an Intel NUC 5i5MYHE with these specs:

  • i5-5300U 2.3Ghz Processor (Passmark: 3784)
  • 16GB RAM (upgradeable to 32gb)
  • 512GB SSD
  • Gigabit ethernet / USB 3.0 & 2.0

Very overkill for Home Assistant, but I also plan to run Plex Media Server (which currently is on an Odroid XU4) so the CPU was important. I want to be able to run other VMs for things like development and testing, and this was one of the few models confirmed to be upgradeable to 32GB of RAM. All of my file serving is handled by a Synology NAS, so storage wasn’t really a concern here. This model does support both a M.2 SSD and 2.5″ hard disk. Eventually I’d like to run all the VMs off the SSD and store persistent Docker data on the spinning disk.

One of the reasons I chose the NUC is that it is relatively low power. By running Proxmox as the host OS, I could eventually cluster multiple NUCs and expand my existing resources easily without have jet engine servers in my apartment.

So the plan is to install Proxmox and have a virtual machine that runs nothing but Docker. Then I will install Hass.IO and it’s related services inside Docker containers.

INSTALL PROXMOX ON THE NUC

First things first, update the BIOS to get that out of the way. Here’s the instructions (PDF) from Intel. I am going to use the “F7 Method” since I don’t have a Windows PC to use their utility.

Next I made a bootable USB image of Debian. Just download the ISO and write it to my USB stick:

sudo dd if=debian-9.4.0-amd64-netinst.iso of=/dev/disk4

I did a standard, headless install of Debian. After a quick install and a reboot, I was at a Linux terminal.

Following the Proxmox-over-Debian instructions from their wiki, I made sure I had a static IP on my network that resolved to my hostname. Then I added the Proxmox repositories and installed Proxmox:

echo "deb http://download.proxmox.com/debian/pve stretch pve-no-subscription" > /etc/apt/sources.list.d/pve-install-repo.list
wget http://download.proxmox.com/debian/proxmox-ve-release-5.x.gpg -O /etc/apt/trusted.gpg.d/proxmox-ve-release-5.x.gpg
apt update && apt dist-upgrade
apt install proxmox-ve postfix open-iscsi

This replaces the Debian kernel with the Proxmox virtualization capable one and installs everything needed to make it work. After rebooting, the login prompt now says “Welcome to the Proxmox Virtual Environment”. Now I can login via the web interface at https://IP:8006/

Proxmox Web Interface

Proxmox Web Interface


CREATING THE VIRTUAL MACHINE

NETWORKING

In order for the virtual machine to have access to the network, I need to set up a bridge. I did this manually by editing the /etc/network/interfaces file

source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

allow-hotplug enp0s25

iface enp0s25 inet manual

auto vmbr0
iface vmbr0 inet static
 address 192.168.0.2
 netmask 255.255.255.0
 gateway 192.168.0.1
 bridge_ports enp0s25
 bridge_stp off
 bridge_fd 0

This gives a static IP of 192.168.0.2 to the host NUC on my LAN and bridges the VMs to the network.

INSTALLING THE VM

In order to install some new VMs from an ISO, copy those ISO files to /var/lib/vz/template/iso on the host NUC. I used SFTP. The images will appear in the “Create VM” dialog:

New Virtual Machine

New Virtual Machine

I select my Debian ISO, gave it 128GB of hard disk space, and set the CPU to share all 4 cores. For RAM I have it set to use a range of 4-10GB.

RELATED >>  The Open Source Smart Home: Getting Started with Home Assistant & Node-Red

Hit start on the VM and open the console – now I am installing Debian for the second time today.

Installing Debian in a VM

Installing Debian in a VM

INSTALLING DOCKER AND HASS.IO

Now I need to get Docker and the HA dependencies installed. The Home Assistant info for this procedure is here. Install what it needs:

apt-get install jq curl dbus socat bash avahi-daemon
apt-get install -y apt-transport-https ca-certificates wget software-properties-common
wget https://download.docker.com/linux/debian/gpg 
sudo apt-key add gpg
echo "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee -a /etc/apt/sources.list.d/docker.list
apt-get update
apt-get -y install docker-ce

Now, install Hass.IO in Docker with the intel-nuc option selected.

curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -s -- -m intel-nuc

And it’s up:

Success!

Success!


Z-WAVE USB PASS THROUGH

I have a HUZB-1 Z-Wave/Zigbee stick. In order to pass it through to the VM, I connect to the NUC and:

brad@nuc:~$ lsusb
Bus 001 Device 002: ID 8087:8001 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 003 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 002 Device 003: ID 10c4:8a2a Cygnal Integrated Products, Inc.
Bus 002 Device 002: ID 1c4f:0002 SiGma Micro Keyboard TRACER Gamma Ivory
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

I’m interested in the Cygnal device, which has an ID of 10c4:8a2a.

brad@nuc:~$ nano /etc/pve/qemu-server/100.conf

100 is the ID of my VM. Add this line at the bottom:

usb0: host=10c4:8a2a

Reboot the VM and it will now have access to my USB stick as if it were plugged in locally.

CONTAINER MANAGEMENT

So now I’m almost done: I have a host server running Proxmox, and have a virtual machine dedicated to running Docker. Home Assistant (Hass.IO) runs in this Docker. For easy management of the containers, I’m going to install Portainer as a web GUI.

docker volume create portainer_data 
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
Portainer Management UI

Portainer Management UI

With Hass.IO in Docker, I have two containers: homeassistant itself and the Hass.IO supervisor. If I install any addons within Hass.IO, they run the same as any other Docker containers and can be managed here as well. You can see I’ve enabled Samba, MQTT, and Node-Red as addons from within Hass.IO. There is no real difference between running an add-on or a standard Docker, add-ons are just Docker containers tailored to Hass.IO.

Now I just need to migrate my HA installation over. Unfortunately, copying a full Hass.IO backup did not work (different architectures?). So I simply copied my HA and Node-Red config folders over to the new Hass.IO via Samba and that got me 90% of the way there. A little tweaking of my databases and getting my other network servers up, and I will be fully migrated over.

AND THE PERFORMANCE?

I am seeing a very dramatic increase in responsiveness. Not just in the web UI (I can now use the logbook and history!) but in the responsiveness of all of my devices. Everything from MQTT triggers to scenes to Z-Wave devices all are noticeable much, much faster. And the load on my NUC, with 3 VMs going and all the above Dockers turned on:

NUC System Load

NUC System Load

Guess I need to find something for all those extra CPU cycles to do!


4 Comments

  1. I’m about to tackle this exact task: moving from Hass.IO on an RPi3 to a small Skylake Core i3 box I’m building on my own. I’d also like to run pfSense on it in another VM to act as my router. I see from one of your screenshots that you downloaded that ISO. Will a future article address that?

    Thanks.

    Reply

    1. Yeah I will write that up eventually, I have just been tinkering with pfSense and haven’t fully switched my network over to it yet. For the NUC I am using a dual gigabit USB3 adapter so that pfSense has it’s own WAN/LAN connection independent of my virtualization host.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *