The ultimate grub.cfg to help you boot isos without burning them to disk/usb

Just copy the text below! Paste it into a file called isoboot.cfg and place that on the root of your drive. Then make a folder called boot-isos and rename it to boot.iso. If you are a distro hopper, you could also modify this cfg slightly to test multiple live systems on one drive!!

You MUST have grub2 installed, or loaded from USB to use this!

isoboot.cfg
menuentry "Find root"  {
    search --no-floppy --set=root --set=drive -f /isoboot.cfg
    echo Drive ($drive) set as root! Select your OS!
    echo or use "loop isofile" to allow searching boot.iso using ls or [tab]
    sleep 6
}
menuentry "Boot Fedora OS" --class fedora --class gnu-linux --class gnu --class os {
        set root=($drive)
        set isofile="/boot-isos/boot.iso"
        export iso_path
        search --no-floppy -f --set=root $isofile
        loopback loop $isofile
        probe --set isolabel --label (loop)
        echo Booting Fedora! Enjoy :) 
        sleep 1
        linux (loop)/isolinux/vmlinuz root=live:CDLABEL=${isolabel} rd.live.image verbose iso-scan/filename=${isofile}
        initrd (loop)/isolinux/initrd.img
}
menuentry "Boot Ubuntu-based os" --class ubuntu {
    set root=($drive)
    set isofile="/boot-isos/boot.iso"
    loopback loop $isofile
    echo Booting Ubuntu-based os! Enjoy :)
    sleep 1
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject toram
    initrd (loop)/casper/initrd
}
menuentry "Boot Arch based os" --class arch  {
    set root=($drive)
    set isofile="/boot-isos/boot.iso"
    set dri="free"
    search --no-floppy -f --set=root $isofile
    probe -u $root --set=abc
    set pqr="/dev/disk/by-uuid/$abc"
    loopback loop $isofile
    echo Booting Arch! Enjoy :)
    sleep 1
    linux  (loop)/arch/boot/x86_64/vmlinuz  img_dev=$pqr img_loop=$isofile driver=$dri 
    initrd  (loop)/arch/boot/intel_ucode.img (loop)/arch/boot/x86_64/archiso.img
}

}
menuentry "loop isofile"  {
    set isofile="($drive)/boot-isos/boot.iso"
    loopback loop $isofile
    echo If you see no errors, use ls (loop)/ to search your isofile!
    sleep 4
}
#Name this file isoboot.cfg
#OS Boot Image must in a folder called placed on the root of the drive called boot-isos. 
#The os image must be renamed to boot.iso. 
#Resulting in the path /boot-isos/boot.iso
#This grub file must be placed on the root of the drive.
#To use this cfg, get to a grub prompt using "C" on bootup.
#Find your drive identifier using  search --no-floppy --set=isoboot /isoboot.cfg . Run command configfile ($isoboot)/isoboot.cfg
#Run Find root before attempting to boot
#Before using this, you may need to edit paths to kernel and initrd
#Use init iso, then in the appropriate entry, specify the new paths
#Hint: use the [tab] key to quickly list all files in a given path
#Then choose the entry that matches the OS you intend to boot!!

9 Likes

Or use ventoy, no need to format USB drive and you can have multiple ISO in one USB drive.

3 Likes