efi | syslinux-efi | kernel efi stub
assuming the kvm host is up and running already
https://station.eciton.net/booting-a-full-system-with-ovmf.html
the efibootmgr -u flag doesn’t work with qemu+ovmf
(as noted at the very bottom of the that page)
todo - but it might be just fine on bare-metal
you need GPT partition table and the EFI firmware to be loaded into the kvm guest skeleton
# debian/ubuntu apt install ovmf fdisk gdisk ls -lkF /sbin/cfdisk ls -lkF /sbin/gdisk ls -lkF /usr/share/OVMF/OVMF_CODE.fd
same as guest-sabotage but this differs
guest=sabotage-efi
manual partitioning (GPT table required for once)
cfdisk $device gpt new 23G linux filesystem (default) new 1G linux swap new ~1G efi system (ESP) write
same as guest-sabotage but this differs
create filesystems and swap space
mkfs.vfat ${device}p3
mkdir -p lala/boot/efi/
mount -t vfat ${device}p3 lala/boot/efi/
vi lala/etc/fstab
/dev/vda3 /boot/efi vfat defaults 0 0
same as guest-sabotage but this differs
efi binary instead of boot code – here directly the linux kernel
grep CONFIG_EFI_STUB 6.1.49.domU.config mv -i 6.1.49.domU.config lala/boot/efi/vmlinuz.config mv -i 6.1.49.domU.vmlinuz lala/boot/efi/vmlinuz
efi setup instead of boot blocks
gdisk -l $device
efibootmgr --create --disk $device --part 3 --loader \\vmlinuz --label EFISTUB \
-u "root=/dev/vda1 ro console=tty1 console=ttyS0,115200n8 mitigations=off"
efibootmgr -v --disk $device
same as guest-sabotage but this differs
<os>
<loader readonly='yes' type='pflash'>/usr/share/OVMF/OVMF_CODE.fd</loader>
<type arch='x86_64' machine='q35'>hvm</type>
<boot dev='hd'/>
</os>
<features>
<acpi/>
</features>
<pm>
<suspend-to-disk enabled='yes'/>
<suspend-to-mem enabled='yes'/>
</pm>
need to load the efi binary manually on qemu+ovmf (no auto-boot there)
fs0: vmlinuz root=/dev/vda1 ro console=tty1 console=ttyS0,115200n8 mitigations=off
https://station.eciton.net/booting-a-full-system-with-ovmf.html
https://mricher.fr/post/boot-from-an-efi-shell/