How to boot from an .iso file in GRUB2? [duplicate]
Is there a way for doing this?
It may be much easier than the impression you get from all the detailed explanations on the web. I just did the following on Ubuntu 12.04 to boot FreeDOS .iso for a firmware update
- Install grub-imageboot
- copy your .iso file(s) to /boot/images/
- run update-grub2
Or copy/paste these:
sudo -s
apt-get install grub-imageboot
mkdir /boot/images/
cp $YOUR_ISO_FILE.iso /boot/images/
update-grub2
That's it.
Sometimes, you may need 2 more steps to do before running update-grub2:
If you never did it before, you need to edit /etc/default/grub so that you see the grub menu on boot:
## To show the menu, disable the hidden_timeout, and set a timeout
#GRUB_HIDDEN_TIMEOUT=0
GRUB_TIMEOUT=10
For some .iso images, you may need to add this option in /etc/default/grub-imageboot : (I needed it for my FreeDOS .iso)
ISOOPTS="iso raw"
If you did edit one of these config. files, you need to run update-grub2
again.
Update: Here is the resulting menuentry asked by "dma_k"
menuentry "Bootable ISO Image: SV100S2_64_128_120229" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos6)'
search --no-floppy --fs-uuid --set=root 6ca082d0-63d0-48c3-9e5f-2ce5d7a74fe4
linux16 /boot/memdisk iso raw
initrd16 /boot/images/SV100S2_64_128_120229.iso
}
This was for a FreeDOS image with some firmware update or such.
I'm assuming you want to add a .iso entry to the GRUB menu and boot it ?
I found this info on Ubuntu Forums
I came across here because I got tired of burning countless bootable ISO 9660 images and thus wanted to use GRUB 2 to bootstrap a FreeDOS one for updating the firmware/microcode of Seagate HDDs. As a complement or alternative to mivk's answer (using memdisk
of syslinux), the following was what I had done to leverage the power of GRUB 2:
- Install the syslinux-common package (for using
memdisk
within it; grub-imageboot is a non-essential hooking package) - Press the 'c' key (mnemonic for command) to activate the command prompt of GRUB 2's builtin mini-shell (or, more precisely, the minimal BASH-like shell)
- Issue the 3 lines of commands in the GRUB 2's mini-shell:
linux16 (hd0,gpt2)/usr/lib/syslinux/memdisk iso raw
initrd16 (hd0,gpt3)/myUserAccount/download/Barracuda-ALL-GRCC4H.iso
boot
# where Barracuda-ALL-GRCC4H.iso is a FreeDOS-based ISO 9660 image, and
# the mathematical 2-tuples or ordered pairs, (hd0,gpt2) and (hd0,gpt3),
# are GRUB 2's respective device notations for my rootfs partition
# (e.g., /dev/sda2) and home partition (e.g., /dev/sda3).
# NOTE: This procedure also applies to Seagate's SeaTools (based on
# FreeDOS as well); just substitute the file SeaToolsDOS223ALL.iso
# for Barracuda-ALL-GRCC4H.iso.
Information on memdisk
of syslinux is at http://www.syslinux.org/wiki/index.php/MEMDISK
By manipulating commands directly in the mini-shell, this procedure is more flexible and smipler than most of the aforesaid methods since you do not have to bother to tweak and update those GRUB 2's configurations every time you wanna try a different Linux distro or a BSD-based live CD.
Currently, it is these 4 lines of commands that one can use as a generic pattern in the GRUB 2's mini-shell, i.e., the loopback-linux-initrd-boot sequence plus some argument(s) passed to the given kernel, for example, to bootstrap as many popular Linux ISO images as possible (in this case is with 3 kernel commandline arguments for System Rescue CD):
loopback lb (hd0,gpt3)/myUserAccount/download/systemrescuecd-x86-3.7.0.iso
linux (lb)/isolinux/rescue64 isoloop=systemrescuecd-x86-3.7.0.iso setkmap=us docache
initrd (lb)/isolinux/initram.igz
boot
N.B. The loopback
part of the generic pattern is not, strictly speaking, mandatory for Linux, when you intend to install a Linux distro such as a Debian derivative without wasting an optical disc.
http://ansi.interblc.com/2010/02/06/howto-boot-iso-images-via-grub2-with-ubuntu/
- Change to the
/etc/grub.d
dir.- Add your ISO images starting with
50
here. For example my entry for the normal Ubuntu ISO image (50_ubuntu) looks like this:
echo "Adding $(egrep menu[e]ntry $0 | cut -d'"' -f2)" >&2
cat << EOF
menuentry "Ubuntu 10.04 Daily Build" {
loopback loop (hd0,3)/ansi/software_and_config/ISOs/ubuntu/lucid-desktop-i386.iso linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ansi/software_and_config/ISOs/ubuntu/lucid-desktop-i386.iso file=(loop)/preseed/ubuntu.seed quiet splash bootkbd=sg -- initrd (loop)/casper/initrd.lz
}My ISO files are stored on sda3 under /ansi/software_and_config/ISOs/ubuntu/. In order to change it for your needs there are 3 elements to change. The loopback line contains your hard disk in grub style (hdx,y x=0->sda x=1->sdb aso) and the path. The third element to change is in the linux line. Store this file as “50_ubuntu” in “/etc/grub.d“, make it executable with “chmod a+x 50_ubuntu” and activate the changes with “ubdate-grub“. After a reboot you should be able to activate the grub menu with the shift-key and select the new entry.
(Note: if someone can use the proper [CODE] formatting, that'd be great. I can't seem to get it to work properly. --tyblu)