I recently learned how to make my own LXD VM image based on Home Assistant's QCOW2 VM images. This blog post is a short write-up how to do that! This is of course useful for other qcow2 images as well.
Download a image
I downloaded the Home Assistant OS image in the qcow2 format, and uncompressed it. The image is intended for KVM, and LXD runs VM:s with Qemu/KVM so it's a good fit for LXD VM:s.
$ wget https://github.com/home-assistant/operating-system/releases/download/7.1/haos_ova-7.1.qcow2.xz
$ xz -d haos_ova-7.1.qcow2.xz
Write a metadata.yaml file
LXD need some metadata, the format is documented here. A minimal example that I used for Home Assistant can be found below:
architecture: x86_64
creation_date: 1643062675
properties:
description: Home Assistant OS 7.1
os: HAOS
release: 7
Save it as metadata.yaml, and make it a tarball with:
$ tar cf metadata.tar metadata.yaml
Import the image
Import the image as haos
with an image import:
$ lxc image import metadata.tar haos_ova-7.1.qcow2 --alias haos
Launch it!
That's all, now start it like any other VM with the --vm
flag. LXD will only launch signed images with secure boot by default, to disable that add -c security.secureboot=false
. The full command I used to launch this specific VM was:
$ lxc init haos homeassistant --vm \
-c security.secureboot=false \
-c limits.cpu=2 \
-c limits.memory=4GiB
That's all!