I know that I can create/burn bootable CD/DVD or live USB and can boot/install from it. But suppose I am currently running GNU/Linux and I've ISO file of another GNU/Linux that I want to install on my hard disk, then Can I directly boot from ISO from hard disk and try/install that GNU/Linux operating system?
How to boot from ISO file stored on hard disk
bootableisosystem-installation
Best Answer
Yes, you can accomplish this by adding a menu entry to the
GRUB
boot loader menu.You can add a custom GRUB menu entry by editing
/etc/grub.d/40_custom
,Example of custom menuentry:
Instruction & Explanation:
The command
set
is used for storing the path of the ISO file into a variable, hereisofile
.loopback
is used to make a device from a file system image. In order to do that, it is necessary to specify the device and image file. Here we used(hd0,5)$isofile
in which(hd0,5)
represents the fifth partition of the disk.(hd0,5)
,1st digit represents the device number which starts from
0
(here : 0 = 1st device) and2nd digit represents the partition number which starts from
1
(here 5 = 5th partition).That means
/dev/sda5
$isofile
has the path of the ISO file. So, finally it becomes(hd0,5)/Operating_Systems/Trisquel_7.0_i686/trisquel_7.0_i686.iso
.linux
command is used to load Linux kernel (vmlinuz) from file. Put the path of Linux kernel in the ISO.Read/extract the content of ISO to get the path of kernel example:
so,
/casper/vmlinuz
was used here.initrd
command is used to load an initial ramdisk for a Linux kernel image, and set the appropriate parameters in the Linux setup area in memory.initrd
in the ISO.Read/extract the content of ISO to get the path of
initrd
:The additional parameter such as
boot=casper iso-scan/filename=$isofile noprompt noeject
may be specific to a GNU/Linux distribution and vary for another family of Linux. You can find some configurations for different family/distribution from here.Note: Some distributions use
initrd.gz
orinitrd.lz
depending upon the algorithm/compression used.After editing
/etc/grub.d/40_custom
, GRUB needs to be updated byupdate-grub2
command. Upon rebooting, you will find the custom menuentry you've added on the GRUB screen. And you may use the Live environment of a GNU/Linux distribution.In order to perform installation from ISO, installer may need to unmount any mounted partitions; i.e. say another system is mounted at
/isodevice
, then you canumount -l /isodevice
.