Create a makeshift Restore and ISO booting partition (with Grub)

Credits: This tutorial is dedicated to my digital friend @gohlip, as without his continuous guidance, help and patience, I would never be as confident as I could dare writing a Grub-related guide. Many thanks pal!!

(Why) do I need a Restore partition?

In rolling release distributions, like Arch/Manjaro, it is not unexpected or uncommon to have your system not booting, or other serious problems that prevent you from getting to your GUI or even TTY. A standard restore method has not been established yet as a Distro setup, except from the standard guides to chroot using a Live media to repair your system. It would be nice to have a proper restore method, using a disk partition, being a dedicated system installation, with all the usefull restore tools and utilities. Until something like this is established (or untill I create a tutorial for :wink:), you may achieve some of the goals of a complete restore system, booting to a Live ISO. This justs saves you from having always a Live ISO USB stick or CD/DVD.

Other possible usage scenarios

Provided you are willing or able to create your own custom ISO image, with your preferred applications and settings, it maybe of great value, only limited from your imagination.

  • It can provide a means to quickly test a new ISO, without the hassle of "burning" it on a USB stick (which always deletes everything inside, due to the dd method).

  • You might use it as a restricted private session of working with Internet web apps or services.

  • You may have it as a Guest session for visitors or siblings, since they wouldn't (normally) destroy your system.

If you have a spare partition (or you disabled your swap partition in favor of zram, or you decide it 's worth creating one) of a minimum of 3GB, or as large as you need, you can make it act as a makeshift Restore partition, or a way of booting ISO images without burning them to a CD/DVD/USB media. Even if it is possible to use your current grub folder, it avoids clutter in the boot system and saves your current root partition from extra space, if you haven't created a really large one, during installation.

Personal history

I had this idea for a long time, but a great opportunity to finally make it happen, after disabling my swap partition in favor of zram swapping. This gave me an empty 4GB partition, along my system partitions. Knowing that Grub can boot ISO images saved on disk, I find this feature too useful to not use it..

After some testing and grub error hunting... is what and how you can do, in conclusion, with an example of a new restore partition /dev/sda3 (use your own actual partition name):

  1. Create a folder as a mount point in /boot, with result:
  1. Create a label for the restore partition (optional)
    Start GParted (or other partition manager), find your partition, (if it is swap or just unformatted space, format it to ext4, if it is mounted, unmount it first) select and create a label ("restore" is used in the example). Also, copy the partition's UUID, because it is needed later. Apply changes and exit GParted.

  2. Mount the spare partition (make sure it is not already mounted with lsblk)

mount /dev/sda3 /boot/restore
  1. Create an fstab entry,
    If you forgot to copy UUID in GParted, find it with:
blkid | grep sda3

/dev/sda3: LABEL="restore" UUID="<long-string> TYPE="ext4" PARTUUID="<short-string>"

Using your text editor, edit /etc/fstab and create something like this (if you have already a separate /home partition, you may clone that line in fstab and change the partition and mount point entries)

UUID=d6c14b3e-e542-4831-9eed-59b2fabe7380 /home ext4 defaults,noatime 0 2
UUID=445d3791-02ce-4cf6-98d9-5476599245be /boot/restore ext4 defaults,noatime 0 2

The flags are for my SSD, use what you should, for your drive..

  1. Create a folder in the "restore" partition, where you will place your ISOs. I named it "isos", as it suits an additional purpose I will explain later. Example:
  1. Copy one or more Manjaro ISO images in the "isos" folder. I copied
  1. Create a file for adding custom Grub menu entries to boot ISO images (if it already exists, skip to the next step), as
  1. Paste/add these Grub menu entries in the custom.cfg file:
menuentry "Manjaro (loop) KDE 18.0 Stable" {
	export iso_path
	search --set=root --file $iso_path
	probe -u -s rootuuid $root
	export rootuuid
	loopback loop $iso_path
	configfile /boot/grub/loopback.cfg

menuentry "Manjaro (loop) Architect 17.1.12" {
	export iso_path
	search --set=root --file $iso_path
	probe -u -s rootuuid $root
	export rootuuid
	loopback loop $iso_path
	configfile /boot/grub/loopback.cfg

menuentry "Manjaro KDE 18.0 Stable (GR)"  {
    set isofile="/isos/manjaro-kde-18.0-stable-x86_64.iso"
    set dri="free"
    search --no-floppy -f --set=root $isofile
    probe -u $root --set=abc
    set pqr="/dev/disk/by-uuid/$abc"
    loopback loop $isofile
    linux  (loop)/boot/vmlinuz-x86_64  img_dev=$pqr img_loop=$isofile driver=$dri tz=Europe/Athens lang=el_GR keytable=us
    initrd  (loop)/boot/intel_ucode.img (loop)/boot/initramfs-x86_64.img

menuentry "Manjaro Architect 17.1.12 (GR)"  {
    set isofile="/isos/manjaro-architect-17.1.12-stable-x86_64.iso"
    set dri="free"
    search --no-floppy -f --set=root $isofile
    probe -u $root --set=abc
    set pqr="/dev/disk/by-uuid/$abc"
    loopback loop $isofile
    linux  (loop)/boot/vmlinuz-x86_64  img_dev=$pqr img_loop=$isofile driver=$dri tz=Europe/Athens lang=en_US keytable=us
    initrd  (loop)/boot/intel_ucode.img (loop)/boot/initramfs-x86_64.img

The first two entries boot the ISOs with the loopback method, getting you to the original Manjaro ISO Grub menu, with all the available editable entries.

The next two entries boot straight to the ISO itself (KDE or Architect sessions), bypassing the original Manjaro ISO Grub menu. Please, notice I have changed the timezone parameter from "tz=Europe/London" to "tz=Europe/Athens" in KDE ISO entry, so I get the Greek locale in the Plasma environment (the session menus and applications UI are in Greek). You can change to your locale, using your own. Check your running system's with

timedatectl status

Extra Bonus!

Because Grub is so smart and scriptable, it is possible to make it auto-discover ISO images and boot them, without the need to create a custom entry for each new image. This is what Github user Aguslr has created with his MultibootUSB Project.

It is originally intended to be used to create a Multiboot USB drive, where you would copy any (compatible) image and use it to boot it as if you had burned it to a flash drive or CD/DVD.

This is how you can embed this functionality to your new restore partition:

  • Download the project's files in a local folder and decompress it:
mkdir AIBoot
cd AIBoot
wget -O - | tar -xzv --strip-components 1
sudo cp -r mbusb.{cfg,d} /boot/grub

If you wonder why the proposed name of the folder (it can be anyone..) is AIBoot, you can see the answer here

Make some changes:

  • To /boot/grub/custom.cfg
    Add these lines at the end of the file
# ========= Multiboot ISO  ==========

if [ -e "$prefix/mbusb.cfg" ]; then
  source "$prefix/mbusb.cfg"

  • To /boot/grub/mbusb.cfg
    Add this at the top of the script:
search --label restore --set=root

Edit the path in this line to point to the ISOs folder, relative to the (restore) partition's root:

# set isopath="/boot/isos"
set isopath="/isos"

Save both files and ... reboot to test it!!
(You don't need to update grub)

Some info about the MultiUSB project

It can boot to a very large list of (not only) Linux ISOs. Check the mbusb.d folder! I have not tested all of them, so if you find one is not properly booting, please inform the developer, and maybe with a proposed change to the grub menu entries.
Now I remember :fearful::anguished::zipper_mouth_face: I may have made some changes to the Manjaro mbusb entries, I will check again if needed to be some addition above. Until then, use what it works.. :joy:


Great Tutorial @AgentS. :slight_smile:

After it has spent some time in the wild & you have got some testing feedback, someone should put this in the wiki.


Forum kindly sponsored by