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.
1 Answer
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.
Get the ISO (duh)
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
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.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.Once mounted, go to the directory
/boot/grub/
and copy the filegrub.cfg
. Paste it inside/isoboot/<your_system_name>
.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 }
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:
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"
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:
At the top of the file add the lines
set isofile=/isoboot/boot-repair/boot-repair-disk-64bit.iso loopback loop $isofile
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:
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
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.– JagsAug 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
-
1Every 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
-
23. "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
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 withdd
(data dump) be careful with it, it'll overwrite your whole hdd/sdd if you give it a wrong parameter