Ny way to boot from iso while running system from live disk

bootablegrub2isolivecd

This is bit complicated question let me explain what is expected:

I know that we can add GRUB menuentry with location of ISO file and boot from ISO using GRUB entry. (i.e this method)

But suppose that:

  • I've ISO file of a GNU/Linux (say Trisquel 7.0) stored in computer (hard-disk) say at /dev/sda3/
  • I want to install it on /dev/sda4
  • I've Ubuntu 14.04 installation (bootable) disk from which I can install or try the live system.
  • Consider I've no operating system installed currently or installed system is crashed/corrupted (nothing to do with current boot-loader)

The question is: With the Installation disk, running live environment (say try without installing of Ubuntu 14.04), Can I boot from the ISO (of Trisquel 7.0) from /dev/sda3 and install that system on /dev/sda4? How do I?

Note:I agree that it is better to create/burn live disk/USB of the system I want to install from iso but If there is no disk/usb available right now then Can I do such operation mentioned in question?

I think there is one possible technique: Install GRUB from (Ubuntu's) live environment on HDD pointing the path of ISO (Trisquel) that I finally want to boot from! How to?

Best Answer

Tested on VM. Was able to boot from Trisquel Live ISO (residing on hard disk) using this method.

Required steps would look like this:

  1. After booting to your Ubuntu Live disk, start it's installation process. You would need to do at least minimal installation of the system on /dev/sda4 to get a working and bootable GRUB. But it's easier to just do full installation (it's rather quick).

    1.a. Be sure to restrict the installation to change only the contents of /dev/sda4. To do so you would need to select "Something else" when asked about hard disk settings.

  2. Test that your fresh GRUB is working by booting to the installed system.

    2.a. Note: Under Ubuntu to show GRUB menu press and hold Shift on system start. This question contains instructions on how to enable showing of GRUB menu on every boot.

  3. Now you need to add the required menuentry as explained in this method that you mentioned. Providing adaptation:

    3.a. I assume, that the Trisquel ISO is located at root of /dev/sda3/.

    The menuentry for the ISO image needs to be added to /etc/grub.d/40_custom file. Edit the file by:

    sudo apt-get install gksu
    gksudo gedit /etc/grub.d/40_custom
    

    And replace the text in that file with this one:

    #!/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 "Trisquel ISO" {
            set isofile="/trisquel_7.0_amd64.iso"
            loopback loop (hd0,3)$isofile
            linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject
            initrd (loop)/casper/initrd
    }
    

    Where is:

    • Trisquel ISO = The name you want to display in the Grub menu.
    • /trisquel_7.0_amd64.iso = The path to the ISO image on target partition.
    • (hd0,3) = The partition which contains the ISO image (for GRUB it's equal to /dev/sda3 from linux: "sda1" == "(hd0,1)"; "sdb2" == "(hd1,2)"; ...).
    • note: the tail -n +3 means simply "which line grub starts to read the configuration from as is". the 3th line in this example is the first comment line, which is fine.

    3.b. Save and close this file and now run this command (to apply changes):

    sudo update-grub
    
  4. Now you should be able to boot from ISO on hard disk.
    Note: if you require using /dev/sda3 in installation process, then use this command from the Live CD environment:

    sudo umount -l /isodevice
    

Futher reading: reference and examples of Ubuntu menuentries.

Related Question