I have a bunch of live ISO files like GParted, CloneZilla, Boot-Repair, Ubuntu 14.04 32 bit, ... downloaded in /opt
and on my old BIOS machine, I used to be able to just add them to the grub menu and boot them. :-)
I now have an UEFI machine and all the information I can find are for BIOS machines.
What are the steps to boot these ISO files from grub?
I'm just I'm sick and tired of "burning" these to a USB stick all the time as I can never find the stick I need whereas my computer itself if much harder to loose in the total chaos around me here...) :-(
There is a bug in grub 2.04 so ensure you have a prior or later version.
Well, the basics for adding an ISO file to grub are the same for an UEFI as for a BIOS machine: edit
/etc/grub.d/40_custom
and add amenuentry
item (GParted is used in this example) to the bottom of the file:Now we're going to add a variable containing the directory where we stored the ISO (so far, so good: no differences with BIOS machines):
I'm using
/opt
to store these as I don't like creating directories in the root of my machine and according to the Linux File System Hierarchy that's where optional software should reside anyway.Before we add the
loopback
variable, we need to find out on which hard disk the file is stored, so we do a:df --output=source /opt/Live-ISOs/gparted-live-0.31.0-1-amd64.iso | tail -1
and the output on my machine is:/dev/sdb2
.However grub uses (
hdX,Y
) notation and this is where the difference between UEFI and BIOS machines comes in! So now reboot your machine, go into the grub menu and press C: This will bring you to the grub command prompt with different commands than you're used to but the only one that you need is:ls
.On my machine the output is:
Huh? 4 drives? I only have 3! And it's not
(hd1,4)
line on a BIOS but(hd1,gpt3)
in UEFI and(hd0)
has no partitions at all!Well, apparently when part of the NVRAM is used as storage and shows up as
(hd0)
you need to start numbering your drives at 1! Whereas all the information you find on booting ISO files says you have to start numbering from 0 (on BIOS machines this is always true, this is not necessarily the case on some UEFI machines ! )So the value for
loopback
becomes(hd2,gpt2)$GPartedISOFile
as the ISO file on my machine was/dev/sdb2
(second drivehd2
, second partitiongpt2
):Another difference is that the
linux
andinitrd
on BIOS machines are calledlinuxefi
andinitrdefi
on UEFI machines, which gives us our final result:So now save that file, and update grub with:
After all of the above, reboot, go into the grub menu, choose
GParted Live ISO
and you can now easily boot your ISO without having to hunt for a USB stick ever again!:-)
CloneZilla Live example (for this question )
An alternative is to just add a configfile to 40_custom like this:
I do this as when I update an ISO, I invariably forget to run
sudo update-grub
. The above entries never have to change and I can just edit livecdimage.cfg which has the same format as any 40_custom but without header lines, and is in my /ISO folder in my ISO partition.I do add toram as another boot parameter and on the system with Nvidia add nomodeset boot parameter. But still often have to unmount the /isodevice.
Unable to umount isodevice unmount ISO https://bugs.launchpad.net/ubuntu/+source/ubiquity/+bug/1155216
And this is part of my livecdimage.cfg file
mkusb MULTIBOOT HACK
Mkusb makes a great base for custom boot drive projects because of its abilities with both BIOS and UEFI.
This hack boots multiple ISO files including the Windows installer, and has a grub2 menu.
Grub2 menuentries for most OS are available using Google Search and are beyond the scope of this answer.
Use mkusb defaults when creating the Persistent USB drive.
Use mkusb persistence defaults if in doubt, partition size can be adjusted later but takes time.
The DUS Console after install.
GParted before partition modification.
Gparted after modification - Overwrite sdb4, the ISO9660 OS partition and sdb5, the ext2 casper-rw partition, with a FAT32 partition for persistence files.
Persistence partition - Create an uniquely name folder for each OS, (that requires persistence)
Persistence folder - Add a casper-rw file and optional home-rw file to each persistence folder. A home-rw file can be made by renaming a casper-rw file. A home-rw file is like a seperate home partition on a Full install, it can be reused after version upgrades.
Create a folder for the ISO files on the NTFS usbdata partition.
Add some ISO's to the ISO folder.
grub.cfg location
Edit grub.cfg to loopmount the ISO files. Include:
persistent persistent-path=/<persistent-folder-name>/
if you want persistence. Add rmmod tpm to grub.cfg above the first menuentry.EDIT 18.04+ In grub specify vmlinuz not vmlinuz.efi and initrd not initrd not initid.lz
sudo parted -ls /dev/sdb
sudo lsblk -f /dev/sdb
If a Windows installer is required it is possibly easiest to start with the mkusb "extracting Windows installer" function, (I had to extract the Windows ISO to TAR manually),
After installation create a folder for ISO's and if required, folders for persistence, (similar to above procedure).
Edit /boot/grub/grub.cfg to loopmount any ISO's and specify any persistence folders.
(have not found a way to loopmount a Windows ISO file).
If the above is used as a USB stick it can be used to boot ISO's stored on a Windows only computer. Grub is not required on the internal drive.
Three easy steps
to add ISO to the grub menu and boot from it.
First, install
grml-rescueboot
Open a terminal and enter:
Second, move the iso files to
/boot/grml/
In the same terminal enter:
Third, update grub
In the same terminal enter:
Repeat second and third steps as and when necessary
Don't forget to delete obsolete ISO files from
/boot/grml
.Reference: Ubuntu help on Grub2 ISO boot
Note
The
grml-rescueboot
does not work with all live ISO files. For example, the gparted live ISO does not work. See Unable to boot Gparted Live using grml-rescuebootHope this helps
MultiBootUSB - QEMU
If you want to boot ISO files with the least hassle and don't need persistence, MultiBootUSB includes a QEMU option:
Start MultiBootUSB and select the Boot ISO/USB tab.
Drag and drop the ISO on the Select image space.
Select RAM size and hit the Boot ISO button.
You don't need to edit grub.cfg or even log out.
SIMPLE mkusb ISO multibooter
If you don't need multi-persistence, it is easy to multiboot operating system ISO's on a mkusb flash drive.
Use mkusb to make a Persistent USB drive using a default OS of your choice, https://help.ubuntu.com/community/mkusb
Make a folder in the usbdata partition sdx1, named ISOs.
Add the ISO's to be booted to this folder.
Add menuentries to /sdx3/boot/grub/grub.cfg to loopmount the ISO's.
Samples:
This may be the multiboot solution that you need.
https://www.ventoy.net/en/index.html
This bootable USB maker creates two partitions in a USB drive. One is 32MB FAT 32 EFI partition. Another one is exfat partition that is equal in size to the rest of the USB drive. You can copy any number of ISOs including Windows to either the root folder or any subfolder. You can also use this partition for normal storage.
Select this USB in the boot menu and it will show all the supported ISOs as a list to choose from. In my experience it worked for Ubuntu, Kubuntu, Mint, Clonezilla and Windows.