Skip to content

Installing the Tools

This chapter gets btrfs and mkfs.btrfs onto a machine and proves they work. The outcome: a version report you can compare with this guide's, and one small distinction — between the tool in your hand and the filesystem support in the kernel — that explains a whole family of later errors.

Two halves: kernel and tools

Btrfs itself lives in the Linux kernel. Check yours knows the filesystem:

grep btrfs /proc/filesystems

A line saying btrfs means the kernel can mount and run it. The tools — the commands you type — come in one package, btrfs-progs, and are separate: a machine can have the kernel support and no tools, or (as in this guide's lab, which could not mount anything) tools with nowhere to point them but image files.

Install

On Debian and Ubuntu:

sudo apt install btrfs-progs

On Fedora:

sudo dnf install btrfs-progs

On Arch:

sudo pacman -S btrfs-progs

Check

btrfs --version
mkfs.btrfs --version

Both report the same version. This guide's lab used btrfs-progs 6.6.3 on a kernel that listed btrfs among its filesystems (transcript t00), so outputs in the transcripts can be compared line for line with yours. Small differences across versions are normal — mkfs.btrfs has changed some defaults over the years (since 5.15, metadata defaults to DUP and the free-space tree is on), and it prints a note saying so, which the lab's transcript t01 shows.

Check: btrfs --version prints a version number, and btrfs filesystem --help lists subcommands. If the version is much older than 6.x, prefer your distribution's newer packages where you can: filesystem tools are the one place where old is a real disadvantage, because the on-disk format's safety fixes land here first.

A word about where you practise

Everything dangerous in this guide happens to devices, and the commands do not ask whether a device holds your only copy of anything. Practise on spare disks, on a machine you can afford to rebuild, or — like this guide's lab — on image files: plain files treated as disks, made with truncate, examined with the offline tools in chapter 4. The lab's rule, worth adopting as your own: never type a btrfs command at a device you have not identified twice. lsblk shows what is attached; check it before mkfs, before device add, before anything that writes.