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.

7
  • 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, 2019 at 0:19
  • 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. Aug 29, 2019 at 0:21
  • 1
    You just need to edit the existing GRUB of your Ubuntu installation. Aug 29, 2019 at 0: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. Aug 29, 2019 at 0: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. Aug 29, 2019 at 0:56

1 Answer 1

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
12
  • 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, 2019 at 0: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. Aug 31, 2019 at 0:39
  • 1
    Every ISO is a little different, tell what other ISO you need (besides boot-repair) and I'll add it to the answer. Aug 31, 2019 at 0:46
  • 2
    3. "Copy the ISO to your partition." a bit vague, is really a copy or to mean: extracting ISO into your partition Jul 28, 2023 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. Jul 28, 2023 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .