Creating a Recovery Partition in Pop!_OS

Those who have installed Pop!_OS with a non-default setup can still create a recovery partition. The recovery partition contains a live operating system version so users can make full install changes, upgrades, and any other recovery processes.

If you have tailored your partition setup, you probably noticed that you did not automatically get a recovery partition on your system. This guide will show you how to get one on an existing install.

Tools and programs needed:

  • mkfs.vfat: the recovery partition needs to be formatted in vfat.

  • gparted, parted, gdisk, fdisk: you get the riddle. Use whater works for you. I personally prefer to use gparted.

  • pop-upgrade: available by default on POP!_OS.

  • a text editor (I use vim).

I also assume you have an average knowledge of Linux and of the basic concepts of partitions, filesystems, and so on. I will not go into detailed step-by-step descriptions of everything done.

Mind that you need to execute most of the steps below as root; sudo -i is your friend, in this case.

Creating a recovery partition

You need 4.4 GiB of unutilized space available on your main disk drive. This space will then be used to create a new FAT32 part on your drive’s partition table.

If you are using btrfs, It is essential to resize the btrfs filesystem before diminishing the storage size, as there may be allocated parts present in the areas you will be cutting away. Consequently, a slight rebalancing of those data blocks is necessary. The following command will resize your filesystem:

btrfs filesystem resize -4.4g /

I normally use gparted to resize the disk, but any other tool of your preference can be utilized to accomplish the same. If you have not already done so, make a 4.4 GiB partition, and then create the FAT32 filesystem on the new partition (you’ll need to do this booting from an installation media, as far as I remeber).

You can label the new filesystem so that it’s easier to recognise it later.

Formatting the partition with the vfat (FAT32) file system and labelling it RECOVERY can be done by using the command

mkfs.vfat -n RECOVERY /dev/{{ parition }}

The partition now needs to be mounted at /recovery.

mkdir /recovery

mount -L RECOVERY /recovery

Populating the Recovery Partition

Installing the Pop!_OS ISO into the recovery partition requires the use use the pop-upgrade tool.

pop-upgrade can be cryptic with its messages if something goes wrong; therefore, I would recommend opening a terminal to keep the logs monitored with

journalctl -flu pop-upgrade

Note: if your /tmp directory has less storage than the full size of POP!_OS, you may face difficulty installing. To prevent this, make sure you have at least 2.5 GiB of disk storage on /tmp.

Now, on a terminal, execute as root:

pop-upgrade recovery upgrade from-release

if everything goes well, you’ll see an output like:

root@pop-os:~# pop-upgrade recovery upgrade from-release
checking if pop-upgrade requires an update
Recovery event: fetching recovery files
Fetched 2493/2496 MiB
Recovery event: verifying checksum of fetched files
Recovery event: syncing recovery files with recovery partition
Recovery event: recovery partition upgrade completed
Recovery upgrade status: recovery partition refueled and ready to go

If the pop-upgrade recovery process was successful, you should find an automatically created entry in your /etc/fstab. If that’s not the case, you’ll need to manually add it:

(be careful of the difference between “UUID” and “PARTUUID”)

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
PARTUUID={{ pop_recovery_part_PARTUUID }} /recovery vfat umask=0077 0 0

If the pop-upgrade recovery process does not succeed, go to /etc/fstab and disable the automatically created line for the /recovery partition.

Incorporating the recovery.conf file

Now that you’ve got the recovery partition, you need to add the recovery.conf file. Create the file /recovery/recovery.conf with this template:

(be careful of the difference between “UUID” and “PARTUUID”)

HOSTNAME=pop-os
LANG=en_US.UTF-8
KBD_LAYOUT=us
KBD_MODEL=
KBD_VARIANT=
EFI_UUID=PARTUUID={{ pop_boot_part_PARTUUID }}
RECOVERY_UUID=PARTUUID={{ pop_recovery_part_PARTUUID }}
ROOT_UUID={{ pop_root_UUID }}
LUKS_UUID=
OEM_MODE=0

Replace all of the placeholder “{{ }}” with the unique UUID of the partition or the PARTUUID where indicated. You can get the relevant IDs with blkid.

root@pop-os:/recovery# blkid
/dev/vda3: UUID="6c5e552b-d98a-40a9-a00f-d2a1fe0a5beb" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="28ea30b3-783f-4ede-b1f2-82f5623a66ab"
/dev/mapper/cryptswap: LABEL="cryptswap" UUID="e6a5011e-84f4-4bdf-8d4b-f0b1dda61787" TYPE="swap"
/dev/zram0: UUID="2df20122-f063-4b01-ab91-e78dde3699d3" TYPE="swap"
/dev/vda4: UUID="b022ef26-84df-49d1-89d9-3e9f77a797f5" TYPE="swap" PARTUUID="dacd59bc-48a7-4db6-8c08-e32632deec56"
/dev/vda2: UUID="0E57-8003" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="recovery" PARTUUID="4c7e1e09-82b3-4209-bead-e269c82a37d9"
/dev/vda1: UUID="0E57-8F5C" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="b5518ef2-6974-415f-9b83-f3aabf36d612"

Below you can see how the recovery.conf needs to be filled in based on the example output above:

HOSTNAME=pop-os
LANG=en_US.UTF-8
KBD_LAYOUT=us
KBD_MODEL=
KBD_VARIANT=
EFI_UUID=PARTUUID=b5518ef2-6974-415f-9b83-f3aabf36d612
RECOVERY_UUID=PARTUUID=4c7e1e09-82b3-4209-bead-e269c82a37d9
ROOT_UUID=6c5e552b-d98a-40a9-a00f-d2a1fe0a5beb
LUKS_UUID=
OEM_MODE=0

Making an entry in systemd-boot

Well done! You are almost there. To finish, you need to add an entry in the systemd-boot loader. As root create a new file in /boot/efi/loader/entries/ named Recovery{{ pop_recovery_UUID }}.conf (you can name this file pretty much as you want. The naming convention used here is the one used by Pop!_OS in the default installation.

Using the information from the example above the file would be Recovery-0E57-8003.conf

Template for the boot entry file: (be careful of the difference between “UUID” and “PARTUUID”)

title Pop!_OS recovery
linux /EFI/Recovery-{{ recovery_partition_UUID }}/vmlinuz.efi
initrd /EFI/Recovery-{{ recovery_partition_UUID }}/initrd.gz
options boot=casper hostname=recovery userfullname=Recovery username=recovery live-media-path=/casper-{{ recovery_partition_UUID }} live-media=/dev/disk/by-PARTUUID/{{ recovery_partition_PARTUUID }} noprompt

As you are doing this, I do also recommend adding a two seconds delay to the boot menu (it makes it easier to boot into recovery mode when needed)

root@pop-os:~# cd /boot/efi/loader/
root@pop-os:/boot/efi/loader# echo "timeout 2" >>loader.conf 
root@pop-os:/boot/efi/loader# cat loader.conf 
default Pop_OS-current
timeout 2

Testing the new boot entry is the final step. A reboot should show if Pop!_ OS recovery mode is working correctly. If any issues arose during the setup, checking the pop-upgrade journal logs should help resolving them.

Diego Zaccariotto
Diego Zaccariotto
Head of Customer Support - Team Leader EMEA | Service Operations Management, Change & Transformation

I’m a Senior Manager and IT professional with 25+ years of experience, a background in system administration, and an MBA.