Boot an iso on your hard drive using grub2 - March 13, 2018 - amended August 12, 2020
See - https://www.howtogeek.com/196933/how-to-boot-linux-iso-images-directly-from-your-hard-drive/
https://help.ubuntu.com/community/Grub2/ISOBoot
https://help.ubuntu.com/community/Grub2/ISOBoot/Examples
This post was inspired by a user question a few years ago. Following these guides helped me create the following two entries in my custom grub file located at /etc/grub.d/06_custom. You may edit the provided 40_custom file instead if that is more convenient. The entries below are provided as an example.
menuentry "live CD (on /dev/sda6)" {
set isofile="/Iso/ubuntu-mate-16.04.4-desktop-amd64.iso"
loopback loop (hd0,6)$isofile
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile quiet splash video=SVIDEO-1:d
initrd (loop)/casper/initrd.lz
}
The above example was for 16.04 isos only. All isos above should use the example below the explanation.
Line 1 is the name you want to display in your grub menu.
Line 2, the path seen between the quotes is on a data partition /dev/sda6, note no "/home/data4" needed.
Line 3, "(hd0,6)" provides the drive location on my sda6.
Line 4, the .efi suffix for vmlinuz is needed with 64 bit 16.04 isos, quiet splash was added to remove a lot of garbage, and the "video=SVIDEO-1:d" boot parameter was added to accommodate the integrated graphics card on this old laptop. The .efi suffix is dropped for all isos above 16.04.
Line 5, the .efi suffix is dropped for all isos above 16.04. Example shown below:
menuentry "live CD (on /dev/sda6)" {
set isofile="/Iso/ubuntu-mate-18.04.4-desktop-amd64.iso"
loopback loop (hd0,6)$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile
initrd (loop)/casper/initrd
}
I prefer the 18.04.4 live CD iso over 20.1 as I am quite lazy and don't like to press Cntrl-C to bypass the iso checking feature introduced in the 20.1 live CD - your choice of course.
I also wanted to add an entry for partition magic but it required something more specific. I added a pmagic folder to my boot directory and, following their instructions, entered the following in my custom grub file -
menuentry "Parted Magic" {
set root=(hd0,9) # 20.04 root on /dev/sda9
linux /boot/pmagic/bzImage64 root=/dev/sda9 directory=boot edd=on vga=normal # root location
initrd /boot/pmagic/initrd.img /boot/pmagic/fu.img /boot/pmagic/m64.img
}
See -
Make sure that your custom grub file is executable. Then after making changes in this file, remember to enter sudo update-grub
in the terminal and reboot to see (and verify) the changes.