Help launching aloha applicance with LXC

Launching an applicance with LXC

I’m trying to get this image to start with lxc:

Its an appliance image which should work on KVM, so I think it would work with LXD.

This is the instructions for virsh (super old but anyway):

  On Ubuntu 12.04 LTS:

  # sudo apt-get install virtinst python-virtkey python-libvirt libvirt0 libvirt-bin kvm kvm-ipxe qemu qemu-kvm

B) Virtual Appliance Installation:

   1. UnTAR  aloha-albkvm-4.1.tar.gz
   2. Copy aloha-albkvm-4.1.img to /var/lib/libvirtd/images
   3. Create a new virtual machine with virtinstall:

   [root@ubuntu] # virt-install \
     -n aloha1 \                         						# virtual machine name
     -r 512 \			                  					# MB RAM
     --accelerate \		                  					# hardware virtualization
     --disk path=/var/lib/libvirt/images/aloha-albkvm-4.1.img,bus=ide,cache=none \	# disk image
     --os-type linux \
     --os-variant virtio26 \	                  					# kvm specific driver
     --network=network:default \  							# virtual network parameter ( or --network bridge=br0 on a bridge)
     --nographics \

I’ve been trying to get it to start with lxc as follows, replacing the boot disk with the downloaded image:

# Create a new container-vm with a minimal root disk (since I'm not going to use it, but rather replace it with the applicance disk).

$ lxc init aloha1 --empty --vm -c security.secureboot=false -d root,size=1MiB
Creating aloha1

# Add the applicance disk and set it to prio=10.
$ lxc config device add aloha1 aloha-disk disk source=/home/erik/Downloads/aloha-albva/aloha-albva.img boot.priority=10
Device aloha-disk added to aloha1

But no luck.

Please advice.

1 Like

Try using security.csm=true to enable legacy (non-UEFI) boot mode.

Keep in mind the OS being installed will need to be able to support virtio storage and network drivers.

Thanx @tomp !

It might have helped, but I also did some changes in the process of going from the raw image I had and skipped converting it to a qcow2 - but simply used the .img as it was (It was probably already a qcow2).

lxc version: 5.20
lxd snap version: lxd 5.20-f3dd836 27049  latest/stable canonical**

This is what got this to work starting the appliance with lxc.


# Define variables
description="A KVM image for HProxy aloha."
creation_date=$(date +%s)

# Generate metadata.yaml
cat << EOF > metadata.yaml
name: $name
description: "$description"
disk_format: $disk_format
architecture: $architecture
creation_date: $creation_date
  type: $source_type
  url: $source_url

echo "metadata.yaml generated successfully!"

# Create the image the way lxd wants it to be packed with the metadata.yaml
tar -czvf aloha-albva.tgz aloha-albva.img metadata.yaml

# Import the image to lxd
lxc image import ./aloha-albva.tgz --alias aloha

# Launch a container using the newly imported image.
lxc launch aloha aloha1 --console=vga \
    --config security.secureboot=false \
    --config security.csm=true \

There’s also lxd-migrate which allows importing a raw image (not qcow2) file into a VM directly rather than having to go via the intermediate image step.

This also avoids having 2 disks, one root disk and one boot disk.

1 Like

But the description tells a story where I would need to have to use the remote and networking etc?

The process seemed like a big undertaking?

Yeah for now you would need to use a local remote on the loopback address.

We do have plans to address that to allow using a local unix socket too.

1 Like

Update for this is that the image only booted on later versions on LXD for some reason.

5.18 - Didn’t work.
5.20 - Works

1 Like