Guide: Fedora BTRFS grub snapshots
This guide is a step by step how to set up a fresh install of Fedora with BTRFS snapshotting through Timeshift. These snapshots are set up to be bootable from grub for easy disaster recovery and roll back. Remember - snapshots are not backup! Set up proper backups for your important data.
Install fedora⌗
Partition with Custom Blivet-gui
-
Delete all partitions on your drive
-
1st partition EFI
- Click on free space and click +
- Size 600 MB
- Filesystem : EFI System Partition
- Label : EFI
- Mount Point : /boot/efi
-
2nd partition BOOT
- Click on free space, click +
- Size : 1024 MB
- Filesystem : Ext4
- Label : BOOT
- Mount Point : /boot
-
For the rest of the disk we will make a BTRFS Volume.
- Click on free space and click +
- Filesystem : btrfs
- and click ok.
(If you’d like /home on a separate drive, just select it in the installer and label it @home)
- Now to make some btrfs sub-volumes.
- Click on btrfs partition and click +
- +log
- Name: @log
- Mount Point : /var/log
- +home
- Name: @home
- Mount Point : /home
- +/
- Name: @
- Mount Point: /
- +log
Continue the installation and reboot when complete.
Edit the fstab: sudo vim /etc/fstab
⌗
# edit ALL btrfs-volumes - add: defaults,noatime,discard=async
# from:
btrfs subvol=@,compress=zstd:1 0 0
# to:
btrfs subvol=@,compress=zstd:1,defaults,noatime,discard=async 0 0
Update the system + reboot after just to be sure.
sudo dnf update -y
Install grub-btrfs: git clone https://github.com/Antynea/grub-btrfs
⌗
cd grub-btrfs
vim config
GRUB_BTRFS_SUBMENUNAME="Fedora Linux snapshots"
GRUB_BTRFS_SNAPSHOT_KERNEL_PARAMETERS="rd.live.overlay.overlayfs=1" # uncomment
GRUB_BTRFS_IGNORE_SPECIFIC_PATH=("@") # already correct
GRUB_BTRFS_IGNORE_PREFIX_PATH=("var/lib/docker" "@var/lib/docker" "@/var/lib/docker") # already correct
GRUB_BTRFS_GRUB_DIRNAME="/boot/grub2" # uncomment
GRUB_BTRFS_BOOT_DIRNAME="/boot" # uncomment
GRUB_BTRFS_MKCONFIG=/usr/sbin/grub2-mkconfig # uncomment
GRUB_BTRFS_SCRIPT_CHECK=grub2-script-check # uncomment
Save the file, then in the same directory: sudo make install
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
-
Reboot again.
-
Install the tools:
sudo dnf install inotify-tools timeshift
to have the service running, monitoring for filesystem changes. -
Launch timeshift GUI, step through the wizard:
- pick BTRFS snapshot type
- select location
- select a schedule (can be changed later)
- (I also include @home in my snapshots)
-
Take a snapshot!
Edit the systemd-service and make sure the ExecStart line looks like below:⌗
sudo systemctl edit --full grub-btrfsd
ExecStart=/usr/bin/grub-btrfsd --syslog --timeshift-auto
Save it, then start the service:
sudo systemctl enable --now grub-btrfsd
systemctl status grub-btrfsd
- Reboot and check grub for a new submenu (named above as “Fedora Linux snapshots”).
- In the future, to roll back just select a previous snapshot from the boot menu and use timeshift to restore.