Chapter 12. Ext4, XFS, and Btrfs Filesystems
A filesystem turns a raw block device into named files, directories, and metadata that survive a reboot. Debian 13 installs and supports three general-purpose Linux filesystems in depth: ext4, the long-standing default; XFS, built around allocation groups and a metadata log; and Btrfs, a copy-on-write filesystem with subvolumes, snapshots, checksums, and multi-device profiles. Chapter 11 created filesystems and mounted them; this chapter administers them. It covers the choices made at creation, the tuning and inspection tools, the different failure and repair models, and the concerns shared by all three: quotas, sparse files and reflinks, extended attributes and ACLs, and choosing the right check procedure.
The examples run on one Debian 13 system named filesystems (kernel
6.12.86+deb13-amd64, e2fsprogs 1.47.2, xfsprogs 6.13.0, btrfs-progs
6.14, quota 4.09, acl 2.3.2, attr 2.5.2). Two empty virtio disks are
attached: /dev/vdb, 8 GiB, and /dev/vdc, 2 GiB. This chapter
destroys and recreates both. Use a spare disk or a disposable virtual
machine; do not follow the partitioning commands on a disk whose contents
you need. The first disk carries four practice partitions, and the second
is added to Btrfs later:
| Device | Size | Practice role |
|---|---|---|
/dev/vdb1 |
1500 MiB | ext4 creation, tuning, and repair |
/dev/vdb2 |
2200 MiB | Btrfs subvolumes, snapshots, compression, profiles |
/dev/vdb3 |
768 MiB | ext4 user and group quotas |
/dev/vdb4 |
1020 MiB, grown later | XFS creation, growth, repair, project quota |
/dev/vdc |
2000 MiB | second Btrfs device for RAID1 |
Commands entered in john's ordinary shell begin with $ and commands
entered in a root shell begin with #; the prompt marker is not typed.
From john's shell, sudo -i enters a root shell and exit leaves it.
john's account and its sudo access were established during installation
(Chapter 2 and Chapter 5).
The examples assume Chapter 3's shell operations,
including output redirection, pipelines, quoting, and command sequencing.
Files, images, and practice data belong to john under
~/debian-handbook/filesystems; create that directory before the first
example:
$ mkdir -p ~/debian-handbook/filesystems
$ cd ~/debian-handbook/filesystems
Neither command prints anything. The filesystem tools beyond a base installation come from the following packages; install them with Chapter 6's ordinary interactive procedure:
$ sudo apt install parted xfsprogs btrfs-progs btrfs-compsize acl attr quota
e2fsprogs (the ext4 tools) is part of every Debian base system. The
package manager prints its download and configuration progress; the
exact lines depend on which packages are already present, so they are not
reproduced here. losetup, fsfreeze, and blkid are util-linux
tools and filefrag is from e2fsprogs, all already installed;
partprobe comes with the parted package just installed.