Install Fedora 35 with Snapper Full System Rollback

Install Fedora 35 With Snapper Feature Image

This tutorial is no longer valid. Please refer to my latest tutorial on How to Install Fedora 36 with Snapper and Grub-Btrfs with fully functioning system snapshots and rollbacks.

Fedora 35 Workstation has introduced a variety of new features that make working with Fedora far more enjoyable than before. So, in this blog post, I will show how to install Fedora 35 with snapper full system rollback support. In this setup, the /boot directory will be included within the root filesystem (no separate boot partition). As a result, you can perform a full system rollback from the previously created working snapshot, including the kernel.

There are several solutions available on the internet, but none of them, from what I’ve found, can properly roll back to an earlier snapshot when a kernel update is made. I tried a variety of approaches to ensure that Fedora can be rolled back to a previous snapshot with an earlier kernel without any problem. This is what I came up with. I made some modifications to the default setup to make it work. There may be more ways to get the same result, but these are the steps I used.

Here is what the disk layout looks like:

ESP PARTITIONBTRFS VOLUME
/boot/efi//home/var/log/var/lib/libvirt/images
roothomelogimages
/dev/vda1/dev/vda2

Here's a brief rundown of what you may expect.

  1. Install Fedora 35 Workstation with boot directory within the ‘root file system’ so that it is included in the snapshot and rollback regime.
  2. Tweak the default settings of Fedora to facilitate roll back.
  3. Install and configure snapper to take snapshots of the root subvolume.
  4. Using snapper, create some snapshots and test the undochange and rollback functionalities.

If you would like to install Fedora 35 with LUKS Full Disk Encryption (FDE), please check out my other article 'Install Fedora 35 with LUKS Full Disk Encryption (FDE)'.

So let's get started.

1. Install Fedora 35 Workstation

Boot your computer using the Fedora 35 Workstation installer in UEFI mode. On the welcome screen, select the Install to Hard Drive option. Next, select your LanguageKeyboard, and configure Time & Date. Following that, from the INSTALLATION SUMMARY screen, select Installation Destination.

You should now be on the INSTALLATION DESTINATION screen. To proceed, pick the Advanced Custom (Blivet-GUI) radio button and then hit the Done button.

install Fedora 35 With Snapper Select Blivet

You will see the BLIVET GUI PARTITIONING screen. Here you will create partitions, file systems, and btrfs subvolumes necessary to install Fedora 35 Workstation.

First, you need to create and mount the EFI partition. Select the free space and click the + sign to create a partition.

install Fedora 35 With Snapper Blivet Screen

Set the partition Size to 512 MiB, the Filesystem to EFI System Partition, and the Mountpoint to /boot/efi.

install Fedora 35 With Snapper Blivet Efi Partition

Then, you need to create a btrfs volume where you can create all the subvolumes needed to install Fedora Linux.

Select the free space again and click on the + sign to create a Btrfs volume. (1) Set the Device Type to Btrfs Volume. (2) Set the Size of the Btrfs volume. (3) Set the volume name for Btrfs. I named the Btrfs volume FEDORA, but you can name it whatever you like. Do not set any Mountpoint here. Leave it blank and click on the OK button.

install Fedora 35 With Snapper Blivet Btrfs Volume

Next, you must create subvolumes. (1) Select the Btrfs Volume from the left panel, and (2) click on the + sign on the right panel.

install Fedora 35 With Snapper Blivet Select Btrfs Volume

I’ll create four subvolumes: roothome, log, and images. You may also give subvolume names such as @@home@log, and @images if you wish. The root subvolume will be mounted at /, the home subvolume will be mounted at /home, the log subvolume will be mounted at /var/log, and finally, images subvolume will be mounted at /var/lib/libvirt/images. I'm creating a separate images subvolume because I don't want the KVM disk images to be included when I take a snapshot of the 'root file system'.

Subvolumes, unlike standard partitions or LVM logical volumes, do not have a size; instead, they behave like directories with shared space. However, the resemblance of subvolumes to directories ends here. Each subvolume, like a file system, has its own file tree, has its own POSIX namespace, and has its own pool of inodes. This means that hard links cannot be created between the subvolumes. From this point of view, a subvolume begins to look more like a separate file system. Subvolumes are not block devices either.

