Blog » Linux » How to Use Btrfs on Linux: Subvolumes, Snapshots, and Compression
› how-to-use-btrfs-on-linux Terminal showing Btrfs subvolume and snapshot commands on a Linux system in a cozy homelab setup

How to Use Btrfs on Linux: Subvolumes, Snapshots, and Compression

Table of Contents

If you want to learn how to use Btrfs on Linux, you’re in the right place. I’ve been running Btrfs across my homelab for years now, and it has saved my bacon more times than I can count. In this guide I’ll walk you through the parts of Btrfs that actually matter day-to-day: subvolumes, snapshots, transparent compression, and the maintenance commands you should know.

Terminal showing Btrfs subvolume and snapshot commands on a Linux system in a cozy homelab setup

This isn’t a dry man-page rehash. I’ll show you the exact commands I run, the layout I use on every fresh install, and a couple of mistakes I made early on so you don’t repeat them.

Quick answer: To use Btrfs on Linux, format a drive with mkfs.btrfs, mount it with compress=zstd:1,noatime, create subvolumes like @, @home, and @snapshots, then take read-only snapshots with btrfs subvolume snapshot -r. Run btrfs scrub monthly to catch silent corruption.

What Is Btrfs and Why Should You Care?

Btrfs (pronounced “butter-FS” or “better-FS” depending on which IRC channel you hang out in) is a modern B-tree filesystem built around copy-on-write. Chris Mason started it back at Oracle, and it has matured into one of the most capable filesystems in the Linux kernel.

The official Btrfs official documentation covers every flag and corner case, but the short version is this: Btrfs gives you snapshots, compression, checksums, and online resize without bolting on LVM or a separate volume manager.

RackNerd Mobile Leaderboard Banner

Get a VPS from as low as $11/year! WOW!

Key Features That Set Btrfs Apart

  • Copy-on-write (CoW): Data is never overwritten in place. New writes go to new blocks, which is what makes snapshots instant.
  • Checksums on data AND metadata: Btrfs catches silent bitrot that ext4 and XFS will happily ignore.
  • Subvolumes: Independently mountable namespaces inside a single pool.
  • Transparent compression: zstd, lzo, or zlib at the filesystem level.
  • Online resize and multi-device support: No unmount required.

Which Distros Use Btrfs by Default?

Btrfs isn’t some hipster experiment anymore. Fedora’s decision to adopt Btrfs as its default filesystem in Fedora 33 (2020) was a big deal. openSUSE and SUSE Linux Enterprise have shipped it as default since 2014. And Meta runs Btrfs on every OS and data volume in their fleet at petabyte scale.

That last fact is the one I lean on when somebody tells me Btrfs “isn’t ready for production.” If it’s good enough for Facebook’s infrastructure, it’s good enough for your homelab.

Creating a Btrfs Filesystem

Let’s start with the basics. You need a drive (or partition) and the btrfs-progs package. On Ubuntu 24.04 and most current distros, btrfs-progs is already installed.

Step 1: Identify Your Target Drive with lsblk

Before you touch mkfs, confirm you know which device you’re formatting. I lost a partition once because I trusted muscle memory instead of checking. Never again.

lsblk -f

This shows every block device with its current filesystem. If you want a deeper walkthrough, I wrote a full guide on the lsblk command. If you need to partition the drive first, see my guide on partitioning your disk with fdisk.

Step 2: Format with mkfs.btrfs

Once you know your device name (let’s say /dev/sdb1), formatting is one command:

sudo mkfs.btrfs -L 'data' /dev/sdb1

The -L sets a filesystem label. I always label mine. Future-you will thank present-you when you’re staring at six unlabeled disks at 2 AM.

Step 3: Mount Btrfs and Understand Key Mount Options

Make a mount point and mount it with the options that actually matter:

sudo mkdir /mnt/btrfs
sudo mount -o compress=zstd:1,noatime,autodefrag /dev/sdb1 /mnt/btrfs

Here’s what each option does:

  • compress=zstd:1: Transparent zstd compression at level 1. Excellent ratio, near-zero CPU cost.
  • noatime: Stops updating access times on every read. Big SSD win.
  • autodefrag: Background defrag for files that get small random writes (databases, log files).

For deeper coverage of the mount step itself, see my full walkthrough on mounting a disk in Linux.

Working with Btrfs Subvolumes

Here’s where Btrfs starts to feel like magic. Subvolumes are one of the killer features and the reason I run Btrfs on every machine I own.

What Is a Subvolume (And Why You Need Them)

