Issue with Deploying Custom Images on MaaS 3.5.2

Hello everyone,

I’m using MaaS 3.5.2 and facing issues deploying custom images.
This setup worked fine a few weeks ago, but now it no longer does.

I’m generating a QEMU image using this repository: kubernetes-sigs/image-builder.
After generating the image, I convert it using the following process:

QEMU_IMAGE_FILE=images/capi/output/ubuntu-2204-efi-kube-$K8S_VERSION/ubuntu-2204-efi-kube-$K8S_VERSION

TMP_DIR=$(mktemp -d /tmp/packer-maas-XXXX)
echo 'Binding Packer qcow2 image output to NBD...'
modprobe nbd
qemu-nbd -d /dev/nbd4
qemu-nbd -c /dev/nbd4 -n $QEMU_IMAGE_FILE
echo 'Waiting for partitions to be created...'
tries=0
while [ ! -e /dev/nbd4p2 -a $tries -lt 60 ]; do
    sleep 1
    let tries++
done

if [[ $tries -gt 60 ]]; then
    echo "Partition /dev/nbd4p1 cannot be mounted. Stopping here!"
    exit 2
fi

echo "Mounting image..."
mount /dev/nbd4p2 $TMP_DIR
mount "/dev/nbd4p1" "$TMP_DIR/boot/efi"
echo 'Creating a tar archive of the image...'
tar -Sczpf $IMAGE_NAME.tar.gz --acls --selinux --xattrs -C $TMP_DIR .
echo 'Unmounting image...'
umount "$TMP_DIR/boot/efi"
umount $TMP_DIR
qemu-nbd -d /dev/nbd4
rmdir $TMP_DIR

However, when I attempt to deploy the image, I encounter a GRUB error
The install log are available here: Logs

Default MaaS images work fine, including custom images built using canonical/packer-maas.

Does anyone have any ideas on what might be causing this issue?

Thanks in advance!

Why is it installing for a i386 platform instead of amd64?

Stderr: Installing for i386-pc platform.
        grub-install: warning: this GPT partition label contains no BIOS Boot Partition; embedding won't be possible.
        grub-install: warning: Embedding is not possible.  GRUB can only be installed in this setup by using blocklists.  However, blocklists are UNRELIABLE and their use is discouraged..
        grub-install: error: will not proceed with blocklists.
        
Unexpected error while running command.
Command: ['unshare', '--fork', '--pid', '--', 'chroot', '/tmp/tmpxkazgn3n/target', 'grub-install', '/dev/sda']
Exit code: 1

@zmance As I remember, i386-pc is for BIOS mode (the machine is running in BIOS mode, not UEFI).

When we use UEFI, another error occurs.

 grub-efi-amd64 : Conflicts: grub-pc but 2.06-2ubuntu7.2 is to be installed
 grub-pc : Conflicts: grub-efi-amd64 but 2.06-2ubuntu14.4 is to be installed
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.
Running command ['udevadm', 'settle'] with allowed return codes [0] (capture=False)
TIMED subp(['udevadm', 'settle']): 0.031

One thing I didn’t notice is how QEMU starts the VM (BIOS or UEFI). I’ll check this info.