11

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...) :-(

  • 1
    I went this way a while back and it's awesome. – Organic Marble Apr 17 '18 at 0:43
  • 1
    I do like to use a separate partition, one on each drive to make it easier to install to other drive or full drive install to flash drives. help.ubuntu.com/community/Grub2/ISOBoot Examples: help.ubuntu.com/community/Grub2/ISOBoot/Examples I find getting path correct as it is before partitions are mounted and getting detailed boot parameters as the two major issues on getting it to work. Path even can change if flash drive plugged in. And looking into ISO to see its boot stanza & path can help you figure out details. – oldfred Apr 17 '18 at 3:45
  • 1
    I used this 'grub-n-iso' method a lot before, and it works well :-) but now I test iso files in a separate computer for testing, and I clone from the iso files to fast USB3 pendrives or create persistent live USB pendrives with mkusb. (I store my USB pendrives in a small plastic box.) – sudodus Apr 17 '18 at 6:01
  • VBox runs ISO files OK, use save machine state when exiting, MultiBootUSB has an option for drag and drop ISO booting and QEMU with Virtual Machine manager will quickly run an iso. – C.S.Cameron Apr 17 '18 at 19:05
13

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 a menuentry item (GParted is used in this example) to the bottom of the file:

menuentry "GParted Live ISO" {
}

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):

menuentry "GParted Live ISO" {
  set GPartedISOFile="/opt/Live-ISOs/gparted-live-0.31.0-1-amd64.iso"
}

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 we need you already know: ls.

On my machine the output is:

(hd0) (hd1) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) (hd2) ... (hd3) ...

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 drive hd2, second partition gpt2):

menuentry "GParted Live ISO" {
  set GPartedISOFile="/opt/Live-ISOs/gparted-live-0.31.0-1-amd64.iso"
  loopback loop (hd2,gpt2)$GPartedISOFile
}

Another difference is that the linux and initrd on BIOS machines are called linuxefi and linuxefi on UEFI machines, which gives us our final result:

#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.

menuentry "GParted Live ISO" {
  set GPartedISOFile="/opt/Live-ISOs/gparted-live-0.31.0-1-amd64.iso"
  loopback loop (hd2,gpt2)$GPartedISOFile
  linuxefi (loop)/live/vmlinuz boot=live components config findiso=$GPartedISOFile ip=frommedia toram=filesystem.squashfs union=overlay username=user
  initrdefi (loop)/live/initrd.img
}

So now save that file, and update grub with:

update-grub

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 )

menuentry "CloneZilla ISO (Works)" {
  set ISOFile="/opt/Live-ISOs/clonezilla-live-20170905-zesty-amd64.iso"
  loopback loop (hd2,gpt2)$ISOFile
  linuxefi (loop)/live/vmlinuz boot=live components config findiso=$ISOFile ip=frommedia toram=filesystem.squashfs union=overlay
  initrdefi (loop)/live/initrd.img
}
  • Did you set up Clonezilla yet? It's a bit different, I can post that if you haven't figured that one out yet. – Organic Marble Apr 17 '18 at 0:45
  • 1
    I'm going to post another answer for all of the ones I'll be adding tomorrow for the "gimme the codez" kind of people... @OrganicMarble – Fabby Apr 17 '18 at 0:50
  • +1 but its probably safe to drop the 2 from update-grub2 these days. – WinEunuuchs2Unix Apr 18 '18 at 11:41
  • @WinEunuuchs2Unix It's in my history... I just type upd↑ and then copy-paste. Thanks for the reminder Updated! – Fabby Apr 18 '18 at 16:50
6

An alternative is to just add a configfile to 40_custom like this:

menuentry 'Live ISOs on SSD' {
configfile (hd0,3)/ISO/livecdimage.cfg
} 

menuentry 'Live ISOs on HDD (boot on SSD)' {
configfile (hd1,3)/ISO/livecdimage.cfg
} 

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

sudo umount -l -r -f /isodevice

And this is part of my livecdimage.cfg file

# livecdimage.cfg
# Add this to 40_custom to load this file:
# menuentry 'Live ISOs' {
# configfile (hd1,3)/iso/livecdimage.cfg
#} 
# Add iso names to livecdimage.cfg
#for i in `ls *.iso`;do echo "# "$i>>livecdimage.cfg; done;

menuentry "Ubuntu 16.04.4 xenial amd64" {
    set isofile="/ISO/ubuntu-16.04.4-desktop-amd64.iso"
    loopback loop (hd0,3)$isofile 
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile toram
    initrd (loop)/casper/initrd.lz
}

menuentry "Ubuntu 18.04 Bionic amd64" {
    set isofile="/ISO/bionic-desktop-amd64.iso"
    loopback loop (hd0,3)$isofile 
    linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile toram
    initrd (loop)/casper/initrd.lz
}

# spacer line
menuentry " " {
set root= 
}

menuentry "Reboot" {
    reboot
}

