How to Configure Timeshift, Btrfs Snapshots, and Automated Rollbacks on Ubuntu Desktop

System updates, kernel upgrades, and proprietary graphics driver installations on Linux workstations occasionally introduce regression bugs, kernel panics, or broken display managers. On traditional ext4 filesystems, restoring an operating system to a known good state requires restoring full disk images from external backup media—a slow and disruptive procedure. In contrast, the modern Linux Copy-on-Write (CoW) filesystem, Btrfs, provides atomic, instantaneous filesystem snapshots that occupy zero additional disk space upon creation.

By pairing Btrfs subvolumes with Timeshift and the grub-btrfs bootloader module on Ubuntu Desktop, system administrators and developers can establish an automated snapshot protection pipeline. This architecture automatically freezes the system state before package upgrades and injects bootable snapshot entries directly into the GRUB boot menu, enabling instant recovery even if the primary operating system fails to boot.


Architectural Overview: Btrfs Copy-on-Write vs RSYNC Hardlinks

Timeshift supports two distinct operational modes: RSYNC and BTRFS. Understanding the fundamental architectural differences between these two modes is vital for deployment planning.

Operational Metric RSYNC Mode Btrfs Native Snapshot Mode
Filesystem Requirement Any standard filesystem (ext4, XFS, NTFS) Btrfs with standard @ and @home subvolumes
Creation Speed Slow; minutes to hours (file-by-file hardlink indexing) Instantaneous; sub-second atomic metadata pointer freeze
Disk Space Consumption Duplicated directory inodes and metadata tables Zero incremental bytes at creation; uses Copy-on-Write
Pre-Update Apt Hooks Impractical; stalls package upgrades for minutes Seamless; snapshots system in under 200 ms during apt triggers
Bootloader Integration Not supported at GRUB level Native bootable snapshot selection via grub-btrfs

Under Btrfs, an atomic snapshot is not a file copy. Instead, the Btrfs tree allocator freezes root inode pointers. As subsequent packages write modified binaries to disk, only newly modified data blocks consume additional storage capacity, preserving historical states with minimal resource overhead.


Verifying Ubuntu Subvolume Layout and Mounts

Timeshift requires a specific naming convention for root filesystems: the root directory must reside within a Btrfs subvolume named @, while the user home directory typically resides within @home.

Open a terminal on your Ubuntu system and inspect the active mount table and subvolume hierarchy:

# Inspect active root filesystem type and mount options
findmnt / -o TARGET,SOURCE,FSTYPE,OPTIONS

# List active Btrfs subvolumes on the primary drive
sudo btrfs subvolume list /

Confirm that the output indicates subvol=@ for the root mount point. Standard Ubuntu installations partitioned with Btrfs format this structure automatically:

ID 256 gen 4820 top level 5 path @
ID 257 gen 4819 top level 5 path @home

Installing and Configuring Timeshift

Timeshift is maintained in official Ubuntu repositories and can be administered via graphical interface or the command line.

Step 1: Install Timeshift and Required Kernel Tools

# Update local package indexes
sudo apt update

# Install Timeshift and Btrfs administration utilities
sudo apt install -y timeshift btrfs-progs

Step 2: Configure Snapshot Retention Profiles

Launch Timeshift from your application menu or configure it directly via terminal. When prompted by the Setup Wizard:

  1. Select BTRFS as the Snapshot Type, then click Next.
  2. Select the target partition hosting your Ubuntu installation (e.g. /dev/nvme0n1p2).
  3. Define automated retention schedules:
    • Boot: Retain 3 to 5 snapshots (captures clean states after system reboots).
    • Daily: Retain 5 snapshots.
    • Hourly: Optional; disable unless testing active development stacks.
  4. Under User Home Directories, ensure @home is excluded. Snapshots are designed to protect operating system binaries and configuration libraries. Including personal user folders risks rolling back recent documents, browser downloads, and work files during a system recovery.
  5. Click Finish to commit configuration.

Automating Snapshots with APT Package Hooks

To ensure total rollback capabilities, configure Ubuntu to capture an atomic Btrfs snapshot automatically every time apt upgrade, apt install, or apt remove is executed.

Step 1: Install timeshift-autosnap-apt

Create an automated DPkg hook script to intercept package manager transactions:

# Install git and make dependencies
sudo apt install -y git make

# Clone the automated apt snapshot trigger
git clone https://github.com/wmutschl/timeshift-autosnap-apt.git /tmp/timeshift-autosnap-apt

# Execute the local installation script
cd /tmp/timeshift-autosnap-apt && sudo make install

Step 2: Customise the Hook Configuration

Inspect and edit the hook parameters:

sudo nano /etc/timeshift-autosnap-apt.conf

Ensure the following parameters are enforced:

# Maximum number of automated APT snapshots to keep
maxSnapshots=10

# Update GRUB boot menu automatically after capturing snapshot
updateGrub=true

# Snapshot description prefix
snapshotDescription={counter} at {date} {time} before apt transaction

Save and exit. From this point forward, executing sudo apt upgrade triggers a sub-second snapshot creation before unpacking packages, guaranteeing a clean pre-update restore point.


Configuring GRUB Bootloader Rollback Menus (grub-btrfs)

If an update renders your desktop unbootable (such as a black screen caused by an incompatible graphics driver or a kernel regression), you must be able to boot into a previous snapshot without accessing a desktop environment. The grub-btrfs package automatically detects Timeshift snapshots and generates bootloader submenu entries.

Step 1: Install grub-btrfs

# Install grub-btrfs from source or packaging repository
sudo apt install -y inotify-tools

git clone https://github.com/Antynea/grub-btrfs.git /tmp/grub-btrfs
cd /tmp/grub-btrfs && sudo make install

Step 2: Enable Systemd Inotify Daemon for Auto-Updates

Activate the background daemon so that GRUB’s menu configuration regenerates the moment a new snapshot is created:

# Enable and start the grub-btrfs inotify monitoring unit
sudo systemctl enable --now grub-btrfsd.service

# Manually generate initial GRUB snapshot submenu
sudo update-grub

Upon rebooting, your GRUB bootloader will display a new top-level entry: Ubuntu snapshots. Expanding this menu reveals all timestamped restore points with their kernel parameters.


Executing System Restores via Command Line

While the graphical interface is intuitive, system recoveries are frequently conducted from a recovery shell, live USB environment, or SSH session.

Creating a Manual Snapshot

# Create on-demand snapshot with descriptive tag
sudo timeshift --create --comments "Prior to custom kernel compilation" --tags D

Listing Available Snapshots

# Inspect all available snapshots, UUIDs, and tags
sudo timeshift --list

Restoring a System State

# Trigger non-interactive terminal restoration
sudo timeshift --restore --snapshot '2026-10-23_14-30-00' --target /dev/nvme0n1p2 --skip-grub

Follow the on-screen prompts to confirm target partition assignments. Once complete, reboot the workstation to initialize the restored root subvolume.


Troubleshooting Common Timeshift Btrfs Faults

Symptom Underlying Cause Remediation Procedure
Timeshift returns error: “Selected BTRFS disk does not have subvolume layout (@ and @home)” Root filesystem mounted as flat Btrfs root rather than nested @ subvolume Boot from Ubuntu Live USB. Mount root Btrfs filesystem, create @ subvolume, move all root files into @, and update /etc/fstab to reference subvol=@.
GRUB boot menu does not show snapshot options upon restart grub-btrfsd.service inactive or GRUB hidden timeout active Verify service status with systemctl status grub-btrfsd. In /etc/default/grub, set GRUB_TIMEOUT_STYLE=menu and GRUB_TIMEOUT=5, then execute sudo update-grub.
Physical disk space fills rapidly despite minimal new user files Accumulated Btrfs snapshots retaining deleted large files and database logs Inspect snapshot consumption: sudo btrfs filesystem usage /. Open Timeshift and delete obsolete daily snapshots, or enforce strict limits in retention settings.
System boots into read-only mode after snapshot restoration SELinux / AppArmor context mismatch or stale filesystem mount UUIDs in fstab Boot with rw kernel parameter appended in GRUB. Ensure /etc/fstab uses filesystem UUIDs rather than transient block device names.

System Maintenance and Operational Governance

  • Keep User Data Isolated: Reaffirm that user documents, virtual machine images, and large container caches reside outside the root @ subvolume. This prevents accidental rollbacks of user work during OS restorations.
  • Run Btrfs Scrubs Periodically: Schedule monthly background filesystem scrubs to detect and auto-repair bitrot: sudo btrfs scrub start /. Check status with sudo btrfs scrub status /.
  • Validate Live USB Rollbacks: Maintain a bootable Ubuntu Live USB stick equipped with Timeshift. In the event of catastrophic bootloader corruption, booting into the live environment enables immediate point-in-time restoration within minutes.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.