What is Btrfs?

Btrfs (B-tree File System, pronounced “butter FS”) is a modern copy-on-write filesystem built directly into the Linux kernel. Under development since 2007, it’s now the default filesystem in Fedora, openSUSE, and Steam Deck.

Compared to ext4, it offers:

  • Snapshots — instant copies of the filesystem
  • Subvolumes — logical partitions without repartitioning
  • Transparent compression — saves space on the fly
  • Checksums — protection against silent data corruption
  • Built-in RAID — no need for mdadm or LVM

Unlike ZFS, Btrfs is part of the official kernel — no additional modules required.


Subvolumes

A subvolume is something between a directory and a partition. It looks like a regular folder but has its own snapshots, quotas, and mount options.

# Create a Btrfs filesystem
sudo mkfs.btrfs /dev/sdb

# Mount
sudo mount /dev/sdb /mnt

# Create subvolumes
sudo btrfs subvolume create /mnt/@
sudo btrfs subvolume create /mnt/@home
sudo btrfs subvolume create /mnt/@snapshots

# List subvolumes
sudo btrfs subvolume list /mnt

Mounting Subvolumes

Each subvolume can be mounted separately:

# In /etc/fstab:
# /dev/sdb  /      btrfs  subvol=@,compress=zstd  0 0
# /dev/sdb  /home  btrfs  subvol=@home,compress=zstd  0 0

sudo mount -o subvol=@ /dev/sdb /
sudo mount -o subvol=@home /dev/sdb /home

This way, a system snapshot doesn’t include the home directory and vice versa.


Snapshots

Snapshots in Btrfs are point-in-time images of a subvolume. Creation is instant thanks to the copy-on-write mechanism — data is not copied until it’s modified.

# Read-only snapshot (ideal for backup)
sudo btrfs subvolume snapshot -r /mnt/@ /mnt/@snapshots/@_2026-02-06

# Writable snapshot (e.g., for testing)
sudo btrfs subvolume snapshot /mnt/@ /mnt/@snapshots/@_test

# List snapshots
sudo btrfs subvolume list -s /mnt

# Delete a snapshot
sudo btrfs subvolume delete /mnt/@snapshots/@_test

Restoring from a Snapshot

# Rename the current subvolume
sudo mv /mnt/@ /mnt/@_broken

# Create a writable snapshot from backup
sudo btrfs subvolume snapshot /mnt/@snapshots/@_2026-02-06 /mnt/@

# Reboot — system returns to the snapshot state
sudo reboot

Automatic Snapshots with Snapper

snapper is a tool from SUSE that automates snapshots — it creates them before and after updates, and removes old ones according to a retention policy:

# Installation
sudo apt install snapper    # Debian/Ubuntu
sudo dnf install snapper    # Fedora

# Configure for root subvolume
sudo snapper -c root create-config /

# Manual snapshot
sudo snapper -c root create --description "before upgrade"

# List snapshots
sudo snapper -c root list

# Compare changes between snapshots
sudo snapper -c root diff 1..2

Compression

Btrfs supports transparent compression — files are compressed on write and decompressed on read.

# Enable zstd compression (recommended)
sudo mount -o compress=zstd /dev/sdb /mnt

# Or in /etc/fstab:
# /dev/sdb  /  btrfs  compress=zstd  0 0

Available algorithms:

  • zstd — best balance of performance and compression (recommended)
  • lzo — fastest, weakest compression
  • zlib — best compression, slowest
# Check compression ratio
sudo compsize /mnt

# Example output:
# Type       Perc     Disk Usage   Uncompressed
# TOTAL       68%       15G          22G
# zstd        68%       15G          22G

RAID in Btrfs

Btrfs has built-in RAID support — no mdadm or LVM needed:

# RAID1 (mirror) on two disks
sudo mkfs.btrfs -m raid1 -d raid1 /dev/sdb /dev/sdc

# RAID10 on four disks
sudo mkfs.btrfs -m raid10 -d raid10 /dev/sd{b,c,d,e}

# Add a disk to an existing filesystem
sudo btrfs device add /dev/sdd /mnt
sudo btrfs balance start -dconvert=raid1 -mconvert=raid1 /mnt

Warning: RAID5/6 in Btrfs has known issues and is not recommended for production. For RAID5/6, use ZFS or mdadm instead.


Btrfs vs ext4 vs ZFS

Feature ext4 Btrfs ZFS
In kernel Yes Yes No (module)
Copy-on-write No Yes Yes
Snapshots No Yes Yes
Compression No Yes Yes
Checksums Metadata Data + metadata Data + metadata
RAID No (mdadm) Built-in Built-in
RAM requirements Low Low High (8 GB+)
Maturity Very high High Very high

When ext4: simple server, laptop, proven stability

When Btrfs: snapshots, compression, desktop/laptop (Fedora, openSUSE)

When ZFS: large storage, NAS servers, critical data integrity


Useful Commands

# Filesystem information
sudo btrfs filesystem show
sudo btrfs filesystem df /mnt
sudo btrfs filesystem usage /mnt

# Scrub — data integrity verification
sudo btrfs scrub start /mnt
sudo btrfs scrub status /mnt

# Defragmentation
sudo btrfs filesystem defragment -r /mnt

# Filesystem check (offline)
sudo btrfs check /dev/sdb

Summary

Btrfs is a solid choice for anyone who wants a modern filesystem without installing additional modules. Snapshots, compression, and subvolumes make daily system management more convenient and safer. It’s no coincidence that Fedora, openSUSE, and Valve chose it as their default filesystem.