18

Is there a way for doing this?

5
  • Can you clarify what exactly you want to do?
    – Takkat
    Feb 5, 2011 at 9:34
  • 1
    Yes, please elaborate on what you mean. This is an interesting topic; booting from an .iso file is potentially very useful.
    – loevborg
    Feb 5, 2011 at 12:10
  • i wanted to add a .iso entry in grub2 menu.
    – Lincity
    Feb 5, 2011 at 13:02
  • ISOBoot:: help.ubuntu.com/community/Grub2/ISOBoot
    – totti
    Sep 10, 2013 at 9:16
  • The same topic is discussed here.
    – dma_k
    May 12, 2014 at 10:16

6 Answers 6

11

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.

6
  • 1
    Not working for me on 12.10 iso=>12.10
    – totti
    Feb 1, 2013 at 11:44
  • @mivk: Could you please also provide the resulting menuentry for the given ISO?
    – dma_k
    May 9, 2014 at 17:30
  • @dma_k: see update above.
    – mivk
    May 10, 2014 at 13:16
  • 1
    Thanks, I see. Have you found any limitations with this approach? I have a feeling that memdisk can only load images say less then 1GB, something more heavy (e.g. Win7 DVD ISO) is causing problems.
    – dma_k
    May 12, 2014 at 10:06
  • Only ever used this for various small firmware updates.
    – mivk
    May 12, 2014 at 18:46
8

I'm assuming you want to add a .iso entry to the GRUB menu and boot it ?

I found this info on Ubuntu Forums

1
  • Problem is (as I found out the hard way today) that it's still impossible to install from a grub-mounted iso because the installer crashes when trying to unmount the iso... *sigh
    – turbo
    Jul 14, 2011 at 20:41
4

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:

  1. Install the syslinux-common package (for using memdisk within it; grub-imageboot is a non-essential hooking package)
  2. 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)
  3. 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.

2

http://ansi.interblc.com/2010/02/06/howto-boot-iso-images-via-grub2-with-ubuntu/

  1. Change to the /etc/grub.d dir.
  2. 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)

3
  • 3
    As is this answer isn't very great. Could you provide more insight about the link, possibly even creating a summary of the steps or the result? Feb 10, 2011 at 3:54
  • In modern versions of GRUB you can just edit /boot/grub/custom.cfg and write menu entries directly there (they're read from 41_custom), which is less hassle. Jun 17, 2011 at 8:01
  • Only works for ubuntu, other lininux with modified names
    – totti
    Feb 18, 2014 at 9:37
0

As Mark Rooney said, you can find a great guide on the Ubuntu Forums.

This will allow you to boot from an ISO file, but only if the ISO supports it. (All recent Ubuntu releases should, as should a number of other distros).

If you plan on installing from the live ISO, you should put the file on a different partition from the one you will be installing to (since you can't write to the partition that you are running off of). Chances are, the installer will complain anyway. What you have to do is manually edit /etc/mtab and remove the entry that corresponds to the partition with the ISO file.

1
  • I don't see how this guide helps to boot non-linux-based ISO images, e.g. ISO images that have no vmlinuz. Ideas?
    – dma_k
    May 9, 2014 at 13:54
-1

To boot from an ISO file on USB disk/stick, probably the most user-friendly way is MultiSystem: http://liveusb.info/dotclear/index.php?pages/install

You just drag-and-drop to have most ISO images included in the boot menu of your LiveUSB disk/stick.

2
  • The question is asking how to use grub2 to boot an image file, not put it on a usb stick.
    – psusi
    May 31, 2013 at 13:47
  • Unless you want to deter (put off) people from answering questions, you might have kindly considered that people might want to "boot from an .iso file in GRUB2" either (1) on a hard disk or (2) (probably more often) on a USB disk/stick, and I think my answer offers a good solution to the 2nd scenario although it may not apply to the 1st scenario, and I have made it clear in the answer. But how do you know that this question refers to a hard disk and not a USB disk/stick? In a constructive spirit, you could perhaps say this is a partial answer, and not a negative one ;-)
    – Sadi
    May 31, 2013 at 14:10

Not the answer you're looking for? Browse other questions tagged .