booting efi with syslinux

efi | syslinux-efi | kernel efi stub

warning // lessons learnedwarning // lessons learned

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).

efi setupefi setup

efi binary instead of boot code

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/

efi setup instead of boot blocks

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

boot config on esp

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

kernel on esp

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

ready to goready to go

need to load the efi binary manually on qemu+ovmf (no auto-boot there)

fs0:
syslinux.efi

resourcesresources

https://web.archive.org/web/20250602062321/https://wiki.syslinux.org/wiki/index.php?title=Install#UEFI

https://wiki.archlinux.org/title/Syslinux#UEFI_systems

https://wiki.gentoo.org/wiki/Syslinux/en

https://unix.stackexchange.com/questions/38147/how-to-configure-syslinux-to-load-the-kernel-images-from-a-different-partition-o

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


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Licensed under MIT