Installing Home Assistant OS in oVirt (on CentOS 8)

NOTE! CentOS 8 will be killed 8 years early.

With the recent announcement that CentOS 8 will reach end of life (EOL) ultimo 2021 (instead of 2029 as was the plan), you might want to consider not using CentOS 8. I won’t get into the politics of this move by RedHat/IBM, but just note that CenOS 8 support/updates will end 8 years earlier than announced. You could consider:

  1. Moving to CentOS stream (if this suits you needs). Converting is three commands.
  2. Moving to Oracle Linux. This is free, but still based on RHEL. If using CentOS 6 or 7 (they just updated for CentOS 8, use this. They will update the page describing it soon), it can be done with a script they wrote.
  3. Use CentOS 7, which will be supported until the announced EOL (2024).
  4. Moving to a different distro all together. I’m not sure how this guide will fare on other distros, but please give feedback if you try.
  5. Wait and see what happens with Rocky Linux, a new project by the creator of CentOS which should become what CentOS was. But there’s nothing in the repo yet.

Installing CentOS, oVirt, and HassOS

This will guide you to install CentOS, oVirt, and finally HassOS on most, if not all x86_64 systems with enough resources.

I had this bright idea that I wanted to move from the Docker images I’ve been using for years, to something with the Supervisor. And with all the fuss going on the last year or two, I really wanted it to be an “official” install to avoid being more or less forced to migrate at a later, less ideal time. I am running an old server, so I decided the HassOS VM was the way to go. I’ve never done any significant virtualization, but after a bunch of research, oVirt is the way to go for me. But! This was not as easy as I thought. After many, many hours, I decided that the fruits of my struggle should be documented, so someone else could hopefully avoid it.

I have used several resources, as well as some trial an error. Resources credited at the end, or at relevant places in the text.

As I said, I’m a “virgin virtualizer”, so this contains a bunch of stuff that maybe (probably) could be done smarter. I have also added [QUESTION] a few places, if anyone has feedback to improve, please do share!

That said, here’s how I installed oVirt on CentOS, and spun up a HassOS VM.

1 - Preparation

1.1 - [OPTIONAL] Set up a DNS server

[QUESTION] From what I’ve read, you can add fully qualified domain names to your /etc/hosts (on your “local computer” and your “server”). I haven’t tried, so can’t guarantee how that works.

I used PiHole on a Raspberry Pi 3B+. You can probably get away with as “low” as Raspberry Pi 2B.

1.1.1 - Flash Raspberry Pi OS

Flash Raspberry Pi OS Buster Lite to SD card. Make sure you can attach this with LAN cable (not wireless!)

[OPTIONAL] Add an empty file called “ssh” to the /boot/ directory on the SD card to enable ssh access.

Insert SD card and power up Raspberry Pi.

Upgrade

sudo apt update && sudo apt upgrade -y

1.1.2 - Install PiHole

Install pihole. There are several ways, easy to follow from the official documentation.

1.1.3 - Add local DNS records

