A black vault with a rounded arch on a warm background. Inside, four stacked disks in orange, amber, cream and red represent a RAIDZ pool. A shield with a red checksum tick sits to the right, illustrating ZFS integrity protection.
[ Storage & Backup ]7 min read

The Vault: Demystifying ZFS and Data Sovereignty

Phase 1 · The Spark and the Scrap

A filesystem that assumes hardware is always failing, the RAIDZ-1 mistake I made, and why bit rot is not a myth.

ZFS on Linuxzpoolzfs sendProxmox VE

Everyone who has used computers long enough knows the sound. A rhythmic mechanical click from a drive that should be silent, followed by a system freeze and a refusal to boot. It is the sound of your data starting to die. The modern reflex is to shrug and say “it is all in the cloud anyway”. The honest reading of that reflex is that we have collectively agreed to forget where our data actually lives, because the answer is uncomfortable: the cloud is a warehouse we rent, on someone else’s terms, governed by a contract we do not read.

I wanted a vault I could read the contract on. To build one, I had to stop thinking about drives as “things that work” and start thinking about drives as “things that are always, quietly, in the process of failing”. That shift in mental model is what filesystem designers call data integrity, and the software that embodies it best in an open-source homelab is ZFS.

The Analogy

Ordinary computer storage is like an untended filing cabinet. You drop a document in a folder. Ten years later a silverfish has eaten a hole in the paper, and you only find out when you next reach for it. By then the ink on the replacement copy (if one exists) may have faded too.

ZFS is an archivist team that never sleeps. When you hand them a document they do not simply file it. They photocopy it, store the copies in separate fireproof safes, and write a fingerprint of the document on the outside of each safe. Every week they walk down the row of safes and compare each document to its fingerprint. If a single letter has faded on page four, they fetch an intact copy from another safe, replace the damaged page, and log the repair.

You do not see any of this. The document is always the document. The archivists do the work quietly.

The Tech Translated

ZFS began at Sun Microsystems in the mid-2000s and is now maintained as OpenZFS, a cross-platform community project. It combines three roles that other systems keep separate: a volume manager (which groups drives together), a RAID controller (which mirrors or parity-codes data across drives), and a filesystem (which stores the actual files). Because ZFS owns all three layers, it can do things a conventional RAID array cannot: in particular, it can tell the difference between a drive that has failed loudly (easy) and a drive that is quietly returning wrong data (much harder, and much more common than people think).

The “wrong data” problem is called bit rot. Cosmic rays, magnetic decay, and marginal sectors can flip a single bit on a drive that otherwise looks healthy. A regular filesystem has no way to notice. ZFS notices because every block carries a checksum (a mathematical fingerprint) stored separately from the block itself. When you read the block, ZFS compares the block to its checksum. If they disagree, ZFS looks for a good copy elsewhere in the pool and repairs the bad one in place. Study after study has confirmed that bit rot happens at rates high enough to matter on multi-terabyte drives, which is why the filesystem exists in the first place.

Pool topologies, honestly compared

ZFS groups drives into a “pool”. Inside the pool, you choose a topology that trades off usable capacity, redundancy, and rebuild risk:

TopologyDrivesUsableCan surviveNotes
Mirror (RAID-1)250%1 drive failureFastest rebuild, highest cost per terabyte.
RAIDZ-13+N-11 drive failureCheap capacity, but a second failure during a rebuild loses everything.
RAIDZ-24+N-22 drive failuresMy recommendation for a homelab with four or more drives.
Mirror-stripe4+50%1 per mirror pairFast reads, fast rebuilds, half of raw capacity.

The number that sells people on RAIDZ-1 is the “N-1” usable capacity. The number that should scare them off is the rebuild window. When a drive fails and you swap in a replacement, ZFS has to re-read every remaining drive in full to reconstruct the missing data. That process (called a resilver) can take a day or more on large drives, and during that day a second drive failure destroys the pool. For small drives and a four-drive pool, I thought the risk was acceptable. I was wrong.

The Action

What broke

I built my first real pool with four eight-terabyte drives in RAIDZ-1. That gave me twenty-four terabytes of usable space, which felt generous. Six months in, one of the drives threw a pre-failure warning. I ordered a replacement, plugged it in, and started the resilver. Halfway through the twenty-six-hour rebuild, a second drive began logging read errors. The pool stayed online, but the margin was gone; if that second drive had failed completely, every bit of data on the pool would have been unrecoverable. I got lucky. A lot of people in the same situation have not.

The next hardware refresh moved me to a six-drive RAIDZ-2 layout. I lose a drive’s worth of usable capacity compared with RAIDZ-1, and I gain the peace of a pool that tolerates two simultaneous failures. Peace is cheap at that price.

