49

How can I boot into an ISO file in GRUB? The ISO file is on a reiserfs partition and GRUB can access it (already tested that).

4

3 Answers 3

62

The biggest problem with booting an ISO file is that ISOs that are designed to be booted are almost always designed to be booted from a CD. As explained on Marco's blog regarding Grub 2 (emphasis mine):

GRUB can read ISO9660 (”iso”) images. It can for example load the first few sectors and boot it. But most people do not realize is “what then?”. What would the loaded operating system do? It will most likely look for a CDROM, which it won’t find, and fail.

So the dead-simple-est way to boot from some random ISO file is to load it into a virtual machine (VirtualBox, VMware, or Virtual PC) as a virtual CD and boot it there. That should almost always work, because to the VM, it's not an ISO file -- it's a real CD on real CD hardware.

Booting from an ISO file on bare metal is much harder. How you do this depends on which version of Grub you're using, and results can differ depending on what ISO you're using and how it was configured to boot. This is why most boot-ISO-from-USB tools (Unetbootin, WinToFlash, etc) usually extract the ISO contents to the drive -- because that way they can be accessed directly, without confusing the OS being booted.


Grub 1

... not sure. If possible, menu entries will probably look a lot like Grub4DOS, though I think the "map --hook" command is a Grub4DOS enhancement. On the plus side, Grub has wider filesystem support than Grub4DOS.

A note on Grub with reiserfs (unconfirmed) indicates you "have to mount your partition with notail for it to work".

Memdisk is an option; see below.


Grub4DOS

Grub4DOS offers some experimental "CD emulation" that works with some ISOs. Unfortunately, Grub4DOS only reads FAT32/NTFS filesystems. Download Grub4DOS.

Here's a sample entry (source):

title fdfullcd.iso (0xFF)
  find --set-root /fdfullcd.iso
  map /fdfullcd.iso (0xFF)
  map --hook
  root (0xFF)
  kernel /isolinux/data/memdisk
  initrd /isolinux/data/fdboot.img

Supposedly the Win7 ISO can be booted with this entry:

title Windows 7
  map (hd0,0)/win7.iso (hd32)
  map --hook
  chainloader (hd32)

Other ISOs can be booted with Memdisk:

title Boot Hardware Detection Tool from iso image (with 'iso' parameter)
  kernel /memdisk iso
  initrd /hdt.iso

You can also use a menu configurator like MultiBootISOs.exe from PenDriveLinux. Place ISOs on the flash drive, and run the utility to install the bootloader and configure the boot menu.

Here's a Hak5 episode on installing Grub4DOS.


Grub 2

Here's a couple of example Grub2 entries. chainloader doesn't work to boot an ISO at present, so these entries must (1) use loopback to "mount" the ISO, and (2) add something like iso-scan or findiso to the linux line that specifies the ISO file.

Unfortunately, there's no generic way to do this. Each different boot entry must be customized to the target ISO's contents. Most Linux LiveCDs use ISOLINUX as a bootloader; find the isolinux.cfg and examine that boot entry to see what it usually boots.

Example entries (source):

menuentry "Ubuntu Live 9.10 32bit" {
 loopback loop /boot/iso/ubuntu-9.10-desktop-i386.iso
 linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/boot/iso/ubuntu-9.10-desktop-i386.iso noeject noprompt --
 initrd (loop)/casper/initrd.lz
}

menuentry "Grml small 2009.10" {
  loopback loop /boot/iso/grml-small_2009.10.iso
  linux (loop)/boot/grmlsmall/linux26 findiso=/boot/iso/grml-small_2009.10.iso apm=power-off lang=us vga=791 boot=live nomce noeject noprompt --
  initrd (loop)/boot/grmlsmall/initrd.gz
}

If you're trying to boot a non-Linux LiveCD, you may be out of luck. Again, Memdisk may help:

menuentry "Boot Hardware Detection Tool from iso" {
  linux16 /memdisk iso
  initrd16 /hdt.iso
}
12
  • @albert: i'm using Grub2 on a flash drive and been frustrated by the same things, so it wasn't hard putting together. i'm looking into your other question, but i've never tried "burning" an ISO onto a partition before, so it may be... interesting. Jun 18, 2010 at 18:54
  • Ofc I can boot it inside VMware (and I also already did) but that doesn't help me much because it is Windows and when I install it via VMware on my disk, it wont boot later on (stupid Windows...).
    – Albert
    Jun 18, 2010 at 19:00
  • Can you give me a suggestion what option I should try first, i.e. Grub1, Grub2 or Grub4DOS? I can just install whatever is needed, that wont really be the problem.
    – Albert
    Jun 18, 2010 at 19:01
  • @albert: are you asking in reference to your earlier question? i believe your best bet is to use the extraction method; the Windows installer is one of those ISOs that have problems when they aren't booted from hardware. you can try memtest, but i don't know much about it. you probably want to get a flash drive and use that; see superuser.com/questions/66948/… or superuser.com/questions/62193/install-win7-from-usb Jun 18, 2010 at 20:06
  • 1
    @quackquixote, Regarding your bolded words "What would the loaded operating system do? It will most likely look for a CDROM, which it won’t find, and fail", Why does the OS need to look for a CDROM? It's already a perfect iso file and the everything that is needed to load the OS is already within the iso file, so why can't it skip looking for CDROMs?
    – Pacerier
    Apr 26, 2015 at 20:42
1

You can use dd from the terminal to write an iso file to a partition. Just be careful, if you use dd wrong you can wipe everything. It should look something like this: dd if=Desktop/LinuxCDFile.iso of=/Path/To/Partition

3
  • 1
    But the partition needs to be Primary in order to be bootable by Windows Loader.
    – Firelord
    Mar 23, 2015 at 17:22
  • 1
    This only works occassionally, generally the result isn't bootable. Aug 15, 2016 at 14:11
  • 2
    @Firelord: Well, don’t use Windows Loader. Use Grub. Yes, it does boot Windows too, if you really need to.
    – anon
    Jan 15, 2018 at 1:39
0

There are beautiful set of examples along with tweaks for many popular OS Grub 2 iso boot

menuentry "Focal Desktop iso" {
   set isofile="/iso/focal-desktop-amd64.iso"
   rmmod tpm // For GPT only
   loopback loop (hd0,5)$isofile
   linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
   initrd (loop)/casper/initrd
}

You must log in to answer this question.

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