Difficulties with booting from known ISO files by GRUB2

I loaded a few ISO files which I can try out by the application “Boxes 3.30.2-1.1” (in principle). I would like to construct a corresponding boot menu for the software “GRUB 2.02-35.1”.

Example:

…

  menuentry 'Knoppix 8.2 (aus einer Ext3-Partition)' --class Debian --class Linux --class ISO {
    insmod part_msdos
    insmod ext2
    ISO='/ISO/KNOPPIX_V8.2-2018-05-10-DE.iso'
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/boot/isolinux/isolinux.bin findiso=${ISO} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX} lang=de ${EXTRA}
    initrd (xyz)/boot/isolinux/minirt.gz
  }

  menuentry 'GParted 0.32.0-1 (aus der SSHD-Boot-Partition)' --class Debian --class Linux --class ISO {
    insmod part_msdos
    insmod ext2
    ISO=/ISO/gparted-live-0.32.0-1-amd64.iso
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/syslinux/isolinux.bin boot=live config union=aufs noswap noprompt ip=frommedia findiso=/boot$ISO toram=filesystem.squashfs lang=de keyboard=de
  }

…

I know that similar specifications worked for a while. But I wonder about the message “error: invalid magic number” now after I selected one of these boot menu entries.
Which places should be adjusted for the desired functionality?

grub2 “linux” loader expects Linux kernel which isolinux.bin is not. You want kernel from this ISO, not another loader.

I would like to continue with the usual “boot menus” which can be provided also by such ISO files.
Do you know more appropriate specifications for the GRUB configuration script?

grub2 does not support CD emulation. Use syslinux memdisk.

How should a GRUB2 configuration script take such a detail better into account?

Do other information sources provide more promising descriptions for the direct usage of ISO files with GRUB2?

  • Will it be needed to write the magic number0xaa55” into any more ISO files again (by a special command)?
  • Why do the two GRUB boot command examples fail when their ISO files can be successfully used for the execution by virtual machines?

The following boot menu specifications seem to work.

…
  menuentry 'GParted 0.32.0-1' --class Debian --class Linux {
    insmod part_msdos
    insmod ext2
    ISO=/ISO/gparted-live-0.32.0-1-amd64.iso
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/live/vmlinuz boot=live config union=overlay username=user noswap noprompt ip=frommedia findiso=/boot$ISO toram=filesystem.squashfs lang=de keyboard=de
    initrd (xyz)/live/initrd.img
  }

  menuentry 'Grml 2017-05' --class Debian --class Linux {
    insmod part_msdos
    insmod ext2
    ISO=/ISO/grml64-full_2017.05.iso
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/boot/grml64full/vmlinuz boot=live live-media-path=/live/grml64-full/ findiso=/boot$ISO bootid=grml64full201705 grml2ram ssh=secret noeject noprompt lang=de vga=0x31b startx
    initrd (xyz)/boot/grml64full/initrd.img
  }
…

Do you get any further ideas for fixing another configuration approach?

…
  menuentry 'Knoppix 8.2' --class Debian --class Linux {
    insmod part_msdos
    insmod ext2
    ISO='/ISO/KNOPPIX_V8.2-2018-05-10-DE.iso'
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/boot/isolinux/linux64 findiso=${ISO} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX} lang=de ${EXTRA}
    initrd (xyz)/boot/isolinux/minirt.gz
  }
…

The following boot menu specifications work also on my test system as desired.

…
  menuentry 'Knoppix 8.6 (aus einer Ext3-Partition)' --class Debian --class Linux --class ISO {
    insmod part_msdos
    insmod ext2
    ISO='/ISO/KNOPPIX_V8.6-2019-08-08-DE.iso'
    search -f --set --no-floppy $ISO
    loopback xyz $ISO
    linux (xyz)/boot/isolinux/linux64 bootfrom=/dev/sdc1${ISO} ${GRUB_CMDLINE_LINUX_DEFAULT} ${GRUB_CMDLINE_LINUX} lang=de ${EXTRA}
    initrd (xyz)/boot/isolinux/minirt.gz
  }
…

Way back when I looked at booting ISO files in GRUB2,

You not only had to create the menu entry, you also had to mount the ISO in GRUB.
No big deal, but it’s something that has to be done, and it’s not mounted the same way you mount in a running full OS.

TSU

Would you like to clarify appropriate command line parameters any further?