Boot iso file on hard drive using grub loopback. Without CD or USB

I am trying to boot an openSUSE live CD iso image file using the loopback in GRUB2. I could burn the iso image to CD, but I don’t want to.

I downloaded KDE live CD iso image for opensuse 13.1, and it’s on my hard drive. I have a desktop with a few Operating Systems on it already, and some unused partitions available for another install. I’m currently running OpenSUSE 12.2 on /dev/sda9 and /dev/sda10. Here is my partition table.

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000212fd

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1              63      112454       56196    6  FAT16
/dev/sda2          112455    20595329    10241437+   7  HPFS/NTFS/exFAT
/dev/sda3        20595330   123009704    51207187+   7  HPFS/NTFS/exFAT
/dev/sda4   *   123009766   976768064   426879149+   5  Extended
/dev/sda5       123009768   225424079    51207156    7  HPFS/NTFS/exFAT
/dev/sda6       225424143   327838454    51207156   83  Linux
/dev/sda7       327838518   635049449   153605466   83  Linux
/dev/sda8       635049513   641202344     3076416   82  Linux swap / Solaris
/dev/sda9       641202408   743616719    51207156   83  Linux
/dev/sda10      743616783   976768064   116575641   83  Linux

The image file is here

adam@desk12two:~> ls openSUSE-13.1-NET-i586.iso 
openSUSE-13.1-NET-i586.iso

I fiddled around in the Grub2 command line for a while and Grub is calling /dev/sda10 (hd0,15). I was able to mount the image in grub using the loopback command. (This is how I remember it, since I don’t know how to copy and paste from GRUB.)

loopback loop (hd0,15)/adam/openSUSE-13.1-NET-i586.iso
ls (loop)/boot/i386

and I am able to view the files in there. Looks just like it does on the terminal below.

adam@desk12two:/> ls /media/loop0/boot/i386/
bind      common  directory.yast  initrd-xen     loader      openSUSE  rpmlist      vmlinuz-xenpae
branding  config  gdb             initrd-xenpae  mkbootdisk  rescue    vmlinuz-xen

Following some other advice I found, I added another boot entry to the /etc/grub.d/40_custom

adam@desk12two:/etc/grub.d> cat /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.
menuentry "SUSE 13.1 ISO" {
set root=(hd0,15)
loopback loop /adam/openSUSE-13.1-NET-i586.iso
linux (loop)/boot/i386/vmlinuz-xen isoloop=/adam/openSUSE-13.1-NET-i586.iso
initrd (loop)/boot/i386/initrd-xen
}

and then update the grub config file like this.

grub2-mkconfig -o /boot/grub2/grub.cfg

The new entry is showing up on the grub boot menu, but it crashes and restarts the computer. Can anyone tell me what I need to change in my menu entry?

The problem has been solved. I used the incorrect path to the linux and initrd. Here is 40_custom, now that is has been fixed.

adam@desk12two:/etc> sudo cat /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.
menuentry "SUSE 13.1 ISO" {
set isofile=/adam/openSUSE-13.1-NET-i586.iso
set root=(hd0,15)
loopback loop $isofile
linux (loop)/boot/i386/loader/linux isoloop=$isofile
initrd (loop)/boot/i386/loader/initrd
}

This works. I’ve seen some others that are different, but this worked on my system.