Monday, 6 January 2025

Debugging grub2 menus that won't fully boot (e.g. ArchLinux ISOs)

If you need to construct a grub2 menu, but then find that it does not work, you can add in some extra debug lines. For instance the grub2 read command will wait for you to press the RETURN key before continuing execution and an echo command can be used to track progress and view grub2 variable values.

Here is an example grub2 menu display output screen...



and here is the grub2 menu that was used...
menuentry "Arch Linux with Parameters" {
set iso_path="/_ISO/LINUX/archlinux-2024.12.01-x86_64.iso"
search --no-floppy -f --set=root $iso_path
probe -u $root --set=archiso_img_dev_uuid
loopback loop $iso_path
ls
echo
ls (loop)/
echo
ls /
echo
ls /_ISO/LINUX/
echo
echo archiso_img_dev_uuid=${archiso_img_dev_uuid}  iso_path=${iso_path}  root=${root} 
read
linux (loop)/arch/boot/x86_64/vmlinuz-linux archisobasedir=arch img_dev=UUID=${archiso_img_dev_uuid} img_loop=${iso_path}
initrd (loop)/arch/boot/x86_64/initramfs-linux.img
read
}

This menu sets iso_path to the path of the ISO file we wish to boot.