Which filesystem for a NAS: ext4, XFS, ZFS or Btrfs

Checksums, snapshots, growing a volume, RAM requirements: what each filesystem actually brings to a data store, and which one protects you against silent corruption.

The choice usually gets made at install time, in thirty seconds, on whatever the default is. Then data piles up for years, and that choice becomes very hard to walk back.

Yet the four candidates do not mainly differ on performance. They differ on a question that matters far more for storage: do they know whether your data is still intact?

The dividing line: data checksums

All of these filesystems protect their metadata — the directory tree, the permissions, where the blocks live. That is what journaling is for, and it does its job well when the power cuts out.

But only ZFS and Btrfs compute a checksum over the contents of every block and verify it on every read.

The difference is considerable. Without that verification, an altered block is handed back to the application as if it were valid. The file opens; it is simply wrong. With it, the alteration is detected immediately — and if redundancy exists, repaired from a good copy, transparently.

Silent corruption, the risk you never see

This is the failure mode specific to long-term storage, and the most insidious one.

The causes vary: failing memory, a micro-defect in the medium, a controller error, a mediocre cable. The result is always the same: a block changes and nobody is told.

What comes next is the worst part. Your backup faithfully copies the corrupted file. After a few retention cycles, every one of your versions contains the corruption. You discover the problem years later, opening a pixelated photo, and there is no clean version left anywhere.

What ZFS and Btrfs really bring: not performance, but the ability to say "this block is no longer the one I wrote" — and to repair it before the corruption spreads into your backups.

The four candidates

ext4 is mature, fast, supported everywhere, and its repair tools are thoroughly battle-tested. It is the right choice for a system disk, a virtual machine, or any volume whose contents are replaceable. On data kept for a long time, its lack of content verification is its one real weakness — but that weakness is structural.

XFS excels at large files and parallel writes: it is an excellent choice for media or backup storage, particularly on an array that is already redundant. It grows online but never shrinks — a constraint worth knowing before you size anything. Like ext4, it does not verify the contents of your data.

ZFS is the most complete: checksums, snapshots that are instant and nearly free, very effective transparent compression, built-in redundancy management, and periodic verification of the entire volume. Its price is discipline: you have to think about topology from day one, because pulling a disk out of an existing group remains constrained, and you have to keep an eye on its memory cache when it runs on a hypervisor.

Btrfs offers the same integrity guarantees, built into the kernel, with remarkable flexibility: disks added and removed online, profile conversion, genuinely handy snapshots and subvolumes. The caveat is clear-cut: its parity RAID modes remain inadvisable for important data. Mirrored, or as a simple pooled volume, it is a perfectly sound choice.

The ECC memory debate

"ZFS requires ECC memory" gets repeated a lot and deserves to be pinned down, because that belief talks people out of setups that are perfectly viable.

ZFS guarantees data integrity on disk. If memory corrupts a block before its checksum is computed, ZFS dutifully records the corrupted version with a valid checksum. ECC memory closes that window.

But that reasoning applies to every filesystem: failing memory corrupts an ext4 just as happily. ZFS is not more fragile, it is simply more explicit about the limits of its guarantee. ECC is strongly recommended on a storage server; its absence is not a reason to give up on ZFS.

Choosing in one sentence

  • System disk, virtual machine, replaceable data: ext4. Simple, fast, no surprises.
  • Large files on a redundant array: XFS, keeping in mind that it never shrinks.
  • Data you do not want to lose, spread over several disks: ZFS, if you are willing to design the topology seriously.
  • Integrity plus room to evolve, mirrored: Btrfs, steering clear of its parity modes.

And whatever you choose, a periodic verification of the whole volume is worth scheduling: on ZFS and Btrfs it detects and repairs, on ext4 and XFS it will at least tell you the disks still answer. That is what stops you from discovering a fault in the middle of an array rebuild.

Frequently asked questions

What does silent corruption look like in practice?
It is a block of data being altered with nothing to flag it: a cosmic ray, failing memory, a micro-defect in the medium, a controller error. The file is still there, still opens, and its contents have changed. On a system without checksums, nobody knows — not you, not the operating system, not the backup that faithfully copies the corrupted version. You only find out when you open a pixelated photo or an unreadable archive, often years later.
Is ext4 a bad choice for a NAS?
Not bad, but blind on one specific point. ext4 is mature, fast, universally supported, and its journaling protects the structure of the filesystem very well when the power cuts out. What it does not do is check the contents: it has no way of knowing that a block has been altered. On a replaceable system disk, that has no consequence. On data you keep for ten years, it is the main risk.
Is Btrfs reliable today?
For simple or mirrored use, yes: it ships in the kernel, it is widely deployed, and its snapshots are excellent. The caveat concerns its parity RAID modes (levels 5 and 6), which suffer from a long-known flaw when power is lost mid-write and remain inadvisable for important data. Mirrored, or as a simple pooled volume, Btrfs is a sound choice.
Does ZFS really require ECC memory?
It is not a requirement, contrary to what you often read. The reasoning is subtler: ZFS verifies data integrity on disk, but if memory corrupts a block before its checksum is computed, the error gets recorded as legitimate. ECC memory closes that gap. That said, failing memory hurts every filesystem; ZFS is not more vulnerable, it is simply more honest about what it guarantees.
Can you grow a volume after the fact?
It depends on the filesystem, and it is a criterion people overlook at install time. XFS grows but never shrinks. ext4 does both, with shrinking requiring an unmount. Btrfs is the most flexible: disks added and removed online, with rebalancing. ZFS extends by adding groups of disks, but pulling a disk out of an existing group remains constrained — hence the importance of designing the topology properly from the start.

Did you enjoy this article?

Comments

Morgann Riu

Cybersecurity and Linux administration expert. I help companies secure and optimize their critical infrastructures.

Back to the blog

Checklist Sécurité Linux

30 points essentiels pour sécuriser un serveur Linux. Recevez aussi les nouveaux tutoriels par email.

Pas de spam. Désabonnement en 1 clic.