Booting ubuntu iso file from grub menu

I follow Grub2 ISO boot guide

https://help.ubuntu.com/community/Grub2/ISOBoot

here is my menu for iso booting

menuentry "Ubuntu 14.04 Live" {
     set isofile="/lilw/os/ubuntu.iso"
     loopback loop (hd0,10)$isofile
     linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile noprompt noeject
     initrd (loop)/casper/initrd.lz
}

but I failed to boot from iso file, it always make my system reboot.No message giving out so I don't know what happen.

If I get into grub menu and then using command at

grub >

typing these follow command:

grub > loopback loop (hd0,10)/lilw/os/ubuntu.iso
grub > linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile noprompt noeject
grub > initrd (loop)/casper/initrd.lz

and then

grub > boot

it will boot to the iso normally.

I don't want to boot this way. But the menuentry in grub does not work.

FYI: I have multiple version of ubuntu running on my system, range from 10.04 to the latest. My iso file store in sda10 which is a /home for the current ubuntu grub.

Edit 1: I extract the contains of iso file but still can't boot with ubuntu. But I can boot with Fedora 20 when extract it contains to a folder, weird..

Edit 2: Finally I find a site that help out with new grub2 command syntax. all the failed boot is because of wrong syntax in grub2

TRY THIS: solved my problems

http://git.marmotte.net/git/glim/tree/grub2

So my grub menu entry will look like this:

menuentry "Ubuntu 14.04 (LTS) Live Desktop amd64" --class ubuntu {
   set isoname="ubuntu-14.04-desktop-amd64.iso"
   set isofile="/lilw/os/${isoname}"
   loopback loop (hd0,10)$isofile
   linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=${isofile} quiet splash
   initrd (loop)/casper/initrd.lz
}

if I missing the two '{ }' of isofile it won't boot. so weird


Try this

 menuentry "Ubuntu 14.04 Live" {
 loopback loop (hd0,10)/lilw/os/ubuntu.iso
 linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=/lilw/os/ubuntu.iso noprompt noeject
 initrd (loop)/casper/initrd.lz
 }

In many versions of ubuntu iso as in Ubuntu 18.10 (Cosmic Cuttlefish), the files initrd.lz are just initrd . I suggest you to go and inspect your iso file for initrd and vmlinuz files.

While booting Ubuntu 18.10, I had also made that mistake.