I successfully got a VM to boot in BIOS mode

We are running a bunch of VMs under KVM in BIOS mode, and are currently working out how to migrate these VMs to boot under LXD.

Interestingly, we do not have local storage, and boot our VMs from iSCSI storage. Thankfully, we do not manually configure iSCSI boot settings (iBFT) because that is handled by iPXE in our environment.

The issue was that converting a host to EFI is commonly known as a huge pain, and involves repartitioning hosts if you don’t want to host a kernel and initramfs somewhere else. It gets messy.

There is sparse documentation on getting BIOS VMs to boot on LXD, BUT we have been successful in getting this to work.

The basic steps are:

  1. Install seabios
  2. bind mount the seabios directory somewhere LXD can use it
  3. Add this location read-only to the VM config via raw.apparmor
  4. Set the bios to use via raw.qemu -bios

The VM should then boot normally. It should fail through to ipxe boot if there are no storage devices available.

This fixed our issue, and our VMs are booting normally. Commands used for reference:

root@lxc:/# apt-get install seabios
root@lxc:/# mount --bind /usr/share/seabios /var/lib/snapd/hostfs/usr/share/seabios/ # This should probably be added to fstab
root@lxc:/# lxc config show disposable-me-3
architecture: x86_64
config:
  raw.apparmor: /var/lib/snapd/hostfs/usr/share/seabios/bios-256k.bin r, # Add this so the VM can see the bios
  raw.qemu: -bios /var/lib/snapd/hostfs/usr/share/seabios/bios-256k.bin # And this so it boots to the bios
  security.secureboot: "false"
devices: {}
ephemeral: false
profiles:
- production
- external
stateful: false
description: ""
root@lxc:/#

This commit note was the key to my finding this:
https://github.com/lxc/lxd/pull/10188

Also referenced this:

5 Likes

#whywasthissohard?

2 Likes

This post enabled me to run this basic benchmark that I use to ensure a VM system lets me run legacy software (of which I have a lot).

I didn’t need the bind mount.

Cheers!

Fucking exactly.
Also, where’s my default public VM bridge?
Or my “boot override” and “enter bios”?

Speaking for Incus as we don’t do LXD here anymore.

Our normal UEFI build has a 3s boot delay for you to enter the menu so that should be fine.
It also respects boot.priority on the disk or nic devices, so you can use that to control the boot order.

For BIOS mode, you can just set security.csm=true and you’ll get a legacy BIOS boot.

Woah, how did you install this Version of LXDUI!? After struggling with pip libraries I got the old one from Adaptive Scale to run, I did not know there was one with Graphical Console support and so on. How can I get this?

Have a look at this guide, How to install and setup the Incus Web UI – Mi blog lah!

1 Like

This is for Incus, I tried getting to run a VM with Seabios on Incus but it didnt work. Also the Incus UI has this weird client certificate authentication and is hard to use behind a reverse proxy