Installation steps: Ubuntu on virtual machine kvm and with bridge mode networking!

Use case: Installation of Home Assistant on an old PC.
OS: Linux distribution. Preferably Centos 7 but I have been fighting with Ubuntu 20.
Home assistant to be installed on a KVM virtualization environment with static ip setup.
HA should be able to see all devices on the home LAN and integrate seamlessly with all devices.

Requirements: Stable environment, communication with all devices and integrations on the local network, ability to use the full functionality of home assistant with (medium to low) tweaking on the host OS.

User: IT Manager with Linux / centos experience and command line, python, with some bash scripting.

After a lot of efforts and reading manuals online, I have failed bitterly and failed multiple times. But finally it worked.

Sharing my experience i followed the sequence of steps that should apply on all Linux Distros:

  1. I installed kvm with all relevant utilities

  2. Deleted the default network bridge (NAT) that is automatically created by kvm, which supports NAT by default.

  3. Created a new network with bridge interface. One good instruction set i followed is found on this link. I guess similar instruction sets can be found for all distros but the process is actually the same.

  4. Installed the HA virtual machine as per normal documented procedure:
    a. Download the KVM disk image (qcow2)
    b. Create the VM using Virtual Machine Manager and **import ** the relevant disk image
    c. Select “Generic Default” as the OS Image
    d. Choose memory and CPU settings
    e. Give a name to the Virtual Machine. (I used “HomeAssistant” without spaces or funny chars.
    f. Click on “Customize configuration before install”
    g. Change the boot parameter to UFI
    and shoot!!

The only final thing missing is to set it up with static IP because by default it is using DHCP and gets the IP automatically from the network. I guess one could set the router DHCP setting to deliver the same IP configuring the MAC address of the ethernet i/face. The alternative is to use the HA nmcli and set the IP address manually as per the instructions found here.

2 Likes

Here is a way to add backups to your KVM instance: https://thegabo.dev/backup-script-for-kvm-virtual-machines/