Skip to main content
In this comprehensive guide, you’ll learn how to build, manage, and optimize Btrfs (B-tree file system) volumes on Linux. We cover everything from one-device setups to multi-disk RAID configurations, subvolumes, snapshots, and transparent compression.

Btrfs Overview

Btrfs is a modern copy-on-write (COW) filesystem designed for Linux environments with large storage needs, multiple disks, or advanced snapshot requirements. Its core capabilities include:
When modifying data, COW filesystems write new data to free space, update metadata, then discard the old blocks. This preserves data integrity across crashes.
The image explains the difference between traditional filesystems and copy-on-write filesystems, highlighting how new data is written and managed. Traditional filesystems overwrite old data directly, while copy-on-write filesystems write new data to free space and update metadata before removing old data.

1. Creating a Btrfs Filesystem

1.1 Single-Device Setup

Initialize a simple Btrfs volume on /dev/sdb1:
Add a human-readable label:
Changing labels on a mounted filesystem can cause mount failures. Always unmount before relabeling.

1.2 Multi-Device & RAID Profiles

Expand a Btrfs pool across /dev/sdb and /dev/sdc:

2. Subvolumes

Subvolumes are independent namespaces within a Btrfs filesystem—each with its own snapshots and quotas.
  1. Mount the main volume:
  2. Create a subvolume named BKP:
  3. Verify the listing:
  4. Inspect subvolume metadata:

3. Mounting a Specific Subvolume

To mount BKP directly:

4. Snapshots

Snapshots capture a subvolume’s state at a specific point in time. They are instant, space-efficient, and independent from ongoing changes.

4.1 Create a Read-Write Snapshot

4.2 Verify & Test

Remove some files from the live subvolume:
Original data remains intact in the snapshot:

4.3 Read-Only Snapshots

Immutable snapshots prevent accidental writes:

5. Transparent Compression

Enable compression at mount time to reduce disk usage without manual compression commands.
The image lists three compression algorithms: ZLIB (default), LZO (faster but lower compression ratio), and ZSTD (faster with a similar compression ratio to ZLIB).

Additional Resources

Watch Video