The Btrfs subvolumes are created in reverse order in the Anaconda installer for some reason. It means that the first specified subvolume is created last, and the last specified subvolume is created first. I will therefore specify the subvolumes in reverse order.

Create images subvolume. Enter the Name as images and Mountpoint as /var/lib/libvirt/images. Click OK to finish.

install Fedora 35 With Snapper Blivet Create Images Subvolume

Create log subvolume. Enter the Name as log and Mountpoint as /var/log. Click OK to finish.

install Fedora 35 With Snapper Blivet Create Log Subvolume

Click again on the + symbol to create the home subvolume. Enter the Name as home and Mountpoint as /home. Click OK to finish.

install Fedora 35 With Snapper Blivet Create Home Subvolume

Repeat the same process for the root subvolume as well. Enter the Name as root and Mountpoint as /. Click OK to finish.

install Fedora 35 With Snapper Blivet Create Root Subvolume

When completed, the subvolumes must look something like this. Click Done to create subvolumes.

install Fedora 35 With Snapper Blivet Subvolumes Overview

As with the swap partition, Fedora generates a SwapOnZRAM upon startup, so no separate swap partition is needed.

Verify that the partitions and subvolumes are properly defined on the SUMMARY OF CHANGES screen. To finalize the changes, click the Accept Changes button.

install Fedora 35 With Snapper Confirm Partition Creation

You will be returned to the INSTALLATION SUMMARY screen. Press the Begin Installation button to start the installation process. The installation process will start. Just sit back and relax.

install Fedora 35 With Snapper Installation Process

When the installation is finished, click the Finish installation button and restart the computer.

The last phase of the installation procedure will start. Click the Start Setup button to complete the remaining customization steps, such as setting a new login, password, and so on.

You will then be logged into the all-new Gnome 41 desktop interface.

install Fedora 35 With Snapper Gnome 41 Desktop

Open the Gnome terminal and check your current setup.

[madhu@fedora ~]$ lsblk -p
NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/zram0  251:0    0  3.8G  0 disk [SWAP]
/dev/vda    252:0    0   80G  0 disk 
├─/dev/vda1 252:1    0  512M  0 part /boot/efi
└─/dev/vda2 252:2    0 79.5G  0 part /var/lib/libvirt/images
                                     /var/log
                                     /home
                                     /
[madhu@fedora ~]$ sudo btrfs filesystem show /
Label: 'FEDORA'  uuid: 07430ee0-5ab0-4d68-be0c-221d538935d4
	Total devices 1 FS bytes used 3.08GiB
	devid    1 size 79.50GiB used 5.02GiB path /dev/vda2
[madhu@fedora ~]$ sudo btrfs subvolume list /
ID 256 gen 83 top level 5 path root
ID 257 gen 82 top level 5 path home
ID 258 gen 84 top level 5 path log
ID 259 gen 28 top level 5 path images
ID 264 gen 81 top level 256 path var/lib/machines

When you use QCOW2 images as virtual disks in KVM, the IO performance suffers. This is due to the fact that both the Btrfs filesystem and the QCOW2 images employ Copy-on-Write (CoW). When there is a lot of IO activity on the guest, the KVM guest may even freeze.

It is therefore necessary to disable the CoW feature in the /var/lib/libvirt/images directory.

[madhu@fedora ~]$ sudo chattr -R +C /var/lib/libvirt/images/

[madhu@fedora ~]$ sudo lsattr -d /var/lib/libvirt/images/
---------------C------ /var/lib/libvirt/images/

2. Configure Fedora for rollback

In Fedora, the default subvolume is set to top-level (FS_TREE), and the root subvolume is configured to mount on / in the kernel arguments.

[madhu@fedora ~]$ sudo btrfs subvolume get-default /
ID 5 (FS_TREE)

