12.1. Choosing a Filesystem

The choice is mostly made once, at mkfs time. Ext4, XFS, and Btrfs can all store ordinary files and directories, but they differ in what they record, how they recover after a crash, what they can do while mounted, and which repairs are possible. Those differences are structural: a filesystem created without data checksums or snapshots cannot gain them later.

12.1.1. Journaling, Copy-on-Write, and Failure Recovery

Ext4 and XFS are journaling filesystems. Before overwriting a metadata block in place, they append a description of the change to a journal or log. After a crash, recovery replays committed transactions from that journal and discards an incomplete tail. The file data itself is not normally journaled: ext4's default data=ordered mode writes data blocks before the metadata that points at them, so a crash can lose recent file contents but does not normally expose stale disk blocks as file data. XFS uses the same idea with a log and delayed allocation; its metadata carries CRC32c checksums, but user data does not.

Btrfs is copy-on-write. It never overwrites a live metadata block in place. A change writes new data and new tree nodes, then switches the superblock's root pointer to the new tree. The old blocks remain valid for any snapshot that still references them. Every data and metadata block is checksummed by default, so a read can detect silent corruption; the NOCOW attribute (chattr +C) disables data checksums for a specific file while metadata checksums remain. A snapshot is a second tree root pointing at the same blocks; it is cheap, but it is not a backup. If the underlying device loses a block that both the snapshot and the live tree share, both are damaged.

Journaling appends metadata changes to a log and replays them after a crash; copy-on-write writes new tree nodes and switches the root pointer.

Figure 12.1. Journaling and copy-on-write place the consistency boundary in different places. The comparison is conceptual; journal sizes, checksum coverage, and write ordering are configured separately.

The practical consequence is the recovery model. Ext4 and XFS tolerate a crash by replaying a log, and their offline repair tools start from whatever in-place metadata remains. Btrfs tolerates a crash without a replay log in the same sense: the old root is still valid, and a transaction that was not committed is simply not visible. Btrfs's repair tools are correspondingly different, and btrfs check --repair is much more invasive than e2fsck -fy or xfs_repair; Section 12.5.4 returns to that choice.

12.1.2. Workload, Capacity, and Resize Requirements

All three filesystems grow online. The reverse operation is not symmetric. Ext4 can shrink offline with resize2fs after an e2fsck pass. XFS has no ordinary supported in-place shrink: Debian 13's xfs_growfs can attempt an experimental data-section reduction with -D, but it refuses layouts that leave too little allocation-group space and is not a routine substitute for migration. Btrfs can grow and shrink a device online, but its allocation is spread across data, metadata, and system chunks, so a nearly full filesystem can refuse a shrink or a balance even when df reports free space. Chapter 14 covers the layer-by-layer procedure for a real capacity change.

For a single data volume, the choice often comes down to these questions:

Requirement ext4 XFS Btrfs
Online grow Yes Yes Yes
Shrink Offline only Migration; experimental -D path only Online, with allocation constraints
Data checksums No No (metadata CRC only) Yes
Snapshots No No Yes, per subvolume
Built-in multi-device redundancy No No Yes, RAID1/RAID1C3/RAID1C4/RAID10; RAID5/6 are not recommended for metadata
Quota models User, group, project User, group, project Qgroups per subvolume
Offline repair e2fsck xfs_repair btrfs check
Typical fit General-purpose default, small and mid-size volumes Large volumes, parallel metadata work, grow-only data Snapshots, checksums, multi-device data, send/receive

A decision path that starts from snapshots and checksums, then shrink requirements, then scale and parallelism.

Figure 12.2. A decision path for a general-purpose data volume. The criteria are structural properties, not performance ratings; a workload may make several rows relevant at once.

The table is a selection aid, not a benchmark. A small ext4 filesystem on a desktop and a large XFS filesystem on a server can both be correct choices; the workload and the recovery plan decide which properties matter. A filesystem that must be shrinkable favors ext4. A volume that will only grow and carries many concurrent writers favors XFS. A volume whose operator needs cheap local snapshots, data checksums, or built-in mirroring favors Btrfs.

Capacity planning includes inodes and metadata, not just data blocks. Ext4 allocates a fixed inode table at creation; df -i shows whether a workload that creates millions of small files will exhaust inodes before blocks. XFS allocates inodes dynamically but can still run out of inode space when imaxpct is reached. Btrfs allocates metadata chunks separately from data and can report ENOSPC when data has free space but metadata chunk allocation cannot proceed. Section 12.4.4 shows how btrfs filesystem usage separates those numbers.

12.1.3. Filesystem Features and Tool Compatibility

The installed tools report their own versions; these were the versions used for the procedures in this chapter. They are also the tools that must be available in a rescue environment before a repair is attempted.

Tool set Package Version here Main commands
ext2/3/4 e2fsprogs 1.47.2 mkfs.ext4, dumpe2fs, tune2fs, e2fsck, debugfs, resize2fs
XFS xfsprogs 6.13.0 mkfs.xfs, xfs_info, xfs_growfs, xfs_repair, xfs_spaceman, xfs_db, xfs_quota
Btrfs btrfs-progs 6.14 mkfs.btrfs, btrfs, btrfsck, btrfs-map-logical
Quotas quota 4.09 setquota, repquota, quotaon
ACLs and xattrs acl, attr 2.3.2, 2.5.2 setfacl, getfacl, setfattr, getfattr
Compression report btrfs-compsize 1.5 compsize

Kernel support matters as much as the tools. Kernel 6.12 supports ext4, XFS, and Btrfs, including XFS reflinks, Btrfs no-holes and free-space-tree, and Btrfs zstd compression. Older kernels may mount a filesystem read-only or refuse it when a feature is unknown. Before moving a disk to another system, check that the target kernel supports the features recorded in the superblock; dumpe2fs -h and xfs_info print them, and Btrfs prints its feature set with btrfs inspect-internal dump-super.

The tools are deliberately filesystem-specific. e2fsck does not understand XFS, xfs_repair does not read Btrfs, and btrfs check is not a substitute for either. A rescue image should contain all three tool sets if it may encounter all three filesystems. fsck.xfs and fsck.btrfs exist as boot-time placeholders; they do not perform a repair. That is why Section 12.5.4 makes the repair decision explicitly rather than relying on the boot-time fsck pass.