How to Set Up Btrfs Subvolumes and Snapshots on Fedora

Create Btrfs subvolumes and snapshots on Fedora using the btrfs subvolume create and snapshot commands.

When a broken upgrade needs an undo button

You ran dnf upgrade and the system rebooted into a login loop. Or you edited a config file and now your desktop environment crashes on startup. You need to revert the change without reinstalling. Btrfs snapshots let you roll back the filesystem to a previous state in seconds. This is how you create subvolumes and snapshots on Fedora to protect your data and recover from mistakes.

Snapshot before you break. A broken system is easy to fix when you have a known-good state.

How Btrfs copies-on-write protects you

Btrfs treats data as blocks rather than files. When you modify a file, Btrfs doesn't overwrite the old blocks. It writes the new data to fresh blocks and updates the metadata to point to them. The old blocks stay on disk until they are reclaimed. A snapshot is just a copy of the metadata tree at a specific moment. Because the data blocks are shared until modified, snapshots take almost no space initially.

Think of a snapshot like a bookmark in a book. The bookmark doesn't copy the pages. It just marks where you were. If you keep reading, the bookmark stays at the old page. If you tear out a page, the bookmark still points to the original content. Btrfs works the same way. The snapshot points to the old metadata. Changes after the snapshot write new data, leaving the snapshot view intact.

Trust the copy-on-write mechanism. Your data is safe until you explicitly delete the snapshot.

Creating subvolumes and snapshots

Fedora Workstation installs with a Btrfs root filesystem by default. The layout uses subvolumes to separate the root filesystem from user data. The root subvolume is usually named @ and mounted at /. The home subvolume is named @home and mounted at /home.

Fedora's default layout puts the root subvolume at @. Check /etc/fstab to see the subvol=@ option. This tells the kernel which subvolume to mount as root. Always verify the layout before creating new subvolumes to avoid confusion.

Here's how to inspect your current Btrfs layout and identify the subvolume IDs.

# List all subvolumes on the root filesystem to see the default Fedora layout
sudo btrfs subvolume list /
# The output shows ID, generation, and path for each subvolume
# Note the ID of the root subvolume, usually 5 or 257

Here's how to create a new subvolume for safe experimentation or isolation.

# Create a new subvolume for testing configuration changes
sudo btrfs subvolume create /tmp/test-subvol
# Verify the new subvolume exists and check its object ID
sudo btrfs subvolume list /tmp/test-subvol
# The subvolume is now a directory you can use like any other folder

Here's how to create a writable snapshot of your root filesystem.

# Create a writable snapshot of the root subvolume at /snapshots/root-snap
sudo btrfs subvolume snapshot / /snapshots/root-snap
# The snapshot is fully writable and acts like a normal directory
# Changes here do not affect the original / subvolume

Here's how to create a read-only snapshot to preserve a state without risk of modification.

# Create a read-only snapshot to lock the current state
sudo btrfs subvolume snapshot -r / /snapshots/root-snap-ro
# The -r flag prevents any writes to this snapshot
# Attempting to modify files here will return Permission denied

Run btrfs subvolume list after every operation. Verify the ID and flags before proceeding.

Restoring from a snapshot on Fedora

Creating a snapshot is only half the battle. You need to know how to switch to it. The safest method on Fedora is to mount the snapshot and copy files back. If you need a full rollback, you can change the default subvolume, but this requires care with the mount options.

Here's how to change the default subvolume to restore a snapshot on the next boot.

# Find the object ID of the snapshot you want to restore
sudo btrfs subvolume list /snapshots
# Set the snapshot as the default subvolume for the next boot
sudo btrfs subvolume set-default <ID> /
# Reboot the system to activate the restored state
sudo reboot

Changing the default subvolume affects how the kernel mounts the filesystem. Fedora's /etc/fstab often contains subvol=@ in the root mount options. If you set a new default subvolume that isn't named @, the mount might fail because the kernel tries to mount the default subvolume, but fstab asks for @.

Update /etc/fstab if you change the default subvolume. A mismatch between the kernel default and fstab will drop you to an emergency shell.

Common errors and mount traps

Btrfs snapshots require the source and destination to reside on the same filesystem. You cannot snapshot /home to /var if they are on different mount points. If you try, the command fails with ERROR: not a subvolume or ERROR: cross-device link. Check your mount points with findmnt.

Here's how to verify that two paths are on the same Btrfs filesystem.

# Check the filesystem type and mount point for both paths
findmnt -n -o SOURCE,FSTYPE,TARGET / /var
# Both paths must show the same SOURCE device and FSTYPE btrfs
# If they differ, you cannot create a snapshot between them

Another common error occurs when you try to snapshot a regular directory instead of a subvolume. Btrfs only snapshots subvolumes. If you see ERROR: not a subvolume, the path is just a directory inside a subvolume, not a subvolume itself.

Check the mount point. Snapshots across filesystems are impossible.

Choosing the right approach

Use writable snapshots when you want to test a configuration change and revert by swapping the default subvolume. Use read-only snapshots when you need a backup point that cannot be accidentally modified. Use subvolumes when you want to isolate a directory tree for independent quota or snapshot management. Use btrfs send and btrfs receive when you need to replicate snapshots to another drive or machine. Stay on the default Fedora layout if you only need occasional rollbacks and don't want to manage mount options manually.

Where to go next