[madhu@fedora ~]$ sudo grubby --info=DEFAULT
index=0
kernel="/root/boot/vmlinuz-5.14.10-300.fc35.x86_64"
args="ro rootflags=subvol=root rhgb quiet"
root="UUID=07430ee0-5ab0-4d68-be0c-221d538935d4"
initrd="/root/boot/initramfs-5.14.10-300.fc35.x86_64.img"
title="Fedora Linux (5.14.10-300.fc35.x86_64) 35 (Workstation Edition)"
id="9bec848f799547f7a99df8fbdf903134-5.14.10-300.fc35.x86_64"

You should change this in such a way that when the snapshot is rolled back, the snapper can set the subvolume to be mounted on /.

So set the default subvolume by explicitly specifying the subvolume ID.

[madhu@fedora ~]$ sudo btrfs subvolume list /
ID 256 gen 140 top level 5 path root
ID 257 gen 134 top level 5 path home
ID 258 gen 142 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 114 top level 256 path var/lib/machines

[madhu@fedora ~]$ sudo btrfs subvolume set-default 256 /

[madhu@fedora ~]$ sudo btrfs subvolume get-default /
ID 256 gen 140 top level 5 path root

And remove the root subvolume from the kernel path and arguments.

To do this, first append the SUSE_BTRFS_SNAPSHOT_BOOTING="true" option to the /etc/default/grub file.

[madhu@fedora ~]$ echo 'SUSE_BTRFS_SNAPSHOT_BOOTING="true"' | \
  sudo tee -a /etc/default/grub

Next, remove the old Boot Loader Specification (BLS) configuration files.

[madhu@fedora ~]$ sudo -i
[root@fedora ~]# rm /boot/loader/entries/*.conf

Then recreate the BLS config files by adding kernel and initramfs images.

[root@fedora ~]# kernel-install -v add $(uname -r) \
  /lib/modules/$(uname -r)/vmlinuz

Update the grub.cfg file.

[root@fedora ~]# grub2-mkconfig -o /boot/grub2/grub.cfg

Take a look at the newly created BLS config files. The '/root' should be removed from the kernel/initrd line, and the 'rootflags=subvol=root' from the args line.

[root@fedora ~]# grubby --info=ALL
index=0
kernel="/boot/vmlinuz-5.14.10-300.fc35.x86_64"
args="ro rhgb quiet ${extra_cmdline}"
root="UUID=07430ee0-5ab0-4d68-be0c-221d538935d4"
initrd="/boot/initramfs-5.14.10-300.fc35.x86_64.img"
title="Fedora Linux (5.14.10-300.fc35.x86_64) 35 (Workstation Edition)"
id="9bec848f799547f7a99df8fbdf903134-5.14.10-300.fc35.x86_64"
index=1
kernel="/boot/vmlinuz-0-rescue-9bec848f799547f7a99df8fbdf903134"
args="ro rhgb quiet ${extra_cmdline}"
root="UUID=07430ee0-5ab0-4d68-be0c-221d538935d4"
initrd="/boot/initramfs-0-rescue-9bec848f799547f7a99df8fbdf903134.img"
title="Fedora Linux (0-rescue-9bec848f799547f7a99df8fbdf903134) 35 (Workstation Edition)"
id="9bec848f799547f7a99df8fbdf903134-0-rescue"

Because snapshot booting is now enabled, you must make modifications to the /boot/efi/EFI/fedora/grub.cfg file as well.

From this:

search --no-floppy --fs-uuid --set=dev 07430ee0-5ab0-4d68-be0c-221d538935d4
set prefix=($dev)/root/boot/grub2

export $prefix
configfile $prefix/grub.cfg

To this:

set btrfs_relative_path="yes"
search --no-floppy --fs-uuid --set=dev 07430ee0-5ab0-4d68-be0c-221d538935d4
set prefix=($dev)/boot/grub2

export $prefix
configfile $prefix/grub.cfg

Finally, disable the GRUB menu auto-hide feature. When Fedora is the only operating system installed on the system, Fedora implements a feature called ‘Hidden Grub Menu‘. The goal is to keep the interface as simple as possible, providing information only when it is necessary. However, you need to visually see the GRUB menu to verify whether the rollback is executed correctly.

This feature can be disabled by doing the following.

