LXD VM for Home Assistant

Home Assistant Agent is used for Home Assistant OS and Home Assistant Supervised installation types and it allows the Home Assistant Supervisor to communicate with the host operating system and handles additional tasks on the host and without it the Supervisor won’t be able to fulfill its tasks and responsibilities.

Home Assistant Supervised provides the full Home Assistant experience on a regular operating system without the Home Assistant Operating System. This system will run the Home Assistant Supervisor. The Supervisor is not just an application, it is a full appliance that manages the whole system. It will clean up, repair or reset settings to defaults if they no longer match expected values.

We are going to learn how to install Home Assistant in a LXD Virtual Machine.

Create the required LXD VM Debian Bullseye Instance. Note: Watch my LXD 101 video to learn how to create the required bridge used in the following command:

lxc init images:debian/11 --vm HomeAssistant --profile default --profile bridgeprofile -c boot.autostart=true -c limits.cpu=4 -c limits.memory=4GiB

Enlarge the LXD VM virtual disk:

lxc config device override HomeAssistant root size=100GiB

If you have a Zwave or Zigbee USB device, plug it into your LXD host and do a “lsusb” to find out its vendor id and product id. Here’s a mock example of making a zwave device on your LXD host available to your LXD VM. Your values will be different.

lxc config device add HomeAssistant zwave usb vendorid=a012 productid=4a01

Start your LXD VM and check to see if it has an address with “lxc list”.

lxc start HomeAssistant

Once it has an address, connect to the console bash shell.

lxc exec HomeAssistant bash

Install the components required to resize the partition and the root file system of the container.

apt install cloud-guest-utils fdisk -y

Enlarge the partition to the size of the disk.

growpart /dev/sda   2

Resize the root file system to the size of the enlarged partition.

resize2fs /dev/sda2

Check for and apply all updates to your container.

apt update && apt upgrade -y

Add a user, put the user in the sudo group and move into the new user account.

adduser scott
usermod -aG sudo scott
su - scott

Install the required dependencies.

sudo apt install ca-certificates curl gnupg lsb-release network-manager udisks2 wget apparmor jq libglib2.0-bin dbus lsb-release systemd-journal-remote -y

Create a folder for keyring signatures.

sudo mkdir -m 0755 -p /etc/apt/keyrings 

Get the signature for docker and put it in the keyring folder.

curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Add the docker repository, update the repository list and install the required docker components.

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Put my user account in the docker group.

sudo usermod -aG docker scott
newgrp docker

Download and install the Home Assistant Agent:

wget https://github.com/home-assistant/os-agent/releases/download/1.5.1/os-agent_1.5.1_linux_x86_64.deb
sudo dpkg -i os-agent_1.5.1_linux_x86_64.deb

Download and Install Home Assistant Supervised:

wget https://github.com/home-assistant/supervised-installer/releases/download/1.4.3/homeassistant-supervised.deb
sudo dpkg -i homeassistant-supervised.deb

Go to your web browser at the address of your LXD VM at port 8123.


After a few minutes you should be able to register an account and get started as in the video. Optionally, you may create a subdomain name for your Home Assistant instance and make an NginX Proxy Manager entry with an SSL certificate if you want your instance to be reachable outside your network.


In order to enable reverse proxy, you must edit your Home Assistant configuration.yaml and add the following to the bottom of the file adjusting the proxy IP address to be the address of your NginX Proxy Manager:

  use_x_forwarded_for: true
    - XXX.XXX.XXX.XXX # Add the IP address of the proxy server

For questions, visit my chat:


Alternative install method
How to Install HAOS as a LXD VM
Why use this alternative install method?

No need to manually resize the partition and the root file system of the LXD VM container, this is handled automatically on first boot.

By installing HAOS you get a Home Assistant install that is an appliance with a Managed OS…
As Linux users we generally regard an ‘appliance type install’ in a negative connotation because we associate it with something for a Noob. As a Linux user for 20 years I am certainly guilty of this.
Home Assistant makes changes to the OS requirements from time to time. By giving up control over the OS, we unburden ourselves from managing the OS and keeping it updated to meet changing requirements.
As someone who has in the past run home assistant in a Python Virtual Environment, where I had to manage the OS, I can tell you it can be a lot of work when Home Assistant changes the requirements for something major such as minimum required version of python.
When running HAOS in a LXD VM if there is a new release of HAOS you will see a notification when you open your Home Assistant Dashboard, simple click on it and allow an update of HAOS.
I have been running HAOS as a LXD VM for several months, during which time new releases of Home Assistant as well as HAOS have become available. By simply clicking on the notification in the Home Assistant Dashboard these updates were installed.
HAOS as a LXD VM is running flawlessly for me, I could not be happier with it’s operation and performance.

  1. Download latest Home Assistant Operating System image for Linux in KVM (.qcow2.xz) compressed format, decompress to .qcow2 format
    currently haos_ova-10.3.qcow2.xz VERSION will change over time.
    Click on KVM link in browser or use wget from command line
wget https://github.com/home-assistant/operating-system/releases/download/10.3/haos_ova-10.3.qcow2.xz

change to directory you downloaded to
decompress with xz

xz -dv haos_ova-10.3.qcow2.xz
  1. Create a metadata.yaml file for LXD. The creation_date is a date time in epoch format get current epoch time with:
    visit https://www.epochconverter.com or in a Linux terminal run
    date +%s

metadata.yaml contents:

architecture: x86_64
creation_date: 1687882376
  description: Home Assistant OS
  os: HAOS
  release: 10.3
  1. Create tarball from metadata.yaml

    tar cf metadata.tar metadata.yaml
  2. Import image to LXC as HomeAssistant

lxc image import metadata.tar haos_ova-10.3.qcow2 --alias HomeAssistant
  1. Initialize LXD image
    **** NOTE unfortunately the Home Assistant image does not support secure boot, so we must set security.secureboot=false
    **** NOTE minimum root,size=35GB this will yield Disk Free 26 GiB, Disk use 4 Gib, Disk use percent 14%, on first boot before anything extra is installed.
    **** Adjust root size to something 35GB or greater.
    **** Adjust limits.cpu and limits.memory to your desired values. Home Assistant Minimum recommended values 2 GB RAM, 2vCPU
    **** Add any additional profiles you may need with --profile YOUR-PROFILE-NAME
lxc init HomeAssistant HomeAssistant --vm --profile default -c security.secureboot=false -c boot.autostart=true -c limits.cpu=4 -c limits.memory=4GiB -d root,size=35GB
  1. Clean up you can delete these files from your working directory to free up space:

@Panders Paul, consider creating a video using your method. Following the procedure that I have provided it is necessary to resize the Debian Bullseye partition and file system because the default container size is too small. This has been automated in some LXD VM containers such as Ubuntu. Debian Bullseye (the recommended OS for HA) requires resizing.

By installing the Home Assistant Agent and the Home Assistant Supervisor, you will get standard notifications for the upgrade of HA in the GUI just like you would with the imaged appliance file just like you do.

Your installation method is certainly novel. My issue with “Appliances” like this are that they become effectively black boxes and the HA published “Advanced Installation” process I presented in the video will be more familiar to my subscribers who watch the channel for the 60+ LXD tutorials I’ve created.

I appreciate your alternative method and it is certainly one that you had to develop after much testing, I am sure. Perhaps you should submit this work to the HA folks considering that LXD VM’s are gaining in popularity. I thank you for this valuable alternative option.

@scott Scott,
Sorry to show up out of nowhere and post the alternative method as my first post. Not trolling you, Did not mean to infer that it was a better way to do the install, just easier in my mind. Not really a novel method LXD has info on importing a qcow2 image, Home Assistant makes a qcow2 image available. 1+1=2 Tried it, it worked, been running the VM for months with zero issues so testing is complete? Apologies for not commenting on you videos or posting here earlier. Tend to be pretty quite online and somewhat of a deep lurker. I’m a huge fan of your YouTube channel, have watched most all of your LXD videos, they taught me most of what I know about LXD. As for video production leaving that to folks like yourself who excel at it. I certainly hope LXD and LXD VM’s are gaining in popularity they seem to have been a well keep secret for a long time. Thanks for all your hard work your content is terrific!

@Panders Paul, actually I had a friend call me yesterday and ask if there was a way to do what you had done. I referred him to your method and he had not had any luck with it till he tried your method. So, thanks!