A subvolume is an independently mountable filesystem namespace inside a single Btrfs pool. Think of it as a directory that behaves like its own filesystem — it can be mounted separately, snapshotted independently, and excluded from parent snapshots.

That last part is critical. Snapshots stop at subvolume boundaries by default. So if you put /home in its own subvolume, a snapshot of your root won’t drag along 400GB of family photos. Clean rollbacks become possible.

Creating and Listing Subvolumes

sudo btrfs subvolume create /mnt/btrfs/@
sudo btrfs subvolume create /mnt/btrfs/@home
sudo btrfs subvolume create /mnt/btrfs/@snapshots
sudo btrfs subvolume list /mnt/btrfs

The Standard Subvolume Layout: @, @home, @snapshots

The @ naming convention is the de facto standard on Arch Linux and openSUSE. It’s not required by the kernel — it’s just a convention that makes life easier.

  • @: Mounted at / (your root filesystem).
  • @home: Mounted at /home.
  • @snapshots: Mounted at /.snapshots (where snapshots live).

The big reason to split @home from @ is rollback safety. If a system update breaks the root, you roll back @ without nuking your home directory. We’ll cover that workflow in the snapshots section below — that’s a hook I’m leaving for you.

Persisting Subvolume Mounts via /etc/fstab

To make subvolume mounts survive a reboot, add them to /etc/fstab with the subvol= option:

UUID=xxxx-xxxx / btrfs subvol=@,compress=zstd:1,noatime 0 0
UUID=xxxx-xxxx /home btrfs subvol=@home,compress=zstd:1,noatime 0 0
UUID=xxxx-xxxx /.snapshots btrfs subvol=@snapshots,compress=zstd:1,noatime 0 0

If /etc/fstab still feels like dark magic, I wrote a beginner-friendly guide on configuring /etc/fstab on Linux. Read it before you reboot — a broken fstab will drop you into emergency mode faster than you can say “I should have tested this in a VM.”

Taking and Managing Snapshots

Now we get to the part of Btrfs that has personally saved me from disaster more than once.

A few years back I ran a routine pacman -Syu on my main Arch box. Halfway through the upgrade, the GRUB package mid-installed itself into oblivion. Reboot, black screen, panic. Except I had taken a Btrfs snapshot ten minutes earlier. One reboot into a live ISO, two btrfs subvolume commands, and I was back in business in under five minutes. That moment converted me for life.

Read-Only vs Writable Snapshots: Which to Use When

Btrfs has two snapshot flavors. Use them differently:

  • Read-only snapshots: Use for backups, audit points, and rollback sources. The -r flag.
  • Writable snapshots: Use for testing environments, branching off a known-good state to experiment.

Creating Your First Snapshot

The read-only flavor is what you want for safety:

sudo btrfs subvolume snapshot -r /mnt/btrfs/@ /mnt/btrfs/@snapshots/@-$(date +%Y%m%d-%H%M)

Snapshots are instant and take essentially zero extra disk space at creation time. That’s the copy-on-write magic — Btrfs just adds a new reference to the existing data blocks. Nothing is duplicated until you actually modify the original.

Rolling Back to a Snapshot (The Part Most Guides Skip)

Most tutorials stop at “here’s how to make a snapshot.” Cool, but how do you actually use it? Here’s the workflow:

  1. Boot from a live USB (you can’t roll back the root subvolume while it’s mounted as root).
  2. Mount the top-level Btrfs volume: mount /dev/sdb1 /mnt
  3. Move the broken subvolume aside: mv /mnt/@ /mnt/@broken
  4. Create a writable copy of the snapshot as the new root: btrfs subvolume snapshot /mnt/@snapshots/@-20260128-1430 /mnt/@
  5. Unmount and reboot.

That’s the entire rollback. No reinstalling. No restoring from a backup tarball. Just a rename and a snapshot.

Automating Snapshots with a Systemd Timer

You can install Snapper or Timeshift if you want a GUI, but honestly a 10-line shell script plus a systemd timer is all you need. I wrote a deeper guide on systemd timers that walks through the exact unit file structure.

The basic recipe: a .service unit that runs btrfs subvolume snapshot -r, a matching .timer unit firing daily, and a small cleanup script to prune snapshots older than 30 days.

And a critical reminder — snapshots are not backups. If your drive dies, your snapshots die with it. Pair Btrfs snapshots with rsync for off-site backups, or follow my full guide on setting up automatic backups on Linux. Read-only snapshots actually make beautiful rsync sources — they’re frozen in time, so you get consistent backups.

