How to run the ISO file directly from the hard disk using GRUB 2

Source: Internet
Author: User

How to run the ISO file directly from the hard disk using GRUB 2

Most Linux distributions provide a live environment that can be started from USB so that users can test the system without installation. We can use it to evaluate this release or simply use it as a one-time system, and it is easy to copy these files to a U disk. In some cases, we may need to run the same or different ISO images frequently. GRUB 2 can be configured to run a live environment directly from the boot menu, without burning these ISO to the hard disk or USB device.

 

Obtain and check the launched ISO Image

To obtain an ISO image, we usually need to visit the website of the required release to download image files compatible with our architecture. If the image can be started from the U disk, it should also be able to be started from the GRUB menu.

After the image is downloaded, we should check its integrity through MD5 verification. This will output a series of numbers and letters.

Compare the sequence with the MD5 Verification Code provided on the download page. The two should be identical.

 

Configure GRUB 2

The ISO image file contains the entire system. All we need to do is to tell GRUB 2 where to find the kernel, initramdisk, or initram File System (depending on the release we are using ).

In the following example, A KUbuntu 15.04 live environment will be configured to the Grub boot menu item of the Ubuntu 14.04 machine. This should be able to run on most new Ubuntu-based systems. If you are using other systems and want to implement other things, you can learn more from these files, but this requires you to have a little GRUB experience.

File in this examplekubuntu-15.04-desktop-amd64.isoPlaced in/dev/sda1Of/home/maketecheasier/TempISOs/.

To make GRUB 2 find it correctly, we should edit

  1. /etc/grub.d40-custom

  1. menuentry "Kubuntu 15.04 ISO"{
  2. set isofile="/home/maketecheasier/TempISOs/kubuntu-15.04-desktop-amd64.iso"
  3. loopback loop (hd0,1)$isofile
  4. echo"Starting $isofile..."
  5. linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
  6. initrd (loop)/casper/initrd.lz
  7. }

 

Analyze the above Code

First, a variable name is set.$menuentryThis is the location of the ISO file. If you want to change the ISO, you should modifyisofile="/path/to/file/name-of-iso-file-.iso".

The next line specifies the loopback device and must provide the correct Partition Number.

  1. loopback loop (hd0,1)$isofile

Note that hd0, 1 is very important here, it means the first hard disk, the first partition (/dev/sda1).

The name of GRUB is a bit confusing here. For a hard disk, it starts counting from "0". The first hard disk is #0, and the second disk is #1, the third part is #2, and so on. However, for a partition, it starts counting from "1". The first partition is #1, and the second partition is #2. So on. There may be a good reason, but it is definitely not wise (obviously the user experience is terrible )..

In Linux, the first hard disk, the first partition is/dev/sda1But in GRUB2 it ishd0,1. The second hard disk, and the third partition ishd1,3, And so on.

The next important line is:

  1. linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash

This will load the kernel image. In the new Ubuntu Live CD, the kernel is stored in/casperDirectory and name itvmlinuz.efi. If you are using another system.efiThe extension or kernel is stored elsewhere (you can use the archive manager to open the ISO file in/casper). The last option,quiet splashIs a general GRUB option. It doesn't matter if it is changed.

Last

  1. initrd (loop)/casper/initrd.lz

This loadinitrdIt is responsible for loading RAMDisk to memory for startup.

 

Start the live System

After completing all the above steps, you need to update GRUB2:

  1. sudo update-grub

After the system is restarted, you can see a new GRUB entry that allows us to start the newly configured ISO image:

Selecting this new entry allows us to start a live environment from a DVD or USB disk.

Via: https://www.maketecheasier.com/run-iso-files-hdd-grub2/

Author: Attila Orosz Translator: Locez Proofreader: wxy

This article was originally compiled by LCTT and launched with the honor of Linux in China

This article permanently updates the link address:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.