Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

What Copy-on-Write Means

A classic file system changes a block in place. Btrfs writes the changed data to a new place and then updates the pointers to it. The old version stays intact until nothing refers to it any more. This is what makes snapshots instant: a snapshot is a second set of pointers to the same blocks, and only blocks changed later take extra space.

Main Features

  • Subvolumes: separate directory trees inside one file system, each with its own snapshots, sharing the same pool of space.
  • Snapshots: instant copies of a subvolume, read-only or writable.
  • Checksums and scrub: every data and metadata block is checksummed; a scrub reads everything and repairs bad blocks from a second copy where one exists.
  • Compression: transparent, with zstd, lzo, or zlib.
  • Send and receive: streams a snapshot, or the difference between two, to another Btrfs file system.
  • Several devices: one file system across disks, with profiles such as raid1 and raid10.

The State of RAID 5 and 6

The Btrfs documentation marks its RAID 5 and RAID 6 profiles as unstable and says they should not be used in production, mainly because of the write hole: it has no write journal for them. The raid1, raid10, raid1c3, and raid1c4 profiles are marked stable and are the ones in common production use. Read the project's current status page before planning parity RAID on Btrfs; for that job, ZFS RAID-Z or Linux md RAID 6 is the usual choice.

Where It Is Used

  • Default: openSUSE and SUSE use it for the root file system, and Fedora's desktop editions use it by default.
  • Available: Ubuntu and Debian ship it in their kernels and install ext4 by default. The tools are in the btrfs-progs package.
  • RHEL family: Red Hat removed Btrfs from RHEL 8 onward, so the stock kernels of Rocky Linux and AlmaLinux 9 do not include it. AlmaLinux added Btrfs to its kernel and installer in version 10.1.

Basic Commands

Warning: mkfs.btrfs erases the device you name. Back up anything on it and confirm the name with lsblk first.

sudo mkfs.btrfs -L data /dev/sdb
sudo mkdir -p /mnt/data
sudo mount -o compress=zstd /dev/sdb /mnt/data

Create a subvolume and a read-only snapshot of it:

sudo btrfs subvolume create /mnt/data/www
sudo btrfs subvolume snapshot -r /mnt/data/www /mnt/data/www-2026-11-30
sudo btrfs subvolume list /mnt/data

Check space and data integrity:

sudo btrfs filesystem usage /mnt/data
sudo btrfs scrub start /mnt/data
sudo btrfs scrub status /mnt/data

To mount it at boot, add the file system's UUID with the same options to fstab, as shown in fstab explained.

Send and Receive

Send needs a read-only snapshot. This copies one to a second Btrfs disk mounted at /mnt/backup:

sudo btrfs send /mnt/data/www-2026-11-30 | sudo btrfs receive /mnt/backup/

For the next run, -p names the previous snapshot as parent, and only the difference is sent. A copy on another disk in the same server still shares its fate, so send to another machine as well.

Why df Can Mislead

Btrfs reserves space in chunks, separately for data and for metadata. A raid1 profile stores everything twice, compression makes files take less than their size, and snapshots share blocks. The numbers in df cannot show all of that, and a file system can report "No space left on device" while df still shows space, when the metadata chunks are full. Use btrfs filesystem usage, which shows allocated and used space per type. Rewriting half-empty data chunks often helps:

sudo btrfs balance start -dusage=50 /mnt/data

When to Use It

Btrfs fits a system disk on which you want snapshots before updates, and data where checksums and compression help. For a plain server with no need for those features, ext4 or XFS is simpler: see ext4 vs XFS. For storage servers with parity RAID, compare it with ZFS in ZFS vs Btrfs and what is ZFS. Snapshots on the same disk are not backups; the difference is in snapshot vs backup.

Was this answer helpful?
Loading...