efi | syslinux-efi | kernel efi stub
works fine if you put the kernel on the ESP, but woudln’t it be cool if one could keep the kernel in its rightful place (/vmlinux or /boot/vmlinux outside the ESP)?
grub is a bit more efficient for this scenario, as it is able to load another filesystem on a different partition – with syslinux you need to chainload from EFI to casual boot (possibly yet another syslinux there).
assuming ESP is on GPT partition 3 and mounted vfat as /boot/efi/
mkdir -p /boot/efi/EFI/ # debian/ubuntu cp -vf /usr/lib/SYSLINUX.EFI/efi64/syslinux.efi /boot/efi/EFI/ cp -vf /usr/lib/syslinux/modules/efi64/* /boot/efi/EFI/
device=/dev/sda device=/dev/nbd0 gdisk -l $device efibootmgr --disk $device --part 3 --create --loader \\EFI\\syslinux.efi --label SYSLINUX --bootorder 0000 efibootmgr --disk $device --part 3 --delete-bootnext efibootmgr --disk $device --part 3 --remove-dups
remove the default ubuntu boot entry
efibootmgr --disk $device --bootnum 0001 --delete-bootnum
and clean-up your own shit (remove-dups didn’t do)
for hex in 0007 0008 0009 000A 000B 000C; do
efibootmgr --disk $device --bootnum $hex --delete-bootnum --quiet && echo done with $hex
done; unset hex
check
efibootmgr -v --disk $device --part 3
==> you should see the new entry in first position and as default efi boot entry
don’t forget to fix the path to root partition accordingly in the syslinux config,
in case you’ve got the ESP as partition 1.
in our case we’ve put the ESP on partition 3 so that doesn’t matter, root partition remains at first position (/dev/vda1).
boot config goes same place as EFI binary file
vi /boot/efi/EFI/syslinux.cfg
serial 0 115200
console 1
nohalt 1
default linux-on-esp
prompt 1
timeout 100
label linux-on-esp
linux /vmlinuz
append root=/dev/vda1 ro console=tty1 console=ttyS0,115200n8 mitigations=off
finally make the linux kernel image available there – that’s the dirty part we’re discussing here – as we would obviously prefer to keep it on the target filesystem
ls -lkF /boot/efi/vmlinuz
need to load the efi binary manually on qemu+ovmf (no auto-boot there)
fs0: syslinux.efi
https://wiki.archlinux.org/title/Syslinux#UEFI_systems
https://wiki.gentoo.org/wiki/Syslinux/en
https://wiki.gentoo.org/wiki/Syslinux/en
https://www.rodsbooks.com/efi-bootloaders/syslinux.html
https://unix.stackexchange.com/questions/703920/create-bootable-syslinux-usb-on-uefi
https://man.archlinux.org/man/efibootmgr.8.en