[root@fedora ~]# grub2-editenv - list
saved_entry=9bec848f799547f7a99df8fbdf903134-5.14.10-300.fc35.x86_64
menu_auto_hide=1
boot_success=1
blsdir=/root/boot/loader/entries

[root@fedora ~]# grub2-editenv - unset menu_auto_hide

And reboot.

[root@fedora ~]# reboot

3. Install and configure snapper for the 'root file system'

Install snapper and the optional package python3-dnf-plugin-snapper. The python3-dnf-plugin-snapper package allows you to generate pre and post snapshots every time you install a package on the system with the dnf command-line tool.

[madhu@fedora ~]$ sudo dnf install snapper python3-dnf-plugin-snapper

Now, create a new snapper configuration named root for the Btrfs subvolume at /.

[madhu@fedora ~]$ sudo snapper -c root create-config /

This will create a configuration file at /etc/snapper/configs/root, a new subvolume .snapshots, and the directory /.snapshots.

[madhu@fedora ~]$ ls -l /etc/snapper/configs/
-rw-r-----. 1 root root 1169 Dec  8 21:07 root

[madhu@fedora ~]$ sudo btrfs subvolume list /
ID 256 gen 166 top level 5 path root
ID 257 gen 156 top level 5 path home
ID 258 gen 166 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 155 top level 256 path var/lib/machines
ID 266 gen 165 top level 256 path .snapshots

[madhu@fedora ~]$ ls -ld /.snapshots
drwxr-x---. 1 root root 0 Dec  8 21:07 /.snapshots

However, as shown in the above listing, the subvolume .snapshots is not a top-level subvolume (ID=5). To perform a successful 'root file system' rollback, the .snapshots subvolume must be converted to a top-level subvolume.

First, delete the existing .snapshots subvolume.

[madhu@fedora ~]$ sudo btrfs subvolume delete /.snapshots
Delete subvolume (no-commit): '//.snapshots'

Then recreate a new snapshots subvolume with an ID of 5 (top-level). I've named the subvolume snapshots rather than .snapshots, but that's fine; you may call it whatever you like. The directory in which the snapshots are saved, however, must be kept .snapshots only.

[madhu@fedora ~]$ sudo mkdir /.snapshots
[madhu@fedora ~]$ sudo mount -o subvolid=5 /dev/vda2 /mnt
[madhu@fedora ~]$ sudo btrfs subvolume create /mnt/snapshots
[madhu@fedora ~]$ sudo umount /mnt

Now, connect the snapshots subvolume to the /.snapshots directory and then mount the snapshots subvolume. To do this, open the /etc/fstab file and append the orange-colored line. Replace UUID with your setup's UUID.

[madhu@fedora ~]$ sudo vim /etc/fstab
UUID=CB7A-411F                            /boot/efi               vfat  umask=0077,shortname=winnt       0 2
UUID=07430ee0-5ab0-4d68-be0c-221d538935d4 /                       btrfs subvol=root,compress=zstd:1      0 0
UUID=07430ee0-5ab0-4d68-be0c-221d538935d4 /home                   btrfs subvol=home,compress=zstd:1      0 0
UUID=07430ee0-5ab0-4d68-be0c-221d538935d4 /var/log                btrfs subvol=log,compress=zstd:1       0 0
UUID=07430ee0-5ab0-4d68-be0c-221d538935d4 /var/lib/libvirt/images btrfs subvol=images,compress=zstd:1    0 0
UUID=07430ee0-5ab0-4d68-be0c-221d538935d4 /.snapshots             btrfs subvol=snapshots,compress=zstd:1 0 0

Then mount the snapshots subvolume.

[madhu@fedora ~]$ sudo mount -a

Your setup must look something like this.

[madhu@fedora ~]$ lsblk -p /dev/vda2
NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
/dev/vda2 252:2    0 79.5G  0 part /.snapshots
                                   /var/log
                                   /home
                                   /var/lib/libvirt/images
                                   /

Now check to see if the snapshots subvolume has been elevated to a top-level (ID=5) subvolume.

[madhu@fedora ~]$ sudo btrfs subvolume list /
ID 256 gen 178 top level 5 path root
ID 257 gen 156 top level 5 path home
ID 258 gen 179 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 155 top level 256 path var/lib/machines
ID 267 gen 173 top level 5 path snapshots

