Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Linux

Enable Booting from Snapshots in Linux Mint with BTRFS

One of the most powerful features of BTRFS is the ability to boot directly from snapshots, providing an excellent disaster recovery solution. After setting up BTRFS with proper subvolume structure, here’s how to enable snapshot booting in Linux Mint.

Installing grub-btrfs

The grub-btrfs utility automatically detects BTRFS snapshots and adds them to your GRUB menu:

git clone https://github.com/Antynea/grub-btrfs.git
cd grub-btrfs/
sudo make install
Configuring the Service

Configure the grub-btrfs daemon to work with Timeshift snapshots:

sudo systemctl edit --full grub-btrfsd

Modify the ExecStart line to:

ExecStart=/usr/bin/grub-btrfsd --syslog --timeshift-auto

This configuration automatically detects Timeshift snapshots without needing to specify a custom path.

Enabling the Service

Start and enable the service:

sudo systemctl restart grub-btrfsd
sudo systemctl enable grub-btrfsd
Updating GRUB Configuration

Finally, update your GRUB configuration to include the snapshots:

sudo grub-mkconfig -o /boot/grub/grub.cfg
How It Works
  • The grub-btrfsd service runs in the background, monitoring for new snapshots
  • Each time a snapshot is created (manually or via Timeshift schedules), it’s automatically added to the GRUB menu
  • On reboot, you’ll see additional boot entries for each available snapshot
  • Booting from a snapshot provides a perfect recovery option if system updates or changes cause issues
Important Notes
  • Ensure your BTRFS structure follows the recommended layout with separate subvolumes
  • Timeshift snapshots should be stored in the @snapshots subvolume at the BTRFS filesystem root
  • Regular GRUB updates are required to include newly created snapshots in the boot menu

This setup transforms your Linux Mint installation into a resilient system where any problematic change can be instantly reverted by simply rebooting into a previous snapshot.

Automating Snapshots with timeshift-autosnap-apt

To enhance my BTRFS snapshot strategy, I’ve implemented timeshift-autosnap-apt which automatically creates snapshots before APT operations.

Installation Process

Installed it from source because it’s not official, I did an enhancement request on the mint repo.

git clone https://github.com/wmutschl/timeshift-autosnap-apt.git /home/$USER/Applications/timeshift-autosnap-apt
cd /home/$USER/Applications/timeshift-autosnap-apt
sudo make install
How It Works
  • Automatically creates Timeshift snapshots before any APT operation (install, upgrade, remove)
  • Integrates seamlessly with existing APT commands - no changes to your workflow needed
  • Works in conjunction with your existing grub-btrfs setup for bootable snapshots
Benefits
  • Exactly when it’s most important, a snapshot is made
  • Automatic recovery points without manual intervention
  • Perfect complement to scheduled Timeshift snapshots
  • If an update breaks something, simply reboot into the pre-update snapshot

This tool combined with your existing BTRFS and grub-btrfs setup creates a robust, self-healing system similar to the one implemented in OpenSUSE Tumbleweed, made with zypper and snapper.

btrfs on Debian

Debian is awesome, nontheless some adjustments are needed. I restored my system to integrate btrfs and automatic snapshot. Just remember some pitfalls:

  • Automatic partitioning is going to use ext4, so work with gparted to prepare in advance all the partitions.
  • @ and @home subvolumes are generated automatically, then at first boot you’ll need to manually create at least a subvolume for /var/log and one for snapshots. If using Timeshift, then snapshots will go in /timeshift-btrfs mandatory. Beware to not create subvolumes inside the @ subvolume. To create them at top level, first mount @ on /mnt with sudo mount -t btrfs -o subvolid=5 /dev/sda3 /mnt then sudo btrfs subvolume create /mnt/@snapshots. Modify /etc/fstab accordingly UUID=xxx-yyy-zzz /timeshift-btrfs btrfs defaults,subvol=@snapshots 0 0. Do the same with @log.
  • Eventually other subvolume could be mounted for other well known directories, like /tmp or /opt.
  • Set Timeshift and use a backup utility for /home folder. Mint has one preinstalled.

keep the system running

Desktop distributions will likely sleep after 15 minutes on the login screen. A modern alternative approach for disabling suspend and hibernation is to create /etc/systemd/sleep.conf.d/sleep.conf as

[Sleep]
AllowSuspend=no
AllowHibernation=no
AllowSuspendThenHibernate=no
AllowHybridSleep=no