I want to create a bootable OS image using mkosi that I can use to create a confidential VM. My mkosi.conf so far is:
[Distribution]
Distribution=ubuntu
Release=jammy
Architecture=x86-64
Repositories=main,universe,restricted,multiverse
[Build]
ToolsTree=default
[Content]
Bootable=yes
Bootloader=uki
Initrds=./initrd
InitrdPackages=cryptsetup-initramfs
libdevmapper1.02.1
dmsetup
kmod
busybox-initramfs
RootPassword=root
Packages=systemd
kmod
udev
dbus
tzdata
tpm2-tools
linux-azure
linux-headers-azure
grub-efi-amd64
grub-efi-amd64-bin
linux-firmware
apparmor
apparmor-utils
iptables-persistent
netfilter-persistent
ca-certificates
vim
docker.io
docker-compose
KernelCommandLine="console=ttyS0 systemd.volatile=overlay"
[Runtime]
Firmware=uefi-secure-boot
TPM=true
[Output]
Format = disk
ManifestFormat = json
and my partitions are pretty simple:
$ cat mkosi/rootfs/mkosi.rcat mkosi/rootfs/mkosi.repart/00-esp.conf
[Partition]
Type=esp
Format=vfat
CopyFiles=/efi:/
CopyFiles=/boot:/
SizeMinBytes=1G
SizeMaxBytes=1G
$ cat mkosi/rootfs/mkosi.repart/12-root.conf
[Partition]
Type=root
Format=ext4
CopyFiles=/
Minimize=guess
ExcludeFilesTarget=/var/
ReadOnly=yes
When I boot the resulting image using qemu locally, on a Ubuntu Azure VM:
sudo qemu-system-x86_64 -enable-kvm -cpu host -smp 6 -m 4096 -bios /usr/share/qemu/OVMF.fd -drive format=raw,file=/mnt/scratch/os_disk_azure.raw -nographic
I get a kernel panic:
[ 1.128508] /dev/root: Can't open blockdev
[ 1.129344] VFS: Cannot open root device "" or unknown-block(0,0): error -6
[ 1.130693] Please append a correct "root=" boot option; here are the available partitions:
this is very likely due to incorrect initramfs. But note that this works when linux-generic is used instead of linux-azure i.e. this image boots up fine in a generic kernel: 5.15.0-143-generic but fails on the azure linux kernel: 6.8.0-1031-azure.
Are there additional parameters I need to add to the mkosi.conf file? I am assuming an Azure image i.e. 6.8.0-1031-azure is needed to boot up a confidential VM.