menuentry "Halt" {
    halt
}
  • I like the Reboot and halt ones! :-) +1 Why do you add the insmod? You can also ping me in chat – Fabby Apr 17 '18 at 11:15
  • inmod probably not needed. With grub2 some features were built in and some were addin( the insmod). Probably in beginning I needed the insmod gpt as I started using gpt in 2010 or before pc were UEFI and grub2 was new & just for BIOS/MBR although would boot from gpt with BIOS. – oldfred Apr 17 '18 at 14:08
  • Thank you for the answer. Wouldn't it be better to remove those lines from the answer then? – Fabby Apr 17 '18 at 14:14
  • 1
    Let me edit my own stanza and see if 18.04 boots. I expect it will. I also wanted to update my gparted ISO boot entry which is now very old, so will be back in a bit. – oldfred Apr 17 '18 at 14:17
  • 1
    Booted ok. I forgot I had my 18.04 flash drive plugged in and it becomes hd0 on my system, so when booting I have to manually edit entry up one hdX to have correct drive. My gparted .25 boot did not work by just changing to .30. I had to look into ISO and see its grub.cfg and use those parameters & grub's loop commands, and then it worked. – oldfred Apr 17 '18 at 15:01
5

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.

mkusb defaults

Use mkusb defaults when creating the Persistent USB drive.

mkusb use defaults again

Use mkusb persistence defaults if in doubt, partition size can be adjusted later but takes time.

DUS Console

The DUS Console after install.

GParted Before

GParted before partition modification.

Gparted after

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

Persistence partition - Create an uniquely name folder for each OS, (that requires persistence)

Persistence folder

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.

ISO folder

Create a folder for the ISO files on the NTFS usbdata partition.

ISO folder contents

Add some ISO's to the ISO folder.

GRUB location

grub.cfg location

grub.cfg

Edit grub.cfg to loopmount the ISO files. Include: persistent persistent-path=/<persistent-folder-name>/ if you want persistence.

sudo parted -ls  /dev/sdb

sudo parted -ls /dev/sdb

sudo lsblk -f  /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),

mkusb Windows Installer

After installation create a folder for ISO's and if required, folders for persistence, (similar to above procedure).

mkusb Windows grub

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.

  • And how do you get these back on the HDD/SDD??? The question is about now wanting them on a USB stick, or did I miss something? – Fabby Apr 17 '18 at 16:12
  • 1
    @Fabby, This is not only for USB sticks. If you have a new SATA drive, you can start as described in this answer and let mkusb install its robust boot system, that works in both UEFI and BIOS mode. This SATA drive can be installed internally or connected externally via USB or eSATA. It is possible to add both 'conventionally installed systems' and new iso files to be booted via 'grub-n-iso'. – sudodus Apr 17 '18 at 17:41
  • OK, I still don't get it: I want these ISOs in /opt/. How do I do that? (+1 in the meantime for effort though...) – Fabby Apr 18 '18 at 17:32
  • 1
    @Fabby: I think Instead of making a new folder for the ISO's as shown above, point to the ISO's location in /opt/, in grub.cfg, grub on a pendrive can boot an ISO on the hard drive. I will give this a try. – C.S.Cameron Apr 19 '18 at 1:49
  • @Fabby: If the ISO's are on /opt/ of the internal drive the same menu entry that you are using on the internal drive will work on the external drive. There may be advantages to booting grub on a USB stick, such as not over crowding or corrupting the internal grub menu. – C.S.Cameron Apr 19 '18 at 21:21
3

Three easy steps

to add ISO to the grub menu and boot from it.

First, install grml-rescueboot

Open a terminal and enter:

sudo apt install grml-rescueboot

Second, move the iso files to /boot/grml/

In the same terminal enter:

sudo mv ~/Downloads/<filename.iso> /boot/grml/

Third, update grub

In the same terminal enter:

sudo update-grub

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

Hope this helps

  • /boot is the worst place to put them. Sorry, looked into grml, should have mentioned it. +1 for effort though – Fabby Apr 18 '18 at 17:30
  • Thanks @Fabby for the +1! This may not be the best way to do it, but this seems to be the easiest, IMHO. – user68186 Apr 18 '18 at 17:36
  • 1
    That's why +1: good answer for non-technical users. – Fabby Apr 18 '18 at 17:42
2

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.

MultiBootUSB-QEMU

  • Nifty! I'm going to try this out later! – Fabby Apr 19 '18 at 7:04
  • @Fabby: There is a Windows version of MBUSB and a Linux version. I could not get the Windows version to boot ISO's, only USB's. The Linux version 9.2.0 works great for me. – C.S.Cameron Apr 19 '18 at 15:19
1

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:

menuentry "Ubuntu-18.04 64-bit ISO" {
    set root=(hd0,1)
    set isofile="/ISOs/ubuntu-18.04-desktop-amd64.iso"
        loopback loop $isofile
        linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile splash --
        initrd (loop)/casper/initrd.lz
}

menuentry "GParted 64-bit ISO" {
    set root=(hd0,1)
    set isofile="/ISOs/gparted-live-0.31.0-1-amd64.iso"
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live union=overlay username=user config components noswap noeject toram=filesystem.squashfs ip='' nosplash findiso=$isofile splash --
    initrd (loop)/live/initrd.img
}

menuentry "Clonezilla 64-bit ISO" {
    set root=(hd0,1)
    set isofile="/ISOs/clonezilla-live-2.5.5-38-amd64.iso"
    loopback loop $isofile
    linux (loop)/live/vmlinuz boot=live live-config nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\"   ocs_live_keymap=\"\" ocs_live_batch=\"no\" ocs_lang=\"\" vga=788   ip=frommedia nosplash toram=filesystem.squashfs findiso=$isofile splash --
    initrd (loop)/live/initrd.img
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.