Using Btrfs Snapshots with Snapper for System Rollback on Fedora
Configure Fedora's Btrfs root filesystem to create automatic snapshots and roll back unwanted changes using the snapper tool.
28 Sept 2025, 17:46 UTC

Problem: Quickly undo system changes after updates or configuration mistakes
When a package update breaks a service or a manual edit leaves the system in an undesired state, reinstalling or manually reverting files is time‑consuming. Fedora can be installed with Btrfs as the root filesystem, which provides built‑in snapshot capabilities. Combined with the snapper tool, you can create automatic snapshots and roll back the entire system to a previous known‑good state.
Solution: Install Fedora with Btrfs, configure snapper, and use snapshots for rollback
1. Install Fedora using Btrfs as the root filesystem
During the Fedora installer’s storage selection, choose “Custom” partitioning and set the root (/) to Btrfs. Create two subvolumes:
@– mounted at/@home– mounted at/home
The installer will automatically mount these subvolumes with the appropriate subvol options.
2. Install and initialize snapper
After the first boot, install the snapper package and create a configuration for the root filesystem:
# Run as root or with sudo
dnf install snapper
snapper -c root create-config /
This creates a config file /etc/snapper/configs/root that defines which subvolume is snapshotted (the @ subvolume).
3. Enable automatic timeline snapshots
Snapper ships with a systemd timer that creates hourly, daily, weekly, and monthly snapshots. Enable and start it:
systemctl enable --now snapper.timer
You can verify the timer is active with systemctl status snapper.timer.
4. List existing snapshots
To see what snapshots are available:
sudo snapper list
The output shows columns for # (snapshot number), Type, Pre/Post, Date, and User. Timeline snapshots appear as single type.
5. Perform a rollback to a previous snapshot
If you need to revert the system to snapshot number 42, run:
sudo snapper rollback 42
This command sets the default subvolume to the snapshot’s state and creates a new snapshot of the current state before the rollback, allowing you to roll forward later if needed. After the command completes, reboot the system:
sudo reboot
6. Roll forward (undo a rollback)
If you booted into the rolled‑back state and decide you want to return to the state before the rollback, list snapshots again and roll back to the snapshot that was created just before the rollback (usually the highest number).
Limits and considerations
- Space consumption: Each snapshot stores only the data that has changed since the snapshot was taken. Heavy write workloads (e.g., frequent database updates, large log files) can cause the Btrfs volume to fill quickly. Monitor free space with
df -hT /and ensure at least 10‑20 % remains available for snapshots. - Exclude volatile directories: Directories that change constantly but do not need to be rolled back (such as
/var/lib/mysql,/var/log, or/tmp) should be excluded from snapshots to save space. Edit the snapper config (/etc/snapper/configs/root) and setSPACE_LIMITor addEXCLUDE_PRE/EXCLUDE_POSTpatterns. - Timer dependency: If
snapper.timeris disabled, no automatic snapshots are taken. Verify the timer is active after reboots or system updates. - Subvolume layout: Mixing custom subvolume layouts (e.g., creating additional subvolumes outside of
@and@home) without updating snapper configs can lead to mount‑point errors or snapshots that do not include expected data. Stick to the installer’s recommended layout unless you have a specific reason to adjust it. - Rollback scope: Rolling back reverts the entire root subvolume to the snapshot’s state. Any data stored outside of snapshotted subvolumes (e.g., a separate
/varpartition not using Btrfs, or directories explicitly excluded) will not be reverted and may become inconsistent with the rolled‑back system state.
Common mistakes to avoid
- Assuming snapshots are infinite – regularly prune old snapshots (
sudo snapper delete) or adjust cleanup algorithms in the config to prevent the volume from filling. - Disabling
snapper.timerafter installation and wondering why no snapshots appear. - Attempting to roll back while the system is low on free space; the rollback may fail or leave the filesystem in a degraded state. Always check free space before initiating a rollback.
- Using
snapper rollbackon a system where the root subvolume is not Btrfs (e.g., after accidentally reinstalling with ext4). Verify the filesystem type first.
Verification steps
- Confirm the root filesystem is Btrfs:
Expected output showsdf -T /btrfsin theTypecolumn. - List snapshots to ensure the timer is creating them:
Look for recentsudo snapper listsingleentries with timestamps. - Perform a test rollback to a non‑critical snapshot (e.g., the most recent one before a known change), reboot, and verify that the system boots and the expected files are reverted. You can then roll forward to the latest snapshot if the test was successful.
By following the steps above, Fedora administrators can leverage Btrfs’s native snapshot capabilities together with snapper to obtain a reliable, low‑overhead method for rolling back system changes. Regular monitoring of free space and snapshot cleanup ensures the technique remains practical over time.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.