Skip to content

Instantly share code, notes, and snippets.

@mikethebeer
Last active February 16, 2024 06:24
Show Gist options
  • Save mikethebeer/8b7f970afbf8cbea244b2d29593a27c6 to your computer and use it in GitHub Desktop.
Save mikethebeer/8b7f970afbf8cbea244b2d29593a27c6 to your computer and use it in GitHub Desktop.
Fedora 30 the SUSE way - Snapper Rollback Btrfs

Fedora 30 the SUSE way - Snapper Rollback Btrfs

Fedora Installation

Partitioning

Fedora requires dedicated efi, boot and swap partitions to be defined. The rest of disk can be used for btrfs mounted on /.

alt

Within the btrfs partition I create the 3 subvolumes root, home and snapshots. Ignore the @ prefix in the subvolume names - Fedora will trim it away before installation.

alt

Other than that there is nothing more to do on installation!

Upgrade

It is recommended to upgrade the System after installation.

sudo dnf update --refresh

Snapper

Next step will be the installation of Snapper.

sudo dnf install snapper

Configure Subvolumes

List current configured subvolumes.

sudo btrfs sub list -p /
ID 257 gen 476204 parent 5 top level 5 path root
ID 258 gen 476203 parent 5 top level 5 path home

Start the snapper configuration for snapshots.

sudo snapper -c root create-config /

After creating the snapper configuration you should see somthing similar when list the subvolumes again.

sudo btrfs sub list -p /
ID 257 gen 476204 parent 5 top level 5 path root
ID 258 gen 476203 parent 5 top level 5 path home
ID 264 gen 475931 parent 5 top level 257 path .snapshots

This is not really that what we want since .snapshots is a sub-subvolume of root. This would result in the problem that if a rollback happens on a snapshot the subvolume root need to exist in order to perform the rollback. So that's why this is going to be changed now that snapshots can be mounted on the same level as root.

Remove the existing .snapshots subvolume and create a new mountpoint for snapshots.

sudo btrfs sub del /.snapshots/
sudo mkdir /.snaphshots

fstab

/etc/fstab

UUID=a8cad8fb-1fbf-424a-9b5e-cb8f8783ebe7 /                       btrfs   defaults     0 0
UUID=c41ea40c-b9d2-48f0-9d88-89c8927e5c3c /boot                   ext4    defaults        1 2
UUID=a8cad8fb-1fbf-424a-9b5e-cb8f8783ebe7 /home                   btrfs   defaults,subvol=home     0 0
UUID=a8cad8fb-1fbf-424a-9b5e-cb8f8783ebe7 /btrfs                  btrfs   defaults,subvolid=5     0 0
UUID=a8cad8fb-1fbf-424a-9b5e-cb8f8783ebe7 /.snapshots             btrfs   defaults,subvol=snapshots     0 0
UUID=acf953f1-bade-48c0-8298-5f12d3e53873 swap                    swap    defaults        0 0
  • /.snapshots gets a new entry with subvol=snapshots as option.
  • /btrfs gets a new entry with subvolid=5 as option. (mountpoint will be created afterwards)
  • /home gets the subvol=home option.

Mount points and subvolumes

Create the /btrfs mountpoint and a snapshots subvolume in the same level as root and home:

sudo mkdir /btrfs
sudo mount /btrfs
sudo btrfs sub cr /btrfs/snapshots
Create subvolume '/btrfs/snapshots'
sudo mount /.snapshots/

List current subvolumes:

sudo btrfs sub list -p /
ID 257 gen 476331 parent 5 top level 5 path root
ID 258 gen 476331 parent 5 top level 5 path home
ID 349 gen 475931 parent 5 top level 5 path snapshots

Set the default subvolume:

sudo btrfs sub get-default /
ID 5 (FS_TREE)

sudo btrfs sub set-default 257 /
sudo btrfs sub get-default /
ID 257 gen 476336 top level 5 path root

FINISH and 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment