GRUB: Better support for booting ISO from loopback via loopback.cfg

GRUB2 is very powerful and supports booting from custom locations. However the installation media I downloaded (Fedora-Server-dvd-x86_64-41-1.4.iso) runs into issues booting unless the ISO disk is booted from directly. This makes it more complex to create a customized live USB, where the ISO may be stored on a separate partition.

When booting via GRUB loopback as so

set iso_path=/Fedora-Server-dvd-x86_86-41-1.4.so
export iso_path
search --set=root --file $iso_path
loopback loop $iso_path
root=(loop)
configfile /boot/grub2/grub.cfg  # path to grub on ISO

systemd appears to get stuck on the unit cancel-multipath-wait-sda. Given that systemd is producing messages, it looks like the loading of the initrd is successful.

I have run the following command

grep -r 'cancel-multipath' /usr

when booting directly from the ISO and this appears to part of udev. However I think this error may be a downstream consequence rather than a primary bug. (Hopefully search engines pick up on this for others running into weird errors)

My TOTAL GUESS is that this is caused by the kernel parameter

inst.stage2=hd:LABEL=Fedora-S-dvd-x86_64-41

which will only work if there is indeed a partition with this label, which may not be the case for a customized installation USB!

Rather the installation ISO should include a loopback.cfg that properly sets the kernel parameters based on grub environment variables.

The file should be identical to to the grub.cfg that is already present with one change:

menuentry "Install Fedora 41" {
  linux /images/pxeboot/vmlinuz insta.stage2=$root ...
  ...
}

This seems like a pretty small tweak, but I’m unfamiliar with the build process for the main fedora ISO release so testing it would take some time. I was hoping to get feedback before diving in.

I actually found a better way to this borrowing from multibootusb.

The disk label can be found with probe:

probe --label --set=cd_label (loop)