Go to web UI (http://Raspberry_Pi_IP/admin), and under “Local DNS Records”, add the IP of the computer you’ll run oVirt on, and a FQDN you want to use.

For the following I’ll assume you use centos-ovirt-1.your.home for the server running CentOS (for me, at 192.168.0.97)

Also add an unused IP and a FQDN for the Host Engine we will set up. For the following I’ll assume you use ovirt-engine-1.your.home, and I’ve added this at 192.168.0.235.

[NOTE] You can set the DNS in your router to the IP of the PiHole Raspberry Pi if you want to use it for all DNS requests. Otherwise you need to manually set it as DNS for services/devices you want using it.

1.2 - Get HassOS image

Download HassOS qcow2 image from the install page to the local computer .

2 - Install centOS

2.1 - Flash centOS image to USB drive

Go to the CentOS download page and grab the CentOS-8.2.2004-x86_64-minimal.iso from your preferred mirror.

I used Balena Etcher.

[QUESTION: Would it be better to flash in UEFI-supported mode, and have the hardware run UEFI? If so, you’d need Rufus, and also need to (1) have hardware that is UEFI-compatible, and (2) enable UEFI in BIOS. Is there a Rufus alternative for MacOS?]

2.2 - Install centOS on your server

You’ll need a monitor and keyboard/mouse for the initial install [QUESTION: is there a good way to avoid this?]

There are many guides e.g. this one, so I won’t cover this. If going by the one I linked to, remember to set a static IP (in step 24/25, choose step 25).

Once done, click reboot.

3 - Installing oVirt

From this point, everything is done from your local computer, either via ssh or a browser.

The following assumes you have set your hostname to centos-ovirt-1.your.home, but change as needed. Keep in mind that you will need a FQDN for the machine running oVirt. I’ll also assume you have set the FQDN to use for the oVirt Hosted Engine to ovirt-engine-1.your.home. My IP for the server running CentOS is 192.168.0.97, I’ll use that in the examples below, but remember to change as needed.

3.1 - Install a few packages, and add oVirt repository

ssh into host. I’ll assume you are logging into root, if not you might need sudo for some of the commands:

ssh [email protected]

3.1.1 - [OPTIONAL] Install wget and nano

CentOS uses vi, if you’re comfortable with this, you can skip the nano install. If you won’t need to download anything with wget to the host, you can skip this one as well.

dnf install -y wget nano

3.1.2 - [OPTIONAL] Set hostname

[Optional] If hostname not set during install, set it now:

hostnamectl set-hostname centos-ovirt-1.your.home

3.1.3 - Update and reboot system

dnf -y update
systemctl reboot

3.1.4 - Add official oVirt repository

dnf -y install https://resources.ovirt.org/pub/yum-repo/ovirt-release44.rpm

4 - Prepare storage

This assumes you will use locally accessible storage (i.e. connected internally in the computer running CentOS). The only way I got this to work was to make the local storage NFS shares [QUESTION: can it be done with just local disks without making NFS shares? Is this not advisable?]

If using a different disk/partition than where you have CentOS installed, then you might need to format and partition. If you already have network storage, then just use that.

4.1 - Make mount point and mount drive

Make a mount point (/nfs is used here), and mount the partition you want to use. The best way is by finding the UUID, then added a line in /etc/fstab

mkdir /nfs
ls -lh /dev/disk/by-uuid/
echo "UUID=73a215f1-9c78-453f-8032-f9b0b7230b07 /nfs ext4 defaults,nofail 0 0" >> /etc/fstab
mount -a

This makes the directory /nfs, lists the UUID of drives (mine was 73a215f1-9c78-453f-8032-f9b0b7230b07), makes an entry in /etc/fstab so it’s mounted in case of a reboot, and then mounts it now.

4.2 - Make the directories to export as NFS shares

Here, we’ll make /nfs/ovirt/data, /nfs/ovirt/iso, and /nfs/ovirt/export

mkdir -p /nfs/ovirt/{data,iso,export}

data is used for VMs, including the hosted engine
iso is used for, well, iso files (if you want to install an OS from iso)
export is for data to import/export, including VM images.

4.3 - Install NFS and export directories

Install NFS and enable service

yum -y install nfs-utils
sudo systemctl enable --now nfs-server rpcbind

Create (if not already present) group “kvm” and user “vdsm".

getent group kvm || sudo groupadd kvm -g 36
getent passwd vdsm || sudo useradd vdsm -u 36 -g 36

Change ownership and permissions of created directories:

chown -R 36:36 /nfs/ovirt/{data,iso,export}
chmod 0775 /nfs/ovirt/{data,iso,export}

Add locations to “/etc/exports”:

echo "/nfs/ovirt/data *(rw,anonuid=36,anongid=36,all_squash)" >> /etc/exports
echo "/nfs/ovirt/iso *(rw,anonuid=36,anongid=36,all_squash)" >> /etc/exports
echo "/nfs/ovirt/export *(rw,anonuid=36,anongid=36,all_squash)" >> /etc/exports

Start and enable NFS service, and update NFS exports table

systemctl restart nfs-server
systemctl enable nfs-server
exportfs -rvv

Allow NFS service in firewalld

firewall-cmd --add-service={nfs,nfs3,rpc-bind} --permanent
firewall-cmd --reload

5 - Install Cockpit

Install cockpit and cockpit-ovirt-dashboard (from repo we added earlier), start and enable cockpit service:

dnf -y install cockpit cockpit-ovirt-dashboard gluster-ansible-roles ovirt-engine-appliance
systemctl enable --now cockpit.socket

Enable Cockpit service in firewall

firewall-cmd --add-service=cockpit
firewall-cmd --add-service=cockpit --permanent
firewall-cmd --reload

That’s the end of the command line interface. The rest is done in a web browser.

6 - Install oVirt hosted engine using Cockpit wizard

Open a web browser, and navigate to the IP of the machine you’ve installed CentOS, at port 9090 (mine is 192.168.0.97, so I’ll use https://192.168.0.97:9090/)

Log in with user=root password=whatever_you_set_during_centOS_install.

6.1 - Update and restart

Got to Host → Software Updates and update, and update the system (“Install All Updates”). Click reconnect to connect after the automatic restart (if not available, wait a minute and try again).

6.2 - Deploy hosted engine

Click “Virtualization” → ”Hosted Engine”

6.2.1 - Step 1

Fill in information as shown in the screenshot below (change number of Virtual CPUs and Memory size to fit your needs. This screenshot was from testing on a small, old computer that doesn’t have a lot of resources).

“Root password” is the password for the linux root user for that VM. Insert SSH public key if wanted.

[NOTE] The Engine VM FQDN (and Host FQDN) should verify, but you might need to enter the DNS server address before the FQDNs.

6.2.2 - Step 2

Fill in “Notification settings” if (1) you have mail server set up and (2) you want loads of notification emails. Otherwise leave as is. “Admin Portal Password” is the password used to log in to the engine VM web UI.

You will get an overview at step (3), and if there are not mistakes/typos, then press “Prepare VM" to deploy. This might take a long time, depending on your hardware.

6.2.3 - Step 4

Prepare storage as such (assuming you’ve set things up as described above), and give as much storage as you prefer (though 60GB is the minimum allowed) [QUESTION: Is it a good idea to add more than the 60 GB? What are the consequences of the disk size allocated here?]:

Check on next page, and if correct, click “Finish Deployment”. This will take a long time, again, depending on your hardware.

That’s it for the Cockpit part (the part accessible at the IP of the CentOS server). The rest is done via the hosted engine you have just deployed.

7 - Configure oVirt engine

7.1 - Get certificate

Log in to the engine web UI using the FQDN ( not IP ) that you used in the first step on engine deployment (we used ovirt-engine-1.your.homeas the example).

[NOTE] Firefox would not allow me to navigate to this page. I had to use a different browser for the initial step, getting the certificate. Both Safari, Opera, and Iridium worked fine.

Click the “CA Certificate” link to download the certificate (“pki-resource.cer”).

Import certificate into your browser of choice (this process will differ depending on your browser, but generally somewhere in settings/preferences and then under security and certificates).

Then you can use your browser without errors/warnings for accessing this page.

Click “Administration Portal” and log in using user=admin and the password you set in the second step of the hosted engine deployment above.

7.2 - Add storage domains [Optional]

[OPTIONAL] Set up new storage by going to Storage → Domains → New Domain and put in the details for the “/nfs/ovirt/iso” and “/nfs/ovirt/export” set up earlier. Remember to set “Domain function” to “Iso” or “Export”, respectively. This is not needed for HassOS, but if using oVirt, you’ll likely want more thann one VM running.

8 - Install and deploy HassOS

8.1 - Upload HassOS image

Go to Storage → Disks, in the top right, click Upload and choose “Start” from the drop-down menu. Click “Choose image” and find the “hassos_ova-X.XX-qcow2” file and select it. Give it an “Alias”, amd make sure to select the “Data” storage domain.

Wait for the upload to finish.

8.2 - Deploy HassOS VM

Go to Compute → Virtual Machines → New

8.2.1 - Attach qcow2 image

Under “Image instances”, click “Attach”, and choose the HassOS Image you just uploaded:

Pick a vNIC profile (I only had one), give the new VM a name, and under ”Optimized for”, choose “Server”:

8.2.2 - Enable UEFI, disable BIOS, set resources

Make sure that “Advances Options” are shown (button in lower left corner). Under System → Advanced set the CPU to Q35 chipset with UEFI . Set RAM and vCPUs as you’d like [QUESTION: What is sensible, without being overkill? I’m not really sure how vCPUs compare to “real” CPUs, but I’m guessing 4-8 GB RAM would be plenty?]. Also set time zone.

For HASS, feel free to enable “Headless Mode” under the “Console” tab on the left:

Click “OK”.

8.2.3 - Set static IP

After creating, you’ll end up on the VM page again. Click the name of the new VM, then the “Network Interfaces” tab and get the MAC address to add static IP in router DHCP (you can also give it a custom MAC if needed by clicking “edit” on this tab).

[QUESTION Can I set static IP directly from Admin Portal?]

That’s it, you’re ready to fire up the new HassOS VM. Unless of course you are using USB devices, e.g. a Z-wave or ZigBee stick. If so, read below.

8.3 - [Optional] Attach USB devices (e.g. Z-Wave or ZigBee USB sticks)

Plug the stick into the server, then go to “Compute” → Hosts, select your host, click “Host Devices”, then “Management” (top right) and select “Refresh Capabilities”. Your USB device should now be in the list below (ConBee II stick highlighted in example below).

Then go to “Compute” → “Virtual Machines” and select your VM. Click the “Host Devices” tab, and click “Add Device”

[NOTE] - VM must be powered off, it cannot attach while running. Also note that [QUESTION: the VM cannot be migrated with the USB attached? This could complicate things if you are interested in that]. But that is more advanced than what we cover here, so if you do, you probably already know more than me.

Select the correct host, the under “Capability”, choose “usb_device”, and select the correct device from the list. Press the “Down Arrow” in the GUI to move it from “Available Host Devices” to “Host Devices to be attached”.

Start your HassOS VM, and wait until it comes online (depends on resources allocated and internet connection - give it some time).

9 - References and acknowledgements

Thomas Foulds for assistance with UEFI (Installing HomeAssistant on oVirt)
Main guide where at least most things finally worked (https://computingforgeeks.com/install-and-configure-ovirt-on-centos/)
Guide to NFS shares (https://www.howtoforge.com/tutorial/setting-up-an-nfs-server-and-client-on-centos-7/)
Installation of “CentOS 8.0″ with Screenshots (CentOS install images)
DNS (https://pi-hole.net/)
oVirt (https://www.ovirt.org/)
CentOS (https://www.centos.org/)

3 Likes

Reserved for future updates