Displaying Snapshots in the Grub Menu on Fedora using Btrfs-Assistant and Grub-Btrfs

This tutorial is intended for Fedora systems installed with the default btrfs disk configuration. After performing these steps, you will be able to see and access snapshots via GRUB, but /boot partition will not be included in the snapshots because it is in EXT4 format by default in Fedora. Protect your /boot space really well!

1. Install Btrfs-Assistant and Enable Root Snapshots

First, install btrfs-assistant and enable the root snapshot feature. Take your first snapshot.

2. Install and Configure Grub-Btrfs

To display snapshots in the Grub menu, you'll need to install and configure grub-btrfs. Follow these steps:

git clone https://github.com/Antynea/grub-btrfs
cd grub-btrfs

Now, modify the grub-btrfs configuration file to make it work properly on Fedora:

sed -i '/#GRUB_BTRFS_SNAPSHOT_KERNEL/a GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="systemd.volatile=state"' config
sed -i '/#GRUB_BTRFS_GRUB_DIRNAME/a GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2"' config
sed -i '/#GRUB_BTRFS_MKCONFIG=/a GRUB_BTRFS_MKCONFIG=/sbin/grub2-mkconfig' config
sed -i '/#GRUB_BTRFS_SCRIPT_CHECK=/a GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check' config

Then, install grub-btrfs:

sudo make install

Update your grub.cfg and enable the grub-btrfsd.service:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg
sudo systemctl enable --now grub-btrfsd.service

Once done, you can remove the grub-btrfs folder:

cd ..
rm -rvf grub-btrfs

3. (Optional) Install DNF Plugin for Automatic Snapshots

If you want to automate snapshots when using dnf, install the python3-dnf-plugin-snapper:

sudo dnf install python3-dnf-plugin-snapper

4. Automatic Grub Update After Snapshots and Enable Scheduled Snapshots

For these features to work, we need to activate the following services:

Start and enable snapper-timeline.timer service:

sudo systemctl start snapper-timeline.timer && sudo systemctl enable snapper-timeline.timer

Start and enable snapper-timeline.timer service for scheduled cleanups:

sudo systemctl start snapper-cleanup.timer && sudo systemctl enable snapper-cleanup.timer

Install inotify-tools to monitor changes:

sudo dnf install inotify-tools

Finally, restart the grub-btrfsd service:

sudo systemctl restart grub-btrfsd

Now you can see the snapshots taken on the grub screen.

4. A little information about the restoration process

Since we do not create the sub-volume structure manually, you will get an error with rollback commands when you login the system from grub. But this is not a problem. We can perform the restore operation through Btrfs Assistant.

After accessing the operating system, open the Btrfs Assistant GUI and select the snapshot you want to rollback and perform the restore operation and then reboot the system:

Important notice: As I mentioned at the beginning, EXT4 /boot area is not included in snapshots, so if there is a file deleted from boot area, you will not be able to boot with snapshots.

System will boot as usual with the snapshot you selected.

Now rebuild Grub and reactivate any services that may have been disabled:

sudo grub2-mkconfig -o /boot/grub2/grub.cfg

sudo systemctl enable --now grub-btrfsd.service

sudo systemctl start grub-btrfsd

sudo systemctl start snapper-timeline.timer && sudo systemctl enable snapper-timeline.timer

sudo systemctl start snapper-cleanup.timer && sudo systemctl enable snapper-cleanup.timer

Thanks to sysguides.com article for the detailed explanation and inspiration.