Skip to content
Related Articles

Related Articles

Improve Article

How to Boot Linux ISO Image Directly from Hard Drive

  • Last Updated : 17 Jun, 2021

To  Boot Linux ISO Image Directly from Hard Drive, you must have a Linux operating system installed on your hard drive and your computer must be using a GRUB2 bootloader. The GRUB2 bootloader is a standard bootloader on most Linux systems.

Note: The downloaded ISO file of Linux must be a live CD release of each Linux ISO image.

How to Get ISO files from Linux:

1) First of all, search for the ISO file on Google which you want to download. To download these Linux distributions you may visit:

2) Let us take the example of downloading Ubuntu.

  • Visit the official website and navigate to the download tab.
  • Select the Ubuntu desktop for downloading.
  • Select the LTS(Long Term Support) version of Ubuntu for downloading.



  • Your download will start in a few seconds.

Determine the Hard Drive Partition’s Path:

The “device name” scheme used by GRUB is a different scheme than Linux. In your Linux system, /dev/sda1 is the first partition on the first hard disk, where a means the first hard disk and 1 means its first partition. In GRUB, (hd0,1) is equivalent to /dev/sda0 where  0 means the first hard disk and 1 means the first partition on it. That means that in a GRUB device name, the disk numbers start counting at 0 and the partition numbers start counting at 1. For example, (hd2,5) refers to the fifth partition on the third hard disk.

To view the information, we use the fdisk -l command on Ubuntu’s terminal and use the following command:

sudo fdisk -l

A list of Linux device paths is shown, which you can convert to GRUB device names on your own.

Adding Boot Menu To GRUB:

The best way by which you can add a custom boot entry is by editing the /etc/grub.d/40_custom script, which is a file designed for user-added custom boot entries.  After you are done editing the file, every content of your /etc/defaults/grub file and the /etc/grub.d/ scripts will get combined and create a /boot/grub/grub.cfg file.

Note: You shouldn’t edit this file by hand. It’s designed to be automatically generated from the settings you specify in other files.

You’ll need to open the /etc/grub.d/40_custom file for editing with root privileges.  On Ubuntu, you can do this by opening a Terminal window and running the following command:

sudo gedit /etc/grub.d/40_custom

You can open this file in your favorite editor by just replacing gedit with your editor name.



So to boot an Ubuntu or Ubuntu-based distribution from an ISO file. We tested this with Ubuntu 20.04:

menuentry “Ubuntu 20.04 ISO” {

set isofile=”/home/nikhil/ubuntu-20.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

}

Note: 

  • You can customize the boot entry to contain your desired menu entry name, the correct path to the ISO file on your pc, and the device name of the hard disk and partition containing the ISO file. If the vmlinuz and initrd files have different names or paths, be sure to specify the correct path to those files, too.
  • Different Linux distributions require different boot entries with different boot options. The GRUB Live ISO Multiboot project offers a variety of menu entries for different Linux distributions. You should be able to adapt these example menu entries for the ISO file you want to boot or you can also just perform a web search for the name and release number of the Linux distribution you want to boot along with “boot from ISO in GRUB” to find more information.

If you want to add more ISO boot options, add additional sections to the file, otherwise just save the file and return to the terminal window.

Update GRUB:

To update GRUB run the following command:

sudo update-grub 

The next time you boot your computer, you’ll see the ISO boot entry and you can choose to boot the ISO file. You may have to hold Shift while booting to see the GRUB menu.

Note: If you see an error message or a black screen when you attempt to boot the ISO file, you misconfigured the boot entry somewhere. Even if you got the ISO file path and device name right, the paths to the vmlinuz and intird files on the ISO file may not be correct or the Linux system you’re booting may require different options.

My Personal Notes arrow_drop_up
Recommended Articles
Page :