Install Ubuntu from iso file using grub2

I have previous versions of Ubuntu, which includes grub2. I see on the Internet that, grub2 can boot from iso file, So, I booted Ubuntu from iso file, But whenever I tried to install, it gives an error that, "The disk need to be unmounted first before install".

My question is: How can I install Ubuntu 12.04 from iso file using grub2?


I have successfully booted from iso file and install from that iso file!

The procedure is here

  • First put your Ubuntu iso file in a partition, I have put that in "NTFS" partition, But it should work with ext4 partition also. It is second partition in my hard disk. For example, let's name our Ubuntu iso file as ubuntu.iso. the partition is /dev/sda2 in my case. The location of the Ubuntu iso file is now in (hd0,2)/ubuntu.iso as seen by grub2, i.e It is in the root of the second partition

  • Then reboot your system, containing grub2.

  • Press SHIFT to bring the grub2 menu, if it is not shown by default.

  • In the grub2 menu, press C to bring Command Prompt of the grub2.

  • In the command prompt type this one by one, pressing Enter after each line.

    loopback loop (hd0,2)/ubuntu.iso
    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu.iso quiet splash --
    initrd (loop)/casper/initrd.lz
    boot
    

In 2nd command, if vmlinuz doesn't work use vmlinuz.efi .

After typing boot press Enter. The Live Ubuntu system will be started.

  • Open a terminal and type the below command to unmount the drive where iso file resides

    sudo umount -l /isodevice  
    
  • Then proceed with the normal installation procedure.

Notes:

  1. If you put your iso file in a partition other than 2nd partition, change (hd0,2) to (hd0,X), where X refers to the partition number.

  2. If you put your iso file in a USB pendrive, and you start grub2 from Hard disk (installed by your previous system) , change (hd0,2) accordingly. If you have only one partition in the pendrive, it will be (hd1,1). here hd1 refers to the pen drive.

  3. I have tested this method for installing Ubuntu in ext4 and jfs partition, they worked. But installation in btrfs partition failed.