Start an ISO image with GRUB
If you want to use multiple Linux distributions, you have no choice. You can either install it on your physical machine or virtual machine, or start the ISO file in live mode. The second option is less demanding on hard disk space, but it is a little troublesome because you need to write the ISO file to a USB flash drive or CD/DVD to start it. However, there is another alternative compromise: Put the ISO image on the hard disk and start it in live mode. This solution saves more space than full installation and provides complete functions, which is a good alternative for slow virtual machines. Next I will introduce how to use the popular Grub boot loader to implement this solution.
Obviously, you will need to use Grub, which is used in almost all modern Linux distributions. You also need to download the Linux ISO file to the local disk. Finally, you need to know where the boot partition is and how to describe it in Grub. For this purpose, use the following command:
- # Fdisk-l
Start the partition. For me, it is/dev/sda1, which is described in Grub language (hd0, 1 ).
For reference, sda2 is (hd0, 2), sdb1 is (hd1, 1), and so on. (You understand .)
What do we need to edit?
First, open/etc/default/grub and check the following lines:
- # GRUB_HIDDEN_TIMEOUT = 0
'#' Must be added before this line for comment.
Save and open/etc/grub. d/40_custom.
In this file, you will add the parameter to start to ISO. The structure is as follows:
- Menuentry "[Entry's title in the grub screen]" {
- Set isofile = "[path to ISO file]"
- Loopback loop [boot partition inGrub language] $ isofile
- [Some specific] arguments
- }
For example, if you want to start Ubuntu from the ISO file, you just want to add the following line to the 40_custom file:
- Menuentry "Ubuntu 14.04 (LTS) Live Desktop amd64 "{
- Set isofile = "/boot/ubuntu-14.04-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
- }
If you want to start Gparted:
- Menuentry "GParted Live amd64 "{
- Set isofile = "/boot/gparted-live-0.18.0-2-amd64.iso"
- Loopback loop (hd0, 1) $ isofile
- Loopback loop $ isofile
- Linux (loop)/live/vmlinuz boot = live config union = aufs noswap noprompt ip = frommedia toram = filesystem. squashfs findiso =$ {isofile}
- Initrd (loop)/live/initrd. img
- }
Or even Fedora:
- Menuentry "Fedora 20 Live Desktop x86_64 "{
- Set isofile = "/boot/Fedora-Live-Desktop-x86_64-20-1.iso"
- Loopback loop (hd0, 1) $ isofile
- Loopback loop $ isofile
- Linux (loop)/isolinux/vmlinuz0 root = live: CDLABEL = Fedora-Live-Desktop-x86_64-20-1 rootfstype = auto ro rd. live. image quiet rhgb rd. luks = 0 rd. md = 0 rd. dm = 0 iso-scan/filename =$ {isofile}
- Initrd (loop)/isolinux/initrd0.img
- }
Note: The parameters can be modified according to the release version. Fortunately, you can check it in many places. I like this release, but there are many other releases you can start. At the same time, pay attention to the place where you place the ISO file. If your home directory is encrypted or cannot be accessed, you may prefer to put these files into startup partitions like in the example. However, make sure that there is sufficient space for the start partition.
Finally, do not forget to save the 40_custom file and use the following command to update grub:
- # Sudo update-grub
So that you can see the changes at the next startup.
What to do next?
Want more? Well, modify the parameters for fun. You can start an ISO file and keep it running. For example, if you want to have an option to quickly clear the hard disk, you can use DBAN for some settings. Now, be careful, because this setting will clear your hard disk, and there is no recovery option at startup:
- Menuentry "Darik's Boot and Nuke "{
- Set isofile = "/boot/dban. iso"
- Loopback loop (hd0, 1) $ isofile
- Linux (loop)/dban. bzi nuke = "dwipe" silent
- }
Another option
- Menuentry "Darik's Boot and Nuke "{
- Set isofile = "/boot/dban. iso"
- Loopback loop (hd0, 1) $ isofile
- Linux (loop)/dban. bzi
- }
You can select to clear the drive by displaying the DBAN option. Be careful because it is still very dangerous.
To sum up, there are many things to do for ISO files and Grub: from quick live sessions to one-click destruction, they can satisfy you. Then, you can try to launch some privacy-related releases, such as Tails.
What do you think is the idea of starting an ISO from Grub? Is that what you want to do? Why? Please leave a message below.
How to reinstall or fix Grub2 boot in Ubuntu12.04/12.10
Grub and mbr during Linux boot
Installation and Use of grub
Grub Bootstrap Configuration File Analysis
CentOS 6.4 grub and password
CentOS GRUB boot error cannot enter system solution
This article permanently updates the link address: