How to Boot ISO Files From GRUB2 Boot Loader
This tutorial will be showing you how to boot ISO files stored on your hard drive with the GRUB2 boot loader. Normally you need to create a live DVD or live USB in order to boot Linux ISO images. You can do it with graphical tools or from the command line. But what if you don’t have an optical disk or USB thumb drive around, or your computer does not support burning ISO images to an optical disk?
GRUB to the rescue
GRUB2 (GRand Unified Bootloader) is the standard boot loader for Linux. It can boot Linux ISO image files stored on the hard drive without a USB or DVD. GRUB Legacy (version 0.x) doesn’t have this feature. Many Linux distributions can be booted directly from an ISO file.
- GRUB2 supports many file systems, including but not limited to
ext4
,HFS+
, andNTFS
, which means you can put your ISO file on any of these file systems. - GRUB2 can read files directly from LVM and RAID devices.
- GRUB2 also has network support. You can load ISO images over the network by using the TFTP protocol.
To use GRUB2 to boot ISO files, you need a Linux distro with GRUB2 as the boot loader already installed on your computer. The following instructions work on both the traditional BIOS and the newer UEFI firmware. However, if you use UEFI, then you should disable secure boot in the firmware for GRUB2 to boot ISO files, otherwise, you might see the “can not find command loopback” error.
Now let’s get started.
Boot Ubuntu ISO Files From GRUB2
Log in to a computer running Linux and download an Ubuntu ISO image file. Then open up a terminal window and edit the /etc/grub.d/40_custom
file with a command-line text editor like Nano.
sudo nano /etc/grub.d/40_custom
The first line of this file is #! /bin/sh
indicating it’s a shell script. In this file, we can add custom entries to the GRUB boot menu.
Copy and paste the following text at the end of this file.
menuentry "ubuntu-20.04.2.0-desktop-amd64.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/ubuntu-20.04.2.0-desktop-amd64.iso" loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash initrd (loop)/casper/initrd }
Where:
- menuentry: This entry will be displayed on the GRUB2 boot menu. You can name it whatever you like.
- The insmod command inserts a module. Since the ISO file is stored under my
ext4
home dierctory, theext2
module is needed. If it’s stored on an NTFS partition, then you needinsmod ntfs
instead. Note that GRUB may not be able to recognize XFS and Btrfs file system, so it’s not recommended to store the ISO file on a XFS or Btrfs partition. - set isofile: Specify that path of your ISO image file. Here I’m using Ubuntu 20.04 Desktop ISO file saved under the
Downloads
folder. - loopback: Mount the ISO file.
hd0
means the first hard drive in the computer and5
means the ISO file is stored on the 5th disk partition. - The
linux
command loads a Linux kernel from the specified path. casper/vmlinuz.efi is the linux kernel inside the Ubuntu ISO image. - The
initrd
command loads an initial ramdisk from the specified path. It can only be used after thelinux
command has been run. The initial ramdisk is a minimal root file system mounted to the RAM. casper/initrd.lz is the initrd file inside the Ubuntu ISO image.
Note that GRUB does not distinguish IDE from SCSI. In Linux kernel:
/dev/hda
refers to the first IDE hard drive and/dev/sda
refers to the first SCSI or SATA hard drive./dev/nvme0n1
refers to the first NVMe SSD./dev/nvme1n1
refers to the second NVMe SSD.
But in GRUB, the first hard drive is always referred to as hd0
, no matter what the interface type is. Also note that partition numbers in GRUB start at 1, not 0.
If the ISO file is stored on an extended partition of MBR disk, the partition number starts from 5, instead of 1. For example, the first logical partition inside an extended partition will be numbered as 5; the second logical partition inside an extended partition will be numbered as 6. To check your partition number, you can run lsblk
or sudo parted -l
command in the terminal window.
Save and close the file. (Press Ctrl+O
, then press Enter
to save a file in Nano text editor. Press Ctrl+X
to exit.)
Then update GRUB boot menu with the following command:
sudo grub-mkconfig -o /boot/grub/grub.cfg
On Fedora, CentOS, RHEL, OpenSUSE, the command to run is:
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
On Debian, Ubuntu, Linux Mint, you can use the following command to update GRUB boot menu.
sudo update-grub
You might not see the new menu entry right away, but you will see it when you reboot your computer.
sudo shutdown -r now
You will see your custom entry at the bottom of the GRUB2 boot menu. If GRUB couldn’t boot your ISO image, please check /etc/grub.d/40_custom
file to see if there is a typo or you left out a space or something like that.
You can add as many menu entries as you like in the /etc/grub.d/40_custom
file.
Debian ISO
Download the Debian live CD ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot a Debian ISO file.
menuentry "debian-live-10.8.0-amd64-lxqt.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/debian-live-10.8.0-amd64-lxqt.iso" loopback loop (hd0,5)$isofile linux (loop)/live/vmlinuz-4.19.0-14-amd64 boot=live findiso=$isofile initrd (loop)/live/initrd.img-4.19.0-14-amd64 }
Note that the vmlinuz
and initrd.img
file include version number. You should mount your Debian ISO file and check if you should update it. Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Arch Linux ISO
Download the Arch Linux ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot a Arch Linux ISO file.
menuentry "archlinux-2021.03.01-x86_64.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/archlinux-2021.03.01-x86_64.iso" loopback loop (hd0,5)$isofile linux (loop)/arch/boot/x86_64/vmlinuz-linux archisolabel=ARCH_202103 img_dev=/dev/sda5 img_loop=$isofile earlymodules=loop initrd (loop)/arch/boot/x86_64/initramfs-linux.img }
Note that if you download a newer Arch Linux ISO file such as archlinux-2021.04.01-x86_64.iso
, then you need to update the archisolabel
to ARCH_202104
. You can also find out what the label should be by mounting the Arch Linux ISO in your file manager. The label will be shown in your file manager.
Also you might need to change the value of img_dev
. It’s the name of the device where your ISO file is stored.
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Clonezilla Live ISO
Clonezilla is a free open-source and reliable tool for bare metal backup and recovery of disk drives. Download the Clonezilla live ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot Clonezilla Live ISO file.
menuentry "clonezilla-live-20210127-groovy-amd64.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/clonezilla-live-20210127-groovy-amd64.iso" loopback loop (hd0,5)$isofile linux (loop)/live/vmlinuz boot=live findiso=$isofile initrd (loop)/live/initrd.img }
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
RHEL 8/CentOS Stream ISO
First, download the ISO image file. For RHEL 8, please read the following article to learn how to download ISO image file.
CentOS Stream ISO image can be downloaded from its official website.
Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot RHEL 8/CentOS/Fedora ISO file.
menuentry "rhel-8.3-x86_64-boot.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/rhel-8.3-x86_64-boot.iso" loopback loop (hd0,5)$isofile linux (loop)/isolinux/vmlinuz noeject inst.stage2=hd:/dev/sda5:$isofile initrd (loop)/isolinux/initrd.img }
In the above code, /dev/sda5
is the 5th partition of the first disk where the ISO image file is stored. Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Fedora ISO
Fedora ISO image can be downloaded from its official website. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot Fedora ISO file.
menuentry "Fedora-Workstation-Live-x86_64-33-1.2.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/Fedora-Workstation-Live-x86_64-33-1.2.iso" loopback loop (hd0,5)$isofile linux (loop)/isolinux/vmlinuz root=live:CDLABEL=Fedora-WS-Live-33-1-2 rd.live.image verbose iso-scan/filename=$isofile initrd (loop)/isolinux/initrd.img }
In the above code, CDLABEL
is the the label displayed in your file manager when the ISO image is mounted.
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
OpenSUSE Leap Live ISO
Download the OpenSUSE Leap live ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot OpenSUSE Leap Live ISO file.
menuentry "openSUSE-Leap-15.2-KDE-Live-x86_64-Build31.383-Media.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/openSUSE-Leap-15.2-KDE-Live-x86_64-Build31.383-Media.iso" loopback loop (hd0,5)$isofile linux (loop)/boot/x86_64/loader/linux boot=isolinux root=live:CDLABEL=openSUSE_Leap_15.2_KDE_Live rd.live.image verbose iso-scan/filename=$isofile initrd (loop)/boot/x86_64/loader/initrd }
In the above code, CDLABEL
is the the label displayed in your file manager when the ISO image is mounted.
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Kali Linux Live ISO
Download the Kali Linux live ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot a Kali Linux Live ISO file.
menuentry "kali-linux-2021.1-live-amd64.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/kali-linux-2021.1-live-amd64.iso" loopback loop (hd0,5)$isofile linux (loop)/live/vmlinuz boot=live findiso=$isofile initrd (loop)/live/initrd.img }
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Linux Mint Live ISO
Download the Linux Mint ISO file. Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot a Linux Mint ISO file.
menuentry "linuxmint-20.1-cinnamon-64bit.iso" { insmod ext2 set isofile="/home/linuxbabe/Downloads/linuxmint-20.1-cinnamon-64bit.iso" loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile quiet noeject noprompt splash initrd (loop)/casper/initrd.lz }
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Finding Out the Linux kernel and initrd File Name
The Linux kernel and initrd (initial ramdisk) file can be different for different Linux ISO images. For Ubuntu, the Linux kernel is located at /casper/vmlinuz
and the initrd image file is located at /casper/initrd
. If you don’t know where they are located, just open your ISO image with archive manager. The following screenshot shows the Arch Linux ISO image file.
Display GRUB Boot Menu
Some Linux distributions like Ubuntu hide the GRUB boot menu if there’s only one OS installed on the hard drive. To show the GRUB boot menu, edit a configuration file.
sudo nano /etc/default/grub
Find the following line, which tells GRUB to hide the boot menu.
GRUB_TIMEOUT_STYLE=hidden
Add the #
character at the beginning to comment out this line.
#GRUB_TIMEOUT_STYLE=hidden
Then find the following line.
GRUB_TIMEOUT=0
Change 0
to 10
, so you will have 10 seconds to choose an entry in the GRUB boot menu.
GRUB_TIMEOUT=10
Save and close the file. Then update GRUB configurations.
sudo update-grub
Change the Boot Order in GRUB
Let’s say you want to boot into the ISO by default in GRUB, then edit the configuration file.
sudo nano /etc/default/grub
Find the following line, which makes GRUB select the first entry in the boot menu.
GRUB_DEFAULT=0
Change it to something like this:
GRUB_DEFAULT="clonezilla-live-20210127-groovy-amd64.iso"
If the /etc/grub.d/40_custom
file has this entry menuentry "clonezilla-live-20210127-groovy-amd64.iso"
, then GRUB will select this entry by default. Update GRUB for the changes to take effect.
sudo update-grub
You can also keep the default boot order, but boot an ISO file for the next boot only with:
sudo grub-reboot clonezilla-live-20210127-groovy-amd64.iso
or
sudo grub2-reboot clonezilla-live-20210127-groovy-amd64.iso
Then reboot.
sudo shutdown -r now
Additional Tips
If you have a SATA disk and an NVMe SSD inside your computer, the SATA disk is the first and the NVMe SSD is the second. The same goes for a USB drive and an NVMe SSD. If you have an optical disk, then GRUB might think the optical disk is the first disk.
If you see the following error when GRUB trying to boot an ISO image file, it likely that you have specified the ISO file location to an optical disk.
can not get C/H/S value
If you have a file system that spans the entire disk, then you don’t need to specify the partition number in GRUB. For example, I have an ISO file on my second disk. I didn’t make any partitions on the second disk, so I can specify (hd1)
in GRUB configuration file.
loopback loop (hd1)$isofile
If you see an error message like below when updating the GRUB boot menu, you can ignore this error.
grub-probe: error: cannot find a GRUB drive for /dev/loop11p3. Check your device.map.
Windows 10 ISO
Yes, you can create a Windows 10 bootable USB on Ubuntu or any Linux distro. If you don’t have a USB thumb drive, you can boot Windows 10 ISO on the hard drive with GRUB2. Download the Windows 10 ISO file. Note that you might not be able to download the ISO from this link on a Windows computer. This download link is visible to users on Linux computer.
GRUB2 can not boot Windows 10 ISO directly. You need to create a separate NTFS partition on your disk with a partition editor like GParted and extract the Windows 10 ISO to that partition. The latest Windows 10 ISO file is 5.8G. The new NTFS partition should be at least 7G and it should not be used to store any other files.
Then find your Windows 10 ISO in file manager. Open it with disk image mounter.
Open the mounted file system. Select all files and folders and copy them to the NTFS partition.
Sometimes the file manager on Ubuntu hangs and it seems that the copy operation has stopped. Actually, it’s working. Just be patient. When you see a checkmark, it means the copy operation has finished.
Next, open up a terminal window and edit the /etc/grub.d/40_custom
file with a text editor such as Nano.
sudo nano /etc/grub.d/40_custom
In this file, we can add custom entries to the GRUB boot menu. In this case, we want to add an entry to boot the Windows 10 installer. If your computer still uses the traditional BIOS firmware, then add the following text in this file.
menuentry "Windows-10-Installer.iso" { set root=(hd0,6) insmod part_msdos insmod ntfs insmod ntldr #uncomment the following line if your computer has multiple hard drives. #drivemap -s (hd0) ${root} ntldr /bootmgr }
My NTFS partition number is 6, so I use (hd0,6)
as the root. You can run sudo parted -l
command to check your NTFS partition number. If your computer has multiple hard drives, use the drivemap
command to set the partition (hd0,6)
as the first hard disk, so Windows will be able to boot.
If your computer uses UEFI firmware, then add the following text in this file.
menuentry "Windows-10-Installer.iso" { set root=(hd0,6) insmod part_gpt insmod ntfs insmod chain chainloader /efi/boot/bootx64.efi }
Save and close the file. Then update GRUB boot menu.
sudo grub-mkconfig -o /boot/grub/grub.cfg
or
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
Unplug all your external USB storage devices, then reboot your computer. Note that the Windows desktop ISO installer doesn’t work properly on Proxmox KVM virtual machines.
Wrapping Up
I hop this tutorial helped you boot ISO files with GRUB2 boot loader. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂
The path and filename must not contain spaces or else iso-scan/filename= does not work.
I have never found a way to use ‘escapes’ around the filename to make it work and I don’t think it is possible.
So the whole path must not contain any spaces.
Thumbs up
Very useful. Thank you.
Hello
Why not include FreeBSD boot ISO case ??
Warm Greetings
Hello,
I can boot multiple iso images by this way and I can obtain persistence for 1 ISO by adding “persistent” in the linux (loop) line and having a EXT4 partition named “writable”
I wasn’t able to obtain multipersistence by “persistent-path=/FOLDER/
I followed many posts (persistence files, folders, on FAT32 partition or EXT4 partition, etc)
Do you have any suggestion?
best regards,
Paolo
How would you do this with grub installed as the bootloader for a USB flash drive? How would I determine what (hd?,1) I should use?
I figured it out: Just leave off the (hd?,1) part and you are good to go!
thank you for a such elaborate and practical guide.
thumbs up!
I try to boot Windows 10 as you do, but when I enter the Windows-10-Installer.iso entry, GRUB says unknown filesystem, then I edit the (hd0,x), change x from 1 to 10 , still says unknown filesystem, all my NTFS partition can be accessed by PE or mounted by openSUSE. So I guess “insmod ntfs” has problem, how to check the ntfs module right or wrong?
Hello,
Does anyone figure it how to boot a openSUSE Tumbleweed edition ?
It seems that the parameters are not the same as for Leap version.
Looking forward for your opinion.
//swimm3r
HOW TO DOWNLOAD JUST ANY ISO IMAGE? FOR EXAMPLE MEMTEST?!! THERE IS NO LINUX IMAGE!
Thanks for this detailed guide. Have successfully booted many isos using this method. But i’m having trouble with Nobara 37. Could you take a look at it. Thanks in advance.
Thanks for this great information. I had success with this today for two live CD.
menuentry “ubuntu-22.04.3-desktop-amd64.iso” {
insmod ext2
set isofile=”/home/lex/share/isos/ubuntu-22.04.3-desktop-amd64.iso”
rmmod tpm
loopback loop (hd0,5)$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
initrd (loop)/casper/initrd
}
menuentry “PeppermintOS-Debian-64.iso” {
insmod ext2
set isofile=”/home/lex/share/isos/PeppermintOS-Debian-64.iso”
loopback loop (hd0,5)$isofile
linux (loop)/live/vmlinuz-6.1.0-10-amd64 boot=live findiso=$isofile
initrd (loop)/live/initrd.img-6.1.0-10-amd64
}
Thanks for the article! I now use Ventoy to boot multiple ISOs, but it’s good to know how it can be done manually
Hello… I have set up clonezilla to backup my Proxmoxserver host to a Synology NAS.
I have done the following steps:
1. I made a copy of /boot/grub/grub.cfg.
2. sed -i ‘s/save_env/#save_env/g’ /boot/grub/grub.cfg
3. then I saved the Clonezilla.iso in the directory /boot
wget https://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative/20231102-mantic/clonezilla-live-20231102-mantic-amd64.iso
4. executed apt update and apt upgrade and for ssh apt install whois.
5. created a file in /etc/grub.d/ with the name 30_clonezilla and executable with chmod +x.
The file contains the following entry:
#!/bin/sh
exec tail -n +3 $0
menuentry “Clonezilla UB Mantic” {
insmod lvm
set isofile=”/boot/clonezilla-live-20231102-mantic-amd64.iso”
loopback loop $isofile
linux (loop)/live/vmlinuz boot=live live-media=/dev/mapper/pve-root config locales=en_DE. UTF-8 keyboard-layouts=en ocs_prerun1=”dhclient -v” boot=live config noswap edd=on nomodeset noprompt nosplash ocs_live_run=”/usr/sbin/ocs-sr -um beginner -q2 -c -batch -j2 -z9p – i 0 -sfsck -scs -senc -p reboot savedisk server_img nvme0n1″ ocs_repository=”smb://michael:[email protected]/PVE-Backup/” ocs_live_batch=no ocs_netlink_timeout=5 toram=filesystem. squashfs findiso=$isofile
initrd (loop)/live/initrd.img
}
Boot the server via ssh with grub-reboot ‘Clonezilla UB Mantic’ && reboot
All tasks are performed correctly and the server is rebooted. But not in Proxmox but in Clonezilla again. And now there is the question. How can I set it and where… so that Proxmox boots again and can I maybe put the boot command in crontab ?