Enabling Transparent Compression with Zstd

If you skip everything else in this article, do not skip this section. Btrfs zstd compression is one of the easiest wins in modern Linux storage.

Why Btrfs Compression Is a No-Brainer for Most Workloads

Compression at zstd:1 on my own daily-driver workstation saves roughly 40% on my root partition compared to an uncompressed ext4 install. That number tracks with what the Fedora Project has measured across their default installs.

Better yet, compression reduces write amplification on SSDs. Fewer bytes on disk means fewer write cycles, which directly extends SSD lifespan. This is the angle most Btrfs guides bury, and it’s the one I think about most.

How to Enable zstd at Mount Time

Add it to your fstab mount options:

compress=zstd:1

That’s it. New writes get compressed transparently. To compress data that’s already on disk, run:

sudo btrfs filesystem defragment -r -czstd /mnt/btrfs

Real-World Space Savings: The Numbers

Recent kernels made compression even better. Linux 6.15 adds fast Zstd compression levels to Btrfs — negative levels from -1 down to -15 that trade some ratio for blistering speed. If your workload is latency-sensitive, try compress=zstd:-5 and benchmark it on your data.

Essential Btrfs Maintenance Commands

Btrfs is mostly self-managing, but there are three commands you should know.

Scrubbing: Verify and Repair Data Integrity

This is Btrfs’s superpower. A scrub reads every block on the filesystem and verifies it against the stored checksum. If a block is corrupt and you have redundancy (RAID1, DUP metadata, etc.), Btrfs repairs it from the good copy.

sudo btrfs scrub start /mnt/btrfs
sudo btrfs scrub status /mnt/btrfs

Run a scrub at least monthly. I have mine on a systemd timer that fires the first Sunday of every month at 3 AM.

Checking Filesystem Usage with btrfs fi df

The standard df command lies on Btrfs. It can’t see compression, deduplication via snapshots, or chunk allocation. Use the Btrfs-native version instead:

sudo btrfs filesystem df /mnt/btrfs
sudo btrfs filesystem usage /mnt/btrfs

The same caveat applies to the du command — shared extents between snapshots make it report inflated numbers.

Balancing: Why and When to Run It

Balance redistributes data across chunks (and across devices in multi-disk setups). You need it after adding or removing a disk, and occasionally after a filesystem fills up and then frees lots of space.

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

The -dusage=50 filter only rebalances data chunks that are less than 50% full. Faster, less I/O, and almost always what you want.

When to Use Btrfs (And When to Stick with ext4)

I love Btrfs, but I’m not going to pretend it’s the right answer for every workload. Here’s my honest take.

Use Btrfs for:

  • Desktops and laptops where you want easy rollback.
  • Homelabs and home servers — snapshots alone justify the switch.
  • NAS builds — see my best Linux NAS software roundup; both Synology DSM and OpenMediaVault lean on Btrfs natively.
  • Workloads with lots of small files where compression and CoW shine.

Stick with ext4 or XFS for:

  • High-IO database servers — CoW write amplification can hurt under heavy random writes.
  • RHEL/CentOS production — Red Hat removed Btrfs from RHEL 8 and recommends XFS.
  • Anything still running kernel 4.9 or older.

If you want raw block-level flexibility instead of a CoW filesystem, look at LVM as an alternative storage management approach. LVM and Btrfs solve overlapping problems differently — LVM operates below the filesystem layer, Btrfs builds storage management into the filesystem itself.

Wrapping Up

Btrfs is one of those tools where the learning curve pays you back tenfold. Once you have subvolumes, snapshots, and zstd compression in your workflow, going back to ext4 feels like driving a car with no rearview mirror.

Start small. Format a spare USB drive with Btrfs this weekend. Create a couple of subvolumes. Take a snapshot, delete some files, roll back. The whole loop takes ten minutes and it’ll click in a way no article (including this one) can fully convey.

If this guide was useful, check out my walkthroughs on systemd timers for automating your snapshot schedule, and setting up automatic backups on Linux to pair your snapshots with real off-site safety. Got a question or a Btrfs war story of your own? Drop me a line — I read every email.

author avatar
Alexa Velinxs
I'm Alexa Velinxs, a cryptocurrency trading expert passionate about demystifying digital assets for both beginners and seasoned investors. Through my writing, I share actionable strategies, market insights, and practical tips to help you navigate the crypto landscape with confidence. Let's explore the future of finance together.
Related Posts