9

I plan on reinstalling Ubuntu and I would like to burn a small bootable recovery system (like SystemRescueCD) to a partition on my hard drive, but still be able to install Ubuntu on the same drive and be able to boot Ubuntu and the recovery partition. Is this possible and if so, how can I do it? EDIT: My current Ubuntu version is 19.04.

  • 2
    I use dd to write my ISO files to thumb-drives, so I'd just of=/dev/sd?? and write to the partition you want instead of the thumb-drive I usually use. Note: if you're not familiar with dd (data dump) be careful with it, it'll overwrite your whole hdd/sdd if you give it a wrong parameter – guiverc Aug 29 '19 at 00:19
  • Yes it's possible, adding the right entry in the GRUB menu. In fact you could boot multiple isos, but that depends on the iso image. – schrodingerscatcuriosity Aug 29 '19 at 00:20
  • 1
    I am wondering if I’d need to install GRUB as well for this or if installing Ubuntu will cover that. I am familiar with dd, and I’m reinstalling anyway, so that’s not really a concern. – GNULinuxOnboard Aug 29 '19 at 00:21
  • 1
    You just need to edit the existing GRUB of your Ubuntu installation. – schrodingerscatcuriosity Aug 29 '19 at 00:24
  • 1
    I could not get it to work on the same physical drive. Works great on a different physical drive. Following to see if someone shows how. – Organic Marble Aug 29 '19 at 00:46
  • 1
    I’m going to do it from a live system after I’ve wiped the drive. The only thing that will be left will be a backup partition so I can move my 200gb of crap onto the new installation. After I flash systemrescuecd or kaspersky recovery or whatever it is, I’ll install Ubuntu and leave the backup partition to move all my stuff onto Ubuntu. – GNULinuxOnboard Aug 29 '19 at 00:56
  • It may actually be better to install Ubuntu first and leave 4gb of space for the recovery partition and then burn the ISO after that – GNULinuxOnboard Aug 29 '19 at 01:33

1 Answers1

7

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 file (no extracting) 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
  • is it possible to add Boot-Repair or other system recovery tools to the rescue ISO? Just in case, if there's no internet, system still can be recovered. Thanks. – Jags Aug 31 '19 at 00:33
  • @Jags Yes, almost every debian/ubuntu systems can be added this way, others can be a bit more complicated (I could boot Manjaro, but it took me a while). Boot repair wouldn't be accessible if GRUB is broken :), although it could be run if the grub rescue shell is avilable. – schrodingerscatcuriosity Aug 31 '19 at 00:39
  • Thanks, so how could I add boot-repair or any other packages to the rescue ISO please. – Jags Aug 31 '19 at 00:41
  • 1
    Every ISO is a little different, tell what other ISO you need (besides boot-repair) and I'll add it to the answer. – schrodingerscatcuriosity Aug 31 '19 at 00:46
  • Thank you so much. I was thinking to first add (1) boot-repair and (2) grub-customizer to the Ubuntu Mate 19.04 x64 ISO. Then implement the System Rescue Partition as you have described in great detail. – Jags Aug 31 '19 at 00:53
  • I could also add ntfs-3g to the rescue ISO. – Jags Aug 31 '19 at 01:02
  • The ISO's are live systems, wich means any change you do, like installing packages, will be deleted on reboot. What you can do is create a persistent system, wich can be done with an ubuntu image, but I'm not sure with system rescue cd or other tools like it. – schrodingerscatcuriosity Aug 31 '19 at 01:18
  • @Jags Added boot repair. – schrodingerscatcuriosity Aug 31 '19 at 13:26
  • Added Ubuntu with persistence. – schrodingerscatcuriosity Aug 31 '19 at 16:24
  • 2
  • "Copy the ISO to your partition."
  • a bit vague, is really a copy or to mean: extracting ISO into your partition

    – user17227456 Jul 28 '23 at 13:37
  • 1
    @itilmemekcantik Copy the ISO, no extracting. If you look at the entries configuration they refer to the ISO file, example: set iso_path=/isoboot/ubuntu/ubuntu-16.04.6-desktop-i386.iso. – schrodingerscatcuriosity Jul 28 '23 at 19:15
  • See also this link; 2. If you want a persistent live system, you can have a partition for persistence. With current Ubuntu systems, that partition should have an ext file system (ext2, ext3 or ext4) the label writable (and it should be a separate partition, not where the ISO file is located).
  • – sudodus Dec 30 '23 at 18:45