This is a How-to for booting from an ISO file on the hard drive using GRUB2 and without the need to burn the image to a disk.
Summary of Steps : --
- Locate the ISO that you desire to boot from.
- Temporarily mount it to ascertain the boot information it contains.
- Ascertain the GRUB2 notation for the partition that contains this ISO
- Edit the GRUB2 custom menu file with the boot information. { /etc/grub.d/40_custom }
- Configure GRUB2 to include the new special boot information by running update-grub {see man update-grub below}.
- Install GRUB2 to the drive from which you wish to boot by running grub-setup.
Worked Example : --
Locate the ISO that you desire to boot from.
Browse to the directory where you have saved the ISO file, right-click on the ISO and choose 'properties'.
Copy and paste the full path and file name of the ISO into a text document.
I will use this as my example : --
name : ubuntu-12.10-beta1-desktop-amd64.iso
location : /media/ubuntu/ext3/DownloadedISOFiles/Ubuntu
full path :/media/ubuntu/ext3/DownloadedISOFiles/Ubuntu/ubuntu-12.10-beta1-desktop-amd64.iso
Temporarily mount it to ascertain the boot information it contains.
Now temporarily mount this ISO file so that you can inspect its contents and extract the paths and names of the two files needed by GRUB in order to launch the distribution included in the ISO file.
sudo mkdir /mnt/iso
sudo mount -o loop /media/ubuntu/ext3/DownloadedISOFiles/Ubuntu/ubuntu-12.10-beta1-desktop-amd64.iso /mnt/iso
From the mounted ISO I am able to read the full path of the two files required to boot this distro, which are : --
/media/ubuntu/Ubuntu 12.10 amd64/casper/initrd.lz
/media/ubuntu/Ubuntu 12.10 amd64/casper/vmlinuz
Which translates into the following data to be added to the GRUB2 custom menu file
casper/initrd.lz
casper/vmlinuz
Ascertain the GRUB2 notation for the partition that contains this ISO
GRUB2 uses the form 'hd0' to represent the first hard drive, 'hd1' to represent the second hard drive, etc.
GRUB2 uses the form '(hd0,1)' to represent the first partition on the first hard drive. The second partition will be '(hd0,2)', etc.
Note particularly the inconsistent starting points for numbering, '0' for the hard drives, '1' for the partitions.
In this example the ISO is found at /media/ubuntu/ext3/DownloadedISOFiles/Ubuntu/ubuntu-12.10-beta1-desktop-amd64.iso
Using the command 'df -a' I can see that this is the drive /dev/sda5
So the device, in GRUB2 form is '(hd0,5)'
Edit the GRUB2 custom menu file with the boot information. { /etc/grub.d/40_custom }
The form of information required is as follows : --
menuentry ' ' { {Put whatever name for the distribution you like between the quote marks}
isofile= {Put the name of the ISO file that you are going to use immediately after the '=' sign}
loopback loop (hd0,5)/iso/$isofile {Put the drive where the ISO file resides into GRUB2 notation. Here sda5 becomes (hd0,5}
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/$isofile noprompt noeject {This locates the ISO file and finds the first stage file for booting the image}
initrd (loop)/casper/initrd.lz {This finds the second stage file for booting the image which can now fully boot the system }
Mostly the information from line four on will be similar to this example if the distro is based on Ubuntu. Other distributions may use different paths and names for these two files.
Here is the full set of booting data needed to boot Ubuntu 12.10 beta 1 64bit : --
menuentry 'Ubuntu 12.10 beta 1 64bit ' {
isofile=ubuntu-12.10-beta1-desktop-amd64.iso
loopback loop (hd0,5)/iso/$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/$isofile noprompt noeject
initrd (loop)/casper/initrd.lz
}
Save the file and exit gedit text editor.
Configure GRUB2 to include the new special boot information by running update-grub {see man update-grub below}.
We now have to run update-grub, as script which will incorporate the above information from the '/etc/grub.d/40_custom' file and write it to the '/boot/grub/grub.cfg' file.
From the info file for update-grub "update-grub is a stub for running grub-mkconfig -o /boot/grub/grub.cfg"
Install GRUB2 to the drive from which you wish to boot by running grub-setup.
Finally, to incorporate this new GRUB configuration into the MBR and make it the effective boot sequence, run the grub-setup command with the main hard drive as the target.
grub-setup sda { GRUB2 can now use the system notation for hard drives, hda for the first IDE drive, sda for the first SATA drive and fda for the first floppy drive}
grub-setup (hd0) { or its own notation, starting at 0 for the first hard drive}
Reboot the system and choose the option that you have now included in the boot menu.
You should now be booted into the system included in the ISO file you have configured into the GRUB2 boot menu.
Enjoy!
Example of menu entry : --
menuentry 'Ubuntu 12.10 beta 1 64bit ' {
isofile=ubuntu-12.10-beta1-desktop-amd64.iso
loopback loop (hd0,5)/iso/$isofile
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/$isofile noprompt noeject
initrd (loop)/casper/initrd.lz
}
Copy of '/etc/grub.d/40_custom' : --
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
## This file is located at /etc/grub.d/40_custom
# menuentry ' ' {
# isofile=
# loopback loop (hd0,5)/iso/$isofile
# linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/iso/$isofile noprompt noeject
# initrd (loop)/casper/initrd.lz
# }
Copy of 'info update-grub' : --
UPDATE-GRUB(8) UPDATE-GRUB(8)
NAME
update-grub, update-grub2 - stub for grub-mkconfig
SYNOPSIS
update-grub
DESCRIPTION
update-grub is a stub for running grub-mkconfig -o /boot/grub/grub.cfg
to generate a grub2 config file.
SEE ALSO
grub-mkconfig(8)
April 2009 UPDATE-GRUB(8)
Copy of 'info grub-setup' : --
GRUB-SETUP(8) System Administration Utilities GRUB-SETUP(8)
NAME
grub-setup - set up a device to boot using GRUB
SYNOPSIS
grub-setup [OPTION...] DEVICE
DESCRIPTION
Set up images to boot from DEVICE.
You should not normally run this program directly. Use grub-install
instead.
-a, --allow-floppy
Make the drive also bootable as floppy (default for fdX
devices). May break on some BIOSes.
-b, --boot-image=FILE
Use FILE as the boot image [default=boot.img]
-c, --core-image=FILE
Use FILE as the core image [default=core.img]
-d, --directory=DIR
Use GRUB files in the directory DIR [default=/boot/grub]
-f, --force
Install even if problems are detected
-m, --device-map=FILE
Use FILE as the device map [default=/boot/grub/device.map]
-r, --root-device=DEV
Use DEV as the root device [default=guessed]
-s, --skip-fs-probe
Do not probe for filesystems in DEVICE
-v, --verbose
Print verbose messages.
-?, --help
give this help list
--usage
give a short usage message
-V, --version
print program version
Mandatory or optional arguments to long options are also mandatory or
optional for any corresponding short options.
DEVICE must be an OS device (e.g. /dev/sda).
REPORTING BUGS
Report bugs to <bug-grub@gnu.org>.
SEE ALSO
grub-install(8), grub-mkimage(1), grub-mkrescue(1)
The full documentation for grub-setup is maintained as a Texinfo man‐
ual. If the info and grub-setup programs are properly installed at
your site, the command
info grub-setup
should give you access to the complete manual.
grub-setup (GRUB) 1.99-22ubuntu1 May 2012 GRUB-SETUP(8)
Copy of output of 'grub-install --usage'
ubuntu@ubuntu:~$ grub-install --usage
Unrecognized option `--usage'
Usage: grub-install [OPTION] install_device
Install GRUB on your drive.
-h, --help print this message and exit
-v, --version print the version information and exit
--modules=MODULES pre-load specified modules MODULES
--boot-directory=DIR install GRUB images under the directory DIR/grub
instead of the /boot/grub directory
--grub-setup=FILE use FILE as grub-setup
--grub-mkimage=FILE use FILE as grub-mkimage
--grub-mkrelpath=FILE use FILE as grub-mkrelpath
--grub-mkdevicemap=FILE use FILE as grub-mkdevicemap
--grub-probe=FILE use FILE as grub-probe
--no-floppy do not probe any floppy drive
--allow-floppy Make the drive also bootable as floppy
(default for fdX devices). May break on some BIOSes.
--recheck probe a device map even if it already exists
--force install even if problems are detected
--disk-module=MODULE disk module to use
INSTALL_DEVICE can be a GRUB device name or a system device filename.
grub-install copies GRUB images into /boot/grub, and uses grub-setup
to install grub into the boot sector.
Report bugs to <bug-grub@gnu.org>.
ubuntu@ubuntu:~$
Comments (1)
Paul G. Taylor said
at 11:26 pm on Sep 25, 2017
This is a mirrored copy of my Wiki page downloaded this 25th day of September 2017
You don't have permission to comment on this page.