How can I burn a bootable ISO file to a partition on my hard drive to use as a rescue system?

Solution 1:

To boot an ISO image from a partition:

(hd0,6) is just an example, you have to change it according to the partition you have.

  1. Get the ISO (duh)

  2. Select your partition where the ISO images is gonna be booted from. It doesn't need to be a special partition, it can be any format, or at least FAT, NTFS, EXT*. (I haven't tried with others)(if you want persistence, it has to be FAT). It can have other data in it, won't make a difference. Take a note of what partition it is, ie /dev/sda6

  3. Copy the ISO to your partition. To be organized, you can create a folder let's say /isoboot/ in the root of the partition, then a subfolder with a name identifying the system, and paste the ISO there.

  4. Mount the ISO. The easiest with is to use the option "Open with disk image mounter" from the contextual menu in the file browser, right clicking on the file.

  5. Once mounted, go to the directory /boot/grub/ and copy the file grub.cfg. Paste it inside /isoboot/<your_system_name>.

  6. In your Ubuntu, open with sudo privileges the file /etc/grub.d/40_custom. Add the menuentry:

    menuentry 'Your name of the ISO system' {
      set root='hd0,6' # this mean /dev/sda6
      configfile /isoboot/<your_system_name>/grub.cfg
    }
    
  7. Run update-grub.


This is different on every ISO, grub config files may have different names

Configuring the ISO grub.cfg file, System Rescue CD

Open the file with your preferred text editor and make the following changes:

  1. At the top of the file add the lines

    set isofile=/isoboot/systemrescuecd-6.0.3.iso
    loopback loop $isofile
    
    probe -u $root --set=rootuuid
    set imgdevpath="/dev/disk/by-uuid/$rootuuid"
    
  2. In the menu entries add the text in bold

    
    menuentry "Boot SystemRescueCd using default options" {
        set gfxpayload=keep
        linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=SYSRCD603 img_loop=$isofile img_dev=$imgdevpath
        initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img
    }
    
    

    menuentry "Boot SystemRescueCd and copy system to RAM" { set gfxpayload=keep linux (loop)/sysresccd/boot/x86_64/vmlinuz archisobasedir=sysresccd archisolabel=SYSRCD603 copytoram img_loop=$isofile img_dev=$imgdevpath initrd (loop)/sysresccd/boot/intel_ucode.img (loop)/sysresccd/boot/amd_ucode.img (loop)/sysresccd/boot/x86_64/sysresccd.img }


Configuring the ISO grub.cfg file, Boot Repair

Open the file with your preferred text editor and make the following changes:

  1. At the top of the file add the lines

    set isofile=/isoboot/boot-repair/boot-repair-disk-64bit.iso
    loopback loop $isofile
    
  2. In the menu entries add the text in bold

    
    menuentry "Boot-Repair-Disk session" {
        set gfxpayload=keep
        linux   (loop)/casper/vmlinuz.efi file=/cdrom/preseed/lubuntu.seed boot=casper quiet splash iso-scan/filename=$isofile --
        initrd  (loop)/casper/initrd.lz
    }
    

Configuring the ISO grub.cfg file, Ubuntu with persistence

Here we will use ubuntu-16.04.6-desktop-i386.iso

WARNING: the filesystem type for persistence to work must be FAT

How to create a casper-rw file

Copy the casper-rw file alongside the ISO

Open the file grub.cfg with your preferred text editor and make the following changes:

  1. At the top of the file add the lines

    set iso_path=/isoboot/ubuntu/ubuntu-16.04.6-desktop-i386.iso
    loopback loop $iso_path
    
  2. In the menu entries add the text in bold

    
    menuentry "Try Ubuntu without installing" {
        linux   (loop)/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper iso-scan/filename=${iso_path} quiet splash persistent persistent-path=/isoboot/ubuntu ---
        initrd  (loop)/casper/initrd
    }
    menuentry "Install Ubuntu" {
        linux   (loop)/casper/vmlinuz  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity iso-scan/filename=${iso_path} quiet splash ---
        initrd  (loop)/casper/initrd
    }
    menuentry "Check disc for defects" {
        linux   (loop)/casper/vmlinuz  boot=casper integrity-check iso-scan/filename=${iso_path} quiet splash ---
        initrd  (loop)/casper/initrd
    }
    menuentry "Test memory" {
        linux16 (loop)/install/mt86plus
    }
    

Accesing the systems from grub> terminal

grub> configfile (hd0,6)/isoboot/<your system folder>/grub.cfg