You're almost done; all that's left is for the normal user to be able to list snapshots.

Open the /etc/snapper/configs/root file and add your user name.

[madhu@fedora ~]$ sudo vim /etc/snapper/configs/root
...
# users and groups allowed to work with config
ALLOW_USERS="madhu"
ALLOW_GROUPS=""
...

And change the group permission of the /.snapshots directory.

[madhu@fedora ~]$ sudo chown -R :madhu /.snapshots

The root subvolume's snapper configuration is now complete. Now list the snapshots.

[madhu@fedora ~]$ snapper ls
 # | Type   | Pre # | Date | User | Cleanup | Description | Userdata
---+--------+-------+------+------+---------+-------------+---------
0  | single |       |      | root |         | current     |         

At this stage, you do not have any snapshots, we will create some later.

4. Create snapshots and test the undochange and rollback features

I'll run two tests here. First, install a package, then undo the change. Second, update the kernel, boot into it, and then rollback to return to the previous kernel.

Test 1: Install a package and undo it.

Here I'm going to install a small package called ps_mem for testing purposes and then undo the changes.

[madhu@fedora ~]$ sudo dnf install ps_mem
Dependencies resolved.
===============================================================================
 Package         Architecture    Version                 Repository       Size
===============================================================================
Installing:
 ps_mem          noarch          3.6-14.fc35             fedora           23 k

Transaction Summary
===============================================================================
Install  1 Package

Total download size: 23 k
Installed size: 44 k
Is this ok [Y/n]:

Now, execute the command to ensure that it is installed.

[madhu@fedora ~]$ sudo ps_mem
 Private  +   Shared  =  RAM used	Program

248.0 KiB +  32.0 KiB = 280.0 KiB	mcelog
240.0 KiB +  68.0 KiB = 308.0 KiB	dbus-run-session
....
 24.6 MiB +   8.4 MiB =  33.0 MiB	systemd-journald
116.7 MiB +  22.0 MiB = 138.7 MiB	gnome-shell
---------------------------------
                        510.7 MiB
=================================

Check the snapper for snapshots.

[madhu@fedora ~]$ snapper ls
 # | Type   | Pre # | Date                                   | User | Cleanup | Description                 | Userdata
---+--------+-------+----------------------------------------+------+---------+-----------------------------+---------
0  | single |       |                                        | root |         | current                     |         
1  | pre    |       | Wednesday 08 December 2021 09:47:47 PM | root | number  | /usr/bin/dnf install ps_mem |         
2  | post   |     1 | Wednesday 08 December 2021 09:47:50 PM | root | number  | /usr/bin/dnf install ps_mem |   

As you can see there is a pre (#1) and post (#2) snapshot created for the package ps_mem.

Take a look at the differences between snapshots #1 and #2.

[madhu@fedora ~]$ snapper status 1..2
+..... /usr/bin/ps_mem
+..... /usr/share/doc/ps_mem
+..... /usr/share/doc/ps_mem/LICENSE
+..... /usr/share/man/man1/ps_mem.1.gz
c..... /var/cache/dnf/packages.db
+..... /var/cache/man/1415
c..... /var/lib/dnf/history.sqlite-shm
c..... /var/lib/dnf/history.sqlite-wal
-..... /var/lib/dnf/rpmdb_lock.pid
c..... /var/lib/rpm/rpmdb.sqlite-shm
c..... /var/lib/rpm/rpmdb.sqlite-wal

Now undo the changes.

[madhu@fedora ~]$ sudo snapper undochange 1..2
create:1 modify:5 delete:5

Check to see if the package ps_mem was indeed removed.

[madhu@fedora ~]$ sudo ps_mem
sudo: ps_mem: command not found

Cool! The undochange has been successful. But, because I want to keep the package ps_mem, I'll undo the changes once again.

[madhu@fedora ~]$ sudo snapper undochange 2..1
create:5 modify:5 delete:1

[madhu@fedora ~]$ sudo ps_mem
 Private  +   Shared  =  RAM used	Program

248.0 KiB +  31.0 KiB = 279.0 KiB	mcelog
240.0 KiB +  66.0 KiB = 306.0 KiB	dbus-run-session
....
 24.6 MiB +   8.6 MiB =  33.2 MiB	systemd-journald
116.1 MiB +  22.3 MiB = 138.3 MiB	gnome-shell
---------------------------------
                        514.0 MiB
=================================

Test 2: Update the kernel, boot into it, and then roll back to the previous kernel.

In this test, I'll update to the latest kernel and then rollback to the current kernel.

Examine the current kernel and subvolumes information.

[root@fedora ~]# uname -r
5.14.10-300.fc35.x86_64

[root@fedora ~]# ls -lh /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 11M Dec  8 20:54 /boot/vmlinuz-0-rescue-9bec848f799547f7a99df8fbdf903134
-rwxr-xr-x. 1 root root 11M Oct  8 02:35 /boot/vmlinuz-5.14.10-300.fc35.x86_64

[root@fedora ~]# btrfs subvolume list /
ID 256 gen 241 top level 5 path root
ID 257 gen 194 top level 5 path home
ID 258 gen 241 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 191 top level 256 path var/lib/machines
ID 267 gen 206 top level 5 path snapshots
ID 268 gen 197 top level 267 path snapshots/1/snapshot
ID 269 gen 199 top level 267 path snapshots/2/snapshot

[root@fedora ~]# btrfs subvolume get-default /
ID 256 gen 242 top level 5 path root

[root@fedora ~]# snapper ls
 # | Type   | Pre # | Date                                   | User | Cleanup | Description                 | Userdata
---+--------+-------+----------------------------------------+------+---------+-----------------------------+---------
0  | single |       |                                        | root |         | current                     |         
1  | pre    |       | Wednesday 08 December 2021 09:47:47 PM | root | number  | /usr/bin/dnf install ps_mem |         
2  | post   |     1 | Wednesday 08 December 2021 09:47:50 PM | root | number  | /usr/bin/dnf install ps_mem |      

Now update to the latest kernel.

[root@fedora ~]# dnf update kernel
Dependencies resolved.
=============================================================================
 Package              Architecture Version               Repository     Size
=============================================================================
Installing:
 kernel               x86_64       5.15.6-200.fc35       updates        14 k
 kernel-modules       x86_64       5.15.6-200.fc35       updates        33 M
Installing dependencies:
 kernel-core          x86_64       5.15.6-200.fc35       updates        35 M

Transaction Summary
=============================================================================
Install  3 Packages

Total download size: 67 M
Installed size: 108 M
Is this ok [Y/n]:

After the kernel update is finished, reboot the computer.

GRUB menu after the kernel update.

Install Fedora 35 With Snapper GRUB Menu after Kernel update

Now examine the updated kernel and subvolumes information.

[root@fedora ~]# uname -r
5.15.6-200.fc35.x86_64

[root@fedora ~]# ls -lh /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 11M Dec  8 20:54 /boot/vmlinuz-0-rescue-9bec848f799547f7a99df8fbdf903134
-rwxr-xr-x. 1 root root 11M Oct  8 02:35 /boot/vmlinuz-5.14.10-300.fc35.x86_64
-rwxr-xr-x. 1 root root 11M Dec  1 19:27 /boot/vmlinuz-5.15.6-200.fc35.x86_64

[root@fedora ~]# btrfs subvolume list /
ID 256 gen 266 top level 5 path root
ID 257 gen 266 top level 5 path home
ID 258 gen 266 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 258 top level 256 path var/lib/machines
ID 267 gen 254 top level 5 path snapshots
ID 268 gen 197 top level 267 path snapshots/1/snapshot
ID 269 gen 199 top level 267 path snapshots/2/snapshot
ID 270 gen 250 top level 267 path snapshots/3/snapshot
ID 271 gen 253 top level 267 path snapshots/4/snapshot

[root@fedora ~]# btrfs subvolume get-default /
ID 256 gen 266 top level 5 path root

[root@fedora ~]# snapper ls
 # | Type   | Pre # | Date                                   | User | Cleanup | Description                 | Userdata
---+--------+-------+----------------------------------------+------+---------+-----------------------------+---------
0  | single |       |                                        | root |         | current                     |         
1  | pre    |       | Wednesday 08 December 2021 09:47:47 PM | root | number  | /usr/bin/dnf install ps_mem |         
2  | post   |     1 | Wednesday 08 December 2021 09:47:50 PM | root | number  | /usr/bin/dnf install ps_mem |         
3  | pre    |       | Wednesday 08 December 2021 11:22:33 PM | root | number  | /usr/bin/dnf update kernel  |         
4  | post   |     3 | Wednesday 08 December 2021 11:23:21 PM | root | number  | /usr/bin/dnf update kernel  |         

For the sake of the experiment, I'll assume I've messed up the present system and rendered it unusable. So I'd want to return to the prior functioning snapshot, i.e. snapshot #3.

[root@fedora ~]# snapper --ambit classic rollback 3
Ambit is classic.
Creating read-only snapshot of current system. (Snapshot 5.)
Creating read-write snapshot of snapshot 3. (Snapshot 6.)
Setting default subvolume to snapshot 6.

[root@fedora ~]# reboot

GRUB menu after the rollback.

Install Fedora 35 With Snapper GRUB Menu after Rollback

Finally, examine the kernel and subvolumes information after the rollback.

[root@fedora ~]# uname -r
5.14.10-300.fc35.x86_64

[root@fedora ~]# ls -lh /boot/vmlinuz-*
-rwxr-xr-x. 1 root root 11M Dec  8 20:54 /boot/vmlinuz-0-rescue-9bec848f799547f7a99df8fbdf903134
-rwxr-xr-x. 1 root root 11M Oct  8 02:35 /boot/vmlinuz-5.14.10-300.fc35.x86_64

[root@fedora ~]# btrfs subvolume list /
ID 256 gen 278 top level 5 path root
ID 257 gen 285 top level 5 path home
ID 258 gen 285 top level 5 path log
ID 259 gen 109 top level 5 path images
ID 264 gen 258 top level 256 path root/var/lib/machines
ID 267 gen 274 top level 5 path snapshots
ID 268 gen 197 top level 267 path snapshots/1/snapshot
ID 269 gen 199 top level 267 path snapshots/2/snapshot
ID 270 gen 273 top level 267 path snapshots/3/snapshot
ID 271 gen 253 top level 267 path snapshots/4/snapshot
ID 272 gen 272 top level 267 path snapshots/5/snapshot
ID 273 gen 285 top level 267 path snapshots/6/snapshot

[root@fedora ~]# btrfs subvolume get-default /
ID 273 gen 285 top level 267 path snapshots/6/snapshot

[root@fedora ~]# snapper ls
 # | Type   | Pre # | Date                                   | User | Cleanup | Description                 | Userdata     
---+--------+-------+----------------------------------------+------+---------+-----------------------------+--------------
0  | single |       |                                        | root |         | current                     |              
1  | pre    |       | Wednesday 08 December 2021 09:47:47 PM | root | number  | /usr/bin/dnf install ps_mem |              
2  | post   |     1 | Wednesday 08 December 2021 09:47:50 PM | root | number  | /usr/bin/dnf install ps_mem |              
3  | pre    |       | Wednesday 08 December 2021 11:22:33 PM | root | number  | /usr/bin/dnf update kernel  |              
4  | post   |     3 | Wednesday 08 December 2021 11:23:21 PM | root | number  | /usr/bin/dnf update kernel  |              
5  | single |       | Wednesday 08 December 2021 11:39:45 PM | root | number  | rollback backup             | important=yes
6* | single |       | Wednesday 08 December 2021 11:39:46 PM | root |         | writable copy of #3         |          

Both tests were successful.

5. Conclusion

As you may have read, we have successfully configured Fedora to rollback properly. Going from here, you can next configure the home subvolume to take snapshots from the snapper command-line tool. You can also configure the timer to take snapshots at predetermined intervals. Visit the Arch Wiki's Snapper page for more information.

Watch on YouTube

guest
8 Comments
Newest
Oldest
Inline Feedbacks
View all comments