This is the procedure I used to install Home Assistant (HA) on a fresh installation of Ubuntu Server 24.04 on a Lenovo ThinkCenter M900 mini computer.
A monitor and a keyboard are required to be connected to the computer both for the installation of Ubuntu and some steps related to modifying the BIOS in the procedure below. Also, it is neccessary to have the computer connected through an Ethernet cable to your network. The HA server MUST be connected to the network through an Ethernet port to run properly.
It is expected that the OS has been installed with the openSSH optional package. Also make sure to unselect the use of the LVM partition scheme in the Ubuntu installation process, as it is not necessary for that kind of server, and simplify the management of the disk's space. A good tutorial on installing Ubuntu server 24.04 is available here.
-
Connect to the server using a terminal screen from your PC or MAC workstation/laptop. Replace
[USERNAME]with the username created when installing the OS, and[IP ADDRESS]with the server IP address. You can find it on the DHCP server (usually located on the main router of the network):$ ssh [USERNAME]@[IP ADDRESS] -
Update the system:
$ sudo apt update $ sudo apt upgrade -
Optional: If you have a defined rsa key to simplify access to the server from your PC or MAC workstation/laptop, do the following:
from another terminal session on your workstation/laptop, copy the .ssh credentials for login without password to the HA server:
$ scp .ssh/id_rsa.pub [USERNAME]@[IP ADDRESS]:.ssh/authorized_keys`On that terminal, test if you credentials were properly copied, loging back to the HA server with ssh, as per step 0. That must works without entering your password.
-
Back on the HA server, adjust timezone. But before, we use sudo to become a privileged process (The prompt becomes a '#' instead of '$'). You will be requested to enter your password:
$ sudo su [sudo] password for username: ****** # timedatectl set-timezone EST -
Lock root login:
# passwd -l root -
Optional: Secure SSH authentication ONLY IF YOU COPIED YOUR RSA CREDENTIALS AT STEP 2:
# cd /etc/ssh # nano sshd_configAdd the following lines
PermitRootLogin no PermitEmptyPassword no PasswordAuthentication noSave file using Ctrl-X and Y. Then restart the ssh daemon:
# /etc/init.d/ssh restart -
Reboot:
# sync # sync # reboot -
Login to the HA server as per step 0.
-
Check if the CPU can run VMs:
$ sudo su # egrep -c '(vmx|svm)' /proc/cpuinfo 8If the answer is 0, you need to go into the BIOS and change it to allow for VMs creation/run. Here is the procedure to do that:
To enable virtualization on a Lenovo ThinkCentre M900, you can:
-
Request a reboot of the HA server as per step 6
-
Using the connected keyboard, press Enter many times during the Lenovo startup screen until you get the firmware menu
-
Press F1 to enter the BIOS screens
-
Navigate to the "Advanced" screen
-
Press Enter on "CPU Setup"
-
Select "Intel(R) Virtualization Technology"
-
Press Enter, choose Enable, and press Enter
-
Press F10 (Save and Exit)
-
Select "Yes" to save the changes and allow the system to reboot
-
Login back to server as per step 0
-
Check again if you have VM support
$ sudo su # egrep -c '(vmx|svm)' /proc/cpuinfo 8
-
-
Install kvm:
# apt install -y qemu-kvm \ libvirt-daemon-system libvirt-clients \ bridge-utils ovmf virt-manager -
Add user to libvirt and kvm (may already been defined):
# adduser [USERNAME] libvirt # adduser [USERNAME] kvm -
Check that the libvirtd daemon is running:
# systemctl status libvirtd -
Create Home Assistant VM folder and download image. Please note that the latest release number could be different (here 16.2). You may want to look here to get the latest release information and adjust steps 12 and 15 accordingly:
# mkdir -vp /var/lib/libvirt/images/hassos-vm # cd /var/lib/libvirt/images/hassos-vm # wget https://github.com/home-assistant/operating-system/releases/download/16.2/haos_ova-16.2.qcow2.xz -
Setup storage pool:
# virsh pool-create-as --name hassos --type dir --target /var/lib/libvirt/images/hassos-vm -
Set up network
Install net-tools:
# apt install net-toolsCheck the Ethernet device name:
# ifconfignote the entry with the server's IP address. For me it was:
eno1Start the editor:
# nano /etc/netplan/00-installer-config.yamlModify the file to get a result similar to the following (replace
eno1with your own Ethernet device name):network: ethernets: eno1: dhcp4: false dhcp6: false version: 2 bridges: br0: dhcp4: true dhcp6: false interfaces: - eno1 parameters: stp: trueChange it's protection:
# chmod 600 /etc/netplan/00-installer-config.yamlThis configuration is good for a DHCP based network.
You may have to remove the file
50-cloud-init.yamlif present in the folder:# rm /etc/netplan/50-cloud-init.ymlIt's now time to generate the files and apply them to the system:
# netplan generate # netplan applyWith the last command, you will loose the connection with the server. Look back at the DHCP server to find a new device appearing with a new address, and reconnect to it:
$ ssh [USERNAME]@[NEW IP ADDRESS](This is the address supplied to the virtual device named br0. This is the bridge for VMs access to the network)
$ sudo su # brctl showCheck that you get the list of bridges. br0 must be listed (there can be other entries present):
bridge name bridge id STP enabled interfaces br0 8000.00215ec64304 yes eno1 -
Install the hassos VM
Goto the /var/lib/libvirt/images/hassos-vm and decompress the VM image.
# cd /var/lib/libvirt/images/hassos-vm # unxz haos_ova-16.2.qcow2.xzNow create the VM instance:
# virt-install --import --name hassos \ --memory 4096 --vcpus 4 --cpu host \ --disk haos_ova-16.2.qcow2,format=qcow2,bus=virtio \ --network bridge=br0,model=virtio \ --osinfo detect=on,require=off \ --graphics none \ --noautoconsole \ --boot uefiTo see if the VM is running:
# virsh list --allThe answer will look like this:
Id Name State ------------------------ 1 hassos runningYou can retrieve the VM MAC address using the following command:
# virsh dumpxml hassos | grep "mac address" | awk -F\' '{ print $2}'If you want the VM to restart automatically at boot time, do the following:
# virsh autostart hassos -
This complete the installation of Home Assistant. Look at your DHCP router and identify the IP address of the Home Assistant server (the entry may have the name
homeassistant). The MAC address retrieved in step 15 could be helpful to identify the proper entry in the DHCP server. Note the IP address. The startup of the Home Assistant server may takes 10-15 minutes to be completed for the first time, so it may takes some times before the IP address appears in the DHCP router.In your browser, you can then connect to Home Assistant using the following (depending on your router DNS support capability):
http://[IP ADDRESS]:8123 or http://homeassistant.local:8123