Building the pool

Here is the command I now reach for on a new six-drive chassis. Always address drives by their stable /dev/disk/by-id/ identifier rather than by /dev/sdX, because sdX names are assigned in boot order and can shuffle.

# Identify the drives. Look for the ata-... or wwn-... identifiers.
ls -l /dev/disk/by-id/ | grep -v part

# Create a six-drive RAIDZ-2 pool called "tank".
sudo zpool create tank raidz2 \
  /dev/disk/by-id/ata-ST8000VN004-... \
  /dev/disk/by-id/ata-ST8000VN004-... \
  /dev/disk/by-id/ata-ST8000VN004-... \
  /dev/disk/by-id/ata-ST8000VN004-... \
  /dev/disk/by-id/ata-ST8000VN004-... \
  /dev/disk/by-id/ata-ST8000VN004-...

# Turn on compression (cheap on modern CPUs, saves 20-40% on text).
sudo zfs set compression=lz4 tank

# Schedule a monthly integrity scrub (the archivists' weekly walk).
sudo systemctl enable --now zfs-scrub-monthly@tank.timer

And here is a zpool status snippet mid-resilver, so you know what a healthy repair looks like:

  pool: tank
 state: DEGRADED
status: One or more devices is currently being resilvered.
action: Wait for the resilver to complete.
  scan: resilver in progress since Sat Jun  8 09:14:02 2024
        2.41T scanned at 612M/s, 1.87T issued at 471M/s, 18.6T total
        311G resilvered, 10.07% done, 11h32m to go
config:

        NAME                            STATE     READ WRITE CKSUM
        tank                            DEGRADED     0     0     0
          raidz2-0                      DEGRADED     0     0     0
            ata-ST8000VN004-2EFJ101     ONLINE       0     0     0
            replacing-1                 DEGRADED     0     0     0
              old                       UNAVAIL      0     0     0
              ata-ST8000VN004-3EFJ101   ONLINE       0     0     0  (resilvering)
            ata-ST8000VN004-2EFJ101     ONLINE       0     0     0
            ata-ST8000VN004-2EFJ101     ONLINE       0     0     0
            ata-ST8000VN004-2EFJ101     ONLINE       0     0     0
            ata-ST8000VN004-2EFJ101     ONLINE       0     0     0

errors: No known data errors

“DEGRADED” is not an emergency word here. It is the filesystem being honest that it has lost a drive and is working to restore full redundancy. The pool stays online and readable throughout. That honesty, logged to journalctl and surfaced in the web interface, is the whole point.

Snapshots are not backups, but they are close

ZFS snapshots are near-instant, copy-on-write photographs of the pool at a point in time. They cost nothing until the underlying data changes. I take hourly, daily, and weekly snapshots on every dataset I care about. If I delete a file by accident at three in the afternoon, the two o’clock snapshot still has it.

# Create a snapshot.
sudo zfs snapshot tank/docs@2024-06-10-14-00

# List snapshots on a dataset.
zfs list -t snapshot tank/docs

# Roll a file back by copying it out of the hidden .zfs/snapshot directory.
cp /tank/docs/.zfs/snapshot/2024-06-10-14-00/invoice.pdf /tank/docs/

# Send a snapshot to another pool or host (the primitive that drives backup).
sudo zfs send tank/docs@2024-06-10-14-00 | ssh backup@vault \
  'sudo zfs receive rust/docs@2024-06-10-14-00'

Snapshots living on the same pool are not a backup (they die with the pool). What they are is the fastest possible undo button for a mistake made by you or your software. We will talk about real off-host backups in entry eight.

What the vault actually feels like

The vault stopped feeling impressive the week after I built it. It became furniture: a machine running in a back room that I rarely log into, quietly serving files, photos, and virtual machine disks, scrubbing itself on the first Sunday of every month, and reporting its own health to me by email. The last drive failure was handled by an overnight resilver; I only noticed because the monthly report arrived with a note about it.

That is the outcome you want. Not a fortress you stare at with pride, but a piece of reliable infrastructure that fades into the background and keeps being there. Sovereignty over your data is not a stirring slogan. It is a set of small, boring, well-configured defaults, held together by a filesystem that assumes the hardware underneath is always, slowly, failing.

Footnotes

  1. OpenZFS is a union of the ZFS-on-Linux and ZFS-on-FreeBSD development efforts, first released as a single codebase in 2020. Project home: openzfs.org. ↩

  2. Bairavasundaram, L. N. et al. (2008). “An Analysis of Data Corruption in the Storage Stack”. USENIX FAST ‘08. Observed silent corruption on roughly 0.5% of SATA drives over a 41-month study of 1.5 million drives at NetApp. Available at usenix.org. ↩

Table of Contents