Why Your Data Needs ZFS
The ZFS filesystem is built on the assumption that every storage system lies to you. Disks report successful writes that silently corrupt. RAID controllers introduce errors. Memory glitches flip bits. Over time, your data degrades without any error messages—this is called bit rot.
Traditional filesystems trust hardware implicitly. When your disk says "write complete," ext4 believes it. When your RAID controller says "all mirrors healthy," XFS trusts it. But hardware fails in subtle ways that these filesystems can't detect.
ZFS trusts nothing. Every block is checksummed. Every checksum is stored in the parent block. Corruption anywhere in the chain is detected and—with redundancy—automatically repaired.
ZFS: The Paranoid Librarian
Think of ZFS like a librarian who trusts no one—not the shelves, not the book bindings, not even their own memory.
- Checksums on every book — Writes a verification code on every spine, checks it before every read
- Never erases originals — Writes amendments on new pages, keeps old ones safe until complete
- Instant photographs — Takes snapshots of the entire library state without copying anything
- Keeps backup copies — Maintains duplicates and reconstructs damaged books automatically
Before diving into theory, let's see ZFS work. This interactive demo walks you through pool creation, RAID-Z parity, snapshots, and disk failure recovery. Pick a scenario, then step through it; the readout panel shows the pool's state at each step:
# Identify available disks
lsblk | grep sd- Four raw disks: /dev/sdb, /dev/sdc, /dev/sdd, /dev/sde
- No filesystem or pool configured
- Total capacity: 4 × 1TB = 4TB raw
- No redundancy or data protection
- Ready to be configured into a ZFS pool
Copy-on-Write: Never Lose Data Mid-Write
Most filesystems overwrite data in place. If power fails mid-write, you get corrupted data and need to run fsck. ZFS never overwrites—it writes new data to new locations, then atomically updates pointers.
Traditional FS vs. Copy-on-Write
- Traditional (ext4, NTFS) — Like erasing and rewriting in a library book. If someone bumps your elbow mid-write, the book is damaged forever. No undo.
- ZFS Copy-on-Write — Like writing amendments on new pages, keeping originals intact. Even if disaster strikes, the old pages still exist—just switch back.
Watch exactly how this works—blocks allocated, snapshots created, rollbacks performed—all with zero copying. Step through it and follow which blocks the file and each snapshot point to:
A file "report.txt" exists with 4 data blocks (B1-B4). Each block is 128KB and contains part of the document.
Traditional filesystem: metadata points directly to data blocks. No history, no safety net.
Why Copy-on-Write is Revolutionary
- Snapshots are instant — Just save the current block pointers (no data copying!)
- Snapshots are free — Only changed blocks consume new space
- Always consistent — Old state remains valid until new state is complete
- No fsck needed — Filesystem is always consistent, even after crash
- Time travel — Roll back to any snapshot instantly
The ARC: Your Data's Memory Palace
You've heard "ZFS needs lots of RAM." Here's why: the Adaptive Replacement Cache (ARC) keeps hot data in memory, dramatically speeding up reads.
ARC: The Smart Filing Clerk
Imagine a filing clerk who keeps two stacks on their desk:
- MRU stack — The 1000 most recently requested files (good for sequential work)
- MFU stack — The 1000 most frequently requested files (good for hot data)
- Adaptive sizing — If MFU hits are higher, that stack grows automatically
- Graceful eviction — When the desk fills up, least-useful files go to a nearby cabinet (L2ARC on SSD)
- Memory pressure aware — When the office needs space, the clerk shrinks their stacks without crashing
Try the cache simulator—watch entries move between lists, apply memory pressure, and see hit ratios change:
ARC Configuration
# Check current ARC size
cat /proc/spl/kstat/zfs/arcstats | grep "^size"
# Limit ARC to 8GB (in /etc/modprobe.d/zfs.conf)
options zfs zfs_arc_max=8589934592
# Add L2ARC device (SSD cache for evicted entries)
sudo zpool add tank cache /dev/nvme0n1
End-to-End Integrity: Trust Nothing
ZFS doesn't trust hardware. Every block is checksummed, and that checksum is stored in the parent block—creating a Merkle tree from data up to the root (uberblock).
RAID-Z: The Secret Sharing Protocol
Imagine 3 friends each know part of a secret phrase:
- Alice: "The treasure is..."
- Bob: "...buried under..."
- Carol: "...the old oak tree"
If Bob forgets his part, Alice and Carol can XOR their parts with the parity checksum to reconstruct it. Any piece can be rebuilt from the others! This is RAID-Z.
See how checksum verification cascades through the block tree, detecting corruption and self-healing. Corrupt a data block, then press Play; switch redundancy to None to see the same corruption go unrepaired:
a7b3f9c2d8e1f4a2b73e9c1d8f2a4bd5e7c3Scrubbing: Proactive Integrity Verification
# Start a scrub (verify all data integrity)
sudo zpool scrub tank
# Check scrub progress
sudo zpool status -v tank
# Schedule weekly scrubs (cron example)
0 2 * * 0 /sbin/zpool scrub tank
Common Pitfalls
Watch Out For
- Memory miscalculation — ZFS wants ~1GB RAM per TB of storage for basic operation. Undersize and performance tanks as ARC can't cache enough.
- Deduplication RAM trap — Enabling dedup requires ~5GB RAM per TB. A 20TB pool with dedup needs 100GB+ RAM. Most home users should avoid dedup entirely.
- Pool expansion limitations — You can add vdevs to a pool but can't remove them (until very recent versions). Plan your pool topology carefully upfront.
- CDDL licensing concerns — ZFS uses CDDL license which is incompatible with GPL. It can't be included in Linux kernel directly—loaded as kernel module.
- Full pool performance cliff — Above 80% full, ZFS performance degrades significantly. Above 90%, copy-on-write struggles to find free blocks. Keep pools under 80%.
Quick Reference: Essential Commands
Pool Operations
# Create pools with different redundancy
sudo zpool create tank mirror /dev/sdb /dev/sdc # RAID1 (mirror)
sudo zpool create tank raidz2 /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf # RAID6-like
# Pool management
sudo zpool status -v tank # Health and status
sudo zpool iostat -v tank 1 # I/O statistics (1 second interval)
sudo zpool add tank mirror /dev/sdg /dev/sdh # Expand pool with new vdev
Dataset Operations
# Create datasets with properties
sudo zfs create -o compression=lz4 -o quota=100G tank/documents
sudo zfs create -o compression=zstd -o recordsize=1M tank/media
# List datasets with useful columns
sudo zfs list -o name,used,referenced,compressratio
Snapshots and Clones
# Create snapshot (instant!)
sudo zfs snapshot tank/home@backup-$(date +%Y%m%d)
# List snapshots
sudo zfs list -t snapshot
# Rollback to snapshot (destroys newer data)
sudo zfs rollback tank/home@backup-20250120
# Create writable clone from snapshot
sudo zfs clone tank/vm@golden tank/vm-test
Send/Receive (Backup)
# Full send to remote
sudo zfs send tank/home@snap | ssh remote sudo zfs receive backup/home
# Incremental send (only changes since @snap1)
sudo zfs send -i @snap1 tank/home@snap2 | ssh remote sudo zfs receive backup/home
# Encrypted send (raw blocks, preserves encryption)
sudo zfs send -w tank/secure@snap | ssh remote sudo zfs receive backup/secure
ZFS vs Other Filesystems
| Feature | ZFS | Btrfs | ext4 | XFS |
|---|---|---|---|---|
| Data Integrity | ████ | ███ | ██ | ██ |
| Snapshots | ████ | ████ | None | None |
| Compression | ████ | ███ | None | None |
| Deduplication | ████ | ██ | None | None |
| Built-in RAID | ████ | ███ | None | None |
| Maturity | ████ | ███ | ████ | ████ |
| Performance | ███ | ███ | ████ | ████ |
| RAM Usage | ████ | ██ | █ | █ |
When to Use ZFS
Perfect for:
- NAS and storage servers (where data integrity is paramount)
- Virtualization hosts (instant VM cloning from snapshots)
- Database servers (tune recordsize for your workload!)
- Backup systems (incremental send/receive is incredible)
- Any system where silent corruption is unacceptable
Consider alternatives when:
- Less than 8GB RAM available (ECC RAM preferred)
- Root filesystem on desktop (complex recovery scenarios)
- Embedded systems with limited resources
- Strict GPL licensing requirements
Best Practices
- Pool Design: Use mirrors for IOPS workloads, RAID-Z2 for capacity with large drives (>4TB)
- Keep pools under 80% full — performance degrades significantly above this threshold
- Use LZ4 compression — nearly free CPU cost, often speeds up I/O due to reduced bytes transferred
- Tune recordsize for workload (1M for large media files, 16K for databases, 128K default)
- Weekly scrubs — catch corruption before you need the data
- Test restores — snapshots are useless if you've never verified you can restore from them
- Avoid dedup unless you have 5GB RAM per TB AND you're certain you have lots of duplicate data
When to choose ZFS (and when Btrfs or stacked dm-integrity is the better answer)
ZFS is the right call when end-to-end integrity, snapshots, and zero-cost clones are the central requirements and you can afford the memory budget. It's the wrong call on small devices, on machines with strict mainline-kernel constraints, or when a simpler stack would do.
Choose ZFS when:
- You're storing anything you cannot recreate — archival media, scientific data, databases, source of truth. Checksum + scrub + self-healing on a mirror or RAID-Z group is the strongest open-source integrity story.
- You need block-level snapshots and clones that cost nothing on creation — virtualisation backends, time-travel backups, replicated DR pairs.
- You're running NAS or storage server workloads where the OS and pool live on dedicated hardware with 16 GB+ of RAM and you don't mind dedicating most of it to the ARC.
- You want a single tool for redundancy, integrity, snapshots, encryption, and quotas — ZFS does all of these in one cohesive interface.
- You're using
zfs send | zfs recvfor incremental replication — the snapshot-stream protocol is bulletproof and trivial to script.
Choose Btrfs when:
- You want mainline Linux kernel support without out-of-tree modules — Btrfs ships in every distro kernel; ZFS-on-Linux is out-of-tree by license.
- You're on a desktop or laptop where the dedicated-RAM cost of ZFS isn't justified.
- You need single-disk snapshots without RAID — Btrfs handles this natively; ZFS prefers a redundant pool.
- You're running OpenSUSE, Fedora Server, or anything that ships Btrfs as default — sticking with the distro's choice is one less thing to maintain.
Stack dm-integrity + ext4/XFS + mdraid when:
- You're forbidden from running out-of-tree modules for compliance reasons.
- You want most of ZFS's integrity guarantee without committing to its memory model — block-level checksums plus mirroring catches most silent corruption.
- You're on a kernel that doesn't have a battle-tested Btrfs RAID path (older LTS releases) and can't migrate to ZFS —
dm-integrityovermdraid1is the safe-but-clunky compromise.
Skip all three when:
- The workload is stateless or fully replicable from elsewhere — a Kubernetes worker node's local disk doesn't need integrity at this depth; you'd replace the node.
- You're storing cache or scratch data that's regenerated on demand — pay for performance, not durability.
- The drive is a single USB stick or SD card — none of the three filesystems plays well with the device's wear leveling and write amplification.
The honest decision rule: ZFS when integrity must be end-to-end and you have the RAM budget, Btrfs when you want most of that on a normal Linux box, dm-integrity stacks when policy forbids the first two.
Related concepts
Trace how Btrfs shares extents, creates snapshots, distributes copies, compresses writes, and repairs checksum errors when a good replica exists.
Follow filesystem copy-on-write from a changed block to a committed root. Explore snapshot sharing, space reclamation, and the trade-offs in Btrfs and ZFS.
Explore ext4, the default Linux filesystem with journaling, extents, and proven reliability. Learn how ext4 protects your data.
Learn FAT32 and exFAT filesystems for cross-platform USB drives and SD cards. Understand file size limits and compatibility.
Follow a filesystem transaction from journal to checkpoint. Explore crash recovery, ext4 journal modes, and the limits of data durability.
Explore Linux filesystems through interactive visuals. Learn VFS, compare ext4 vs Btrfs vs ZFS, and understand file operations.
