Boot Linux ISO from Hard Drive - A Comprehensive Guide

Booting Linux ISOs Directly with GRUB2
The GRUB2 boot loader, standard on many Linux systems, offers the capability to initiate the boot process from Linux ISO files stored directly on your hard drive.
This functionality allows users to run live Linux environments, such as live CDs, or even perform installations onto separate hard drive partitions.
The need for traditional boot media like optical discs or USB drives is therefore bypassed, streamlining the process.
Testing and Compatibility
This procedure was successfully tested using Ubuntu 14.04.
Ubuntu and other Linux distributions derived from Ubuntu generally exhibit strong compatibility with this method.
While tested on a specific distribution, the underlying principles should apply to a wide range of other Linux systems with minimal variation.
Benefits of Direct ISO Booting
- Eliminates the requirement for physical media.
- Provides a convenient method for testing Linux distributions.
- Facilitates installations without needing a USB drive or CD/DVD burner.
By leveraging GRUB2, users gain a more flexible and efficient approach to managing and utilizing Linux ISO images.
Accessing a Linux ISO File
Related: Configuring GRUB2 Boot Loader Settings
This process necessitates a pre-existing Linux installation on your computer’s hard drive. The GRUB2 boot loader, standard on the majority of Linux distributions, is also a requirement. Unfortunately, directly booting a Linux ISO from a Windows environment utilizing the Windows boot loader is not possible.
Obtain the desired ISO files and save them to your Linux partition. GRUB2 generally offers compatibility with a wide range of Linux systems.
Utilizing Live Environments
If your intention is to operate a Linux system within a live environment – without permanent installation to the hard drive – ensure you download the “live CD” versions of the respective Linux ISOs.
A variety of Linux-based bootable utility discs are also expected to function correctly.
Many such utilities can be leveraged for system maintenance or recovery tasks.
- Ensure the ISO file is accessible from your Linux file system.
- Verify GRUB2 is your active boot loader.
- Download the "live CD" version for a non-install experience.
These steps will allow you to effectively utilize Linux ISO files within a GRUB2 environment.
Examining the Contents of an ISO File
Determining the precise location of files within an ISO image may be necessary. This can be achieved by opening the ISO file using a graphical archive manager, such as Archive Manager or File Roller, commonly included with Ubuntu and other GNOME desktop environments.
Within the Nautilus file manager, a simple right-click on the ISO file followed by selecting "Open with Archive Manager" will accomplish this.
Identifying Key Files
The kernel file and the initrd image need to be identified. When working with a standard Ubuntu ISO, these are typically found within the 'casper' directory.
Specifically, 'vmlinuz' represents the Linux kernel itself, while the 'initrd' file constitutes the initial RAM disk image. Their exact path within the ISO will be required for subsequent steps.
Identifying Hard Drive Partition Paths
The method GRUB employs for naming devices differs from that used by Linux. Within a Linux environment, a partition like /dev/sda1 designates the initial partition on the primary hard drive. Here, a represents the first hard drive, and 1 signifies its first partition.
Conversely, GRUB utilizes (hd0,1) to denote the same partition, /dev/sda0. The numeral 0 corresponds to the first hard drive, while 1 indicates the first partition residing on it. Essentially, GRUB’s device naming convention begins counting disks at 0 and partitions at 1, which can be a source of confusion.
As an illustration, (hd3,6) would pinpoint the sixth partition located on the fourth hard disk.
Using fdisk to Determine Partition Paths
The fdisk -l command provides a means of accessing this crucial information. To utilize it on Ubuntu, simply launch a Terminal and execute the following command:
sudo fdisk -l
The output will display a comprehensive listing of Linux device paths. These paths can then be translated into their GRUB equivalents. For instance, if the system partition is identified as /dev/sda1, its GRUB counterpart would be (hd0,1).
Creating a GRUB2 Boot Entry
The most straightforward method for incorporating a custom boot entry involves modifying the /etc/grub.d/40_custom script. This particular file is specifically intended for user-defined, personalized boot entries. Following any edits made to this file, the configurations within your /etc/defaults/grub file and the scripts located in /etc/grub.d/ will be consolidated to generate the /boot/grub/grub.cfg file – direct modification of this file is discouraged, as it’s designed for automatic creation based on your specified settings.
To edit the /etc/grub.d/40_custom file, you will require root-level access. Within Ubuntu, this can be achieved by launching a Terminal window and executing the subsequent command:
sudo gedit /etc/grub.d/40_custom
You are free to utilize your preferred text editor for this task. For instance, substituting "gedit" with "nano" in the command will open the file within the Nano editor.
Typically, if no other custom boot entries have been added, the file will appear largely empty. You will need to append one or more sections designed for booting from ISO images to the file, positioning them below the existing commented lines.

The following example demonstrates how to boot an Ubuntu or Ubuntu-derived distribution directly from an ISO file. This procedure was successfully tested with Ubuntu 14.04:
menuentry "Ubuntu 14.04 ISO" {
set isofile="/home/name/Downloads/ubuntu-14.04.1-desktop-amd64.iso"
loopback loop (hd0,1)$isofile
linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
initrd (loop)/casper/initrd.lz
}
Ensure the boot entry is customized to reflect your desired menu entry title, the accurate location of the ISO file on your system, and the correct device designation for the hard drive partition where the ISO is stored. Should the vmlinuz and initrd files possess differing names or reside in alternative paths, it’s crucial to specify their correct locations as well.
(If your system utilizes a separate /home/ partition, exclude the /home portion of the path, such as: set isofile="/name/Downloads/${isoname}").
Important Consideration: Different Linux distributions necessitate distinct boot entries and varying boot parameters. The GRUB Live ISO Multiboot project provides a collection of menu entries tailored for numerous Linux distributions. These examples can often be adapted to accommodate the specific ISO file you intend to boot. Alternatively, a web search combining the distribution's name, release number, and the phrase "boot from ISO in GRUB" can yield further guidance.

To incorporate additional ISO boot options, simply append further sections to the file.
Once the file is saved, return to a Terminal window and execute the following command:
sudo update-grub

Upon the next system boot, the newly added ISO boot entry will be visible, allowing you to select it to initiate the ISO file's boot process. You might need to hold down the Shift key during startup to display the GRUB menu.
Should you encounter an error message or a blank screen during the ISO boot attempt, it indicates a misconfiguration within the boot entry. Even with correct ISO file paths and device names, inaccuracies in the paths to the vmlinuz and initrd files, or the requirement of different boot options by the Linux system, can cause issues.