Hardware
ZFS Explained: Why Homelabs and Servers Use It
ZFS explained: pools, vdevs, RAIDZ, checksums, snapshots, compression and ARC, how it compares with ext4 and Btrfs, and how to plan a pool for a NAS.
ZFS is a filesystem and volume manager in one, designed to keep data correct. It checksums every block, detects and repairs silent corruption, takes instant snapshots, compresses data on the fly and manages disks in redundant groups without a separate RAID layer. That combination is why ZFS runs under TrueNAS, is built into Proxmox, and is the default answer on homelab forums whenever someone asks how to store data they can't afford to lose.
ZFS asks for a little more planning than a traditional filesystem. Its layout decisions are hard to change later, and it rewards plenty of RAM. This guide explains what ZFS is, how pools and vdevs work, the RAIDZ levels with a capacity table, the features that make it special, how it compares with ext4 and Btrfs, and how to plan a pool for a NAS or server.
ZFS at a Glance
| Item | Detail |
|---|---|
| What it is | Combined filesystem and volume manager with built-in redundancy |
| Origin | Sun Microsystems; announced in 2004, shipped with OpenSolaris in 2005 |
| Today | OpenZFS, an open-source project for Linux, FreeBSD and other systems |
| Licence | CDDL, which keeps it out of the mainline Linux kernel |
| Key features | Checksums and self-healing, copy-on-write, snapshots and clones, send/receive replication, compression, RAIDZ |
| Redundancy options | Mirrors, RAIDZ1, RAIDZ2, RAIDZ3 |
| Common platforms | TrueNAS, Proxmox VE, FreeBSD, Ubuntu and other Linux distributions |
| Main trade-offs | Layout planning, RAM appetite, licence friction on Linux |
What Is ZFS?
What is ZFS file system design, compared with the usual approach? Most storage stacks have separate layers: a RAID controller or mdadm combines disks, a volume manager carves up space, and a filesystem such as ext4 sits on top. None of those layers knows much about the others. (Object stores such as S3 are a different model again; see object storage vs block storage.) ZFS merges them, so the filesystem knows which disks hold each block and can verify and repair data end to end.
ZFS was designed at Sun by a team led by Jeff Bonwick, Bill Moore and Matthew Ahrens. It was announced in September 2004 and released with OpenSolaris in November 2005. After Oracle bought Sun, its ZFS became closed source, and the open-source line continued through illumos and, from 2013, the OpenZFS project. OpenZFS now brings Linux and FreeBSD onto one code base, and its 2.3 release added RAIDZ expansion, the ability to add a disk to an existing RAIDZ group.
Pools, vdevs and datasets
ZFS has three layers to understand:
| Layer | What it is | Example |
|---|---|---|
| Disk | A physical drive or partition | Six 8 TB hard drives |
| vdev (virtual device) | A group of disks with its own redundancy | A 6-disk RAIDZ2 group, or a 2-disk mirror |
| Pool (zpool) | One or more vdevs combined into a single storage space; data is striped across vdevs | tank, made of one RAIDZ2 vdev |
| Dataset | A filesystem (or a block device, called a zvol) inside the pool, with its own settings | tank/photos, tank/backups, tank/vm-disks |
The rule that matters most: redundancy lives in each vdev, and losing any vdev loses the whole pool. A pool made of one RAIDZ2 vdev and one single disk is only as safe as that single disk.
Datasets share the pool's free space; there's no fixed partitioning. Each can have its own compression, record size, quota, reservation and snapshot schedule.
ZFS RAIDZ and Mirrors
ZFS RAIDZ is its parity-based redundancy, similar to RAID 5 and 6 but integrated with the filesystem:
| Layout | Disks that can fail per vdev | Comparable to | Minimum disks |
|---|---|---|---|
| Mirror | All but one in the mirror | RAID 1 | 2 |
| RAIDZ1 | 1 | RAID 5 | 3 |
| RAIDZ2 | 2 | RAID 6 | 4 |
| RAIDZ3 | 3 | Triple parity | 5 |
Approximate usable capacity with six 8 TB disks, before ZFS metadata, padding and the free-space headroom you should keep:
| Layout | Usable (approx.) | Survives | Notes |
|---|---|---|---|
| Three 2-way mirrors | 24 TB | 1 disk per mirror | Best random performance; easy to grow by adding mirrors |
| One 6-disk RAIDZ1 | 40 TB | 1 disk | Risky with large disks during resilver |
| One 6-disk RAIDZ2 | 32 TB | Any 2 disks | The common choice for a home or office NAS |
| One 6-disk RAIDZ3 | 24 TB | Any 3 disks | For very large disks or archives |
Unlike classic RAID 5, ZFS knows which blocks are in use, so rebuilding a replaced disk, called resilvering, copies only real data, not the whole disk. And because every block has a checksum, ZFS can tell which copy is correct when two disagree.
The Features That Make ZFS Different
Checksums and self-healing
Every block is stored with a checksum, kept in its parent block rather than next to the data. On every read, ZFS recomputes the checksum. If it doesn't match, the block is corrupt: a bad sector, a firmware bug, a cable fault or a misdirected write. With redundancy, ZFS reads a good copy from the mirror or rebuilds it from parity, returns the correct data and rewrites the bad block. This is self-healing, and it catches the silent corruption that traditional RAID passes straight through.
A scrub reads every block in the pool and checks it, repairing what it can. Most people schedule one every few weeks.
Copy-on-write
ZFS never overwrites live data in place. Changes are written to new blocks, and pointers are updated only once the new data is safely on disk. A power cut mid-write leaves the previous consistent state intact, so ZFS has no fsck step after a crash. Recently written data may be lost, but the filesystem stays consistent.
Snapshots and clones
Because of copy-on-write, a snapshot is nearly instant and initially takes no space: it simply keeps the old blocks instead of freeing them. You can keep hundreds, roll a dataset back, or browse old versions of files. A clone is a writable copy made from a snapshot, useful for test copies of databases or virtual machines.
Send and receive
zfs send turns a snapshot, or the difference between two snapshots, into a stream that zfs receive can apply on another pool, even over SSH to another machine. Incremental sends transfer only changed blocks, which makes ZFS-to-ZFS backups fast and efficient.
Compression
Transparent compression is cheap and usually worth enabling. LZ4 is fast enough that it often speeds up hard-drive pools, because less data is read and written. Zstandard compresses harder at more CPU cost. Already-compressed media such as video gains little, and ZFS quickly gives up on blocks that don't shrink.
ARC caching
ZFS caches hot data in RAM in the ARC (adaptive replacement cache), which balances recently and frequently used data. More RAM means more cache hits. An optional SSD L2ARC extends the cache, and an optional SLOG device speeds up synchronous writes, such as those from databases or NFS.
A Few Commands
Creating and using a pool on Linux or FreeBSD:
zpool create -o ashift=12 tank raidz2 /dev/disk/by-id/ata-DISK1 /dev/disk/by-id/ata-DISK2 \
/dev/disk/by-id/ata-DISK3 /dev/disk/by-id/ata-DISK4 /dev/disk/by-id/ata-DISK5 /dev/disk/by-id/ata-DISK6 # one RAIDZ2 vdev of six disks
zfs set compression=lz4 tank # children inherit it
zfs create tank/photos
zfs snapshot tank/photos@before-cleanup
zfs list -t snapshot
zpool scrub tank
zpool status tank # health, errors, scrub progress
zfs send -i tank/photos@mon tank/photos@tue | ssh backup zfs receive pool/photosUse stable /dev/disk/by-id/ names rather than /dev/sdX, which can change between boots.
ZFS vs ext4
On ZFS vs ext4: ext4 is the default filesystem on many Linux distributions, and it's fast, simple and very mature. It sits on a single block device and leaves redundancy to mdadm or hardware RAID.
| ZFS | ext4 | |
|---|---|---|
| Data checksums | Yes, with self-healing | Metadata checksums only |
| Built-in RAID | Mirrors and RAIDZ | No (use mdadm or LVM) |
| Snapshots | Instant, built in | Only through LVM, which is slower |
| Compression | Built in | No |
| Replication | zfs send/receive | External tools such as rsync |
| RAM use | Uses spare RAM for ARC | Minimal |
| Licence and kernel | Out-of-tree module on Linux | In the Linux kernel |
| Best for | Storage servers, NAS, VM hosts | Boot drives, desktops, simple servers |
ZFS vs Btrfs
On ZFS vs Btrfs: Btrfs is the Linux-native filesystem with similar goals: copy-on-write, checksums, snapshots, compression and built-in RAID. It's part of the Linux kernel, used by default in Fedora Workstation and openSUSE, and handles mixed disk sizes and reshaping flexibly.
| ZFS | Btrfs | |
|---|---|---|
| In the Linux kernel | No (CDDL licence) | Yes |
| Mirrors | Mature | Mature |
| Parity RAID (5/6) | RAIDZ1/2/3, mature | RAID 5/6 still carries warnings against production use |
| Growing arrays | Add vdevs; RAIDZ expansion since OpenZFS 2.3 | Add or remove disks and rebalance freely |
| Mixed disk sizes | Wasteful within a vdev | Handled well |
| Caching | ARC, L2ARC, SLOG | Uses the normal Linux page cache |
| Best for | Large redundant storage pools | Desktops, single disks and mirrors on Linux |
For a parity-protected storage pool, ZFS is the safer choice; for a Linux desktop or a simple mirror, Btrfs is a good fit.
Useful Dataset Properties
Each dataset can be tuned for what it stores:
| Property | What it controls | Typical setting |
|---|---|---|
compression | Transparent compression | lz4 everywhere; zstd for archives |
recordsize | Maximum block size for files | 1M for large media and backups; 16K–64K for databases; default 128K otherwise |
atime | Whether reads update access times | off to avoid extra writes |
quota / refquota | Maximum space a dataset can use | Per user, project or VM |
reservation | Space guaranteed to a dataset | For critical datasets |
copies | Extra copies of each block within the pool | 2 for a few precious files on a single-disk pool |
encryption | Native encryption per dataset | Set at creation; keys can be loaded separately |
Native encryption is handy for backups: an encrypted dataset can be sent to another machine with zfs send --raw, so the backup host never sees the keys.
Where ZFS Runs
| Platform | ZFS support |
|---|---|
| TrueNAS (Community and Enterprise) | Built around ZFS; managed from a web interface |
| Proxmox VE | ZFS offered at install for the root disk and VM storage |
| FreeBSD | ZFS supported in the base system, including as the root filesystem |
| Ubuntu | OpenZFS packaged by the distribution |
| Other Linux distributions | OpenZFS installed as a separate kernel module |
| macOS and Windows | Community ports exist; not for production data |
How Much RAM Does ZFS Need?
Less than forum folklore suggests. ZFS works on modest systems; the ARC simply uses free memory and gives it back under pressure. More RAM improves cache hit rates on busy pools. The big exception is deduplication, which keeps a large table of block hashes and can need a lot of memory; most home users should leave it off and use compression instead.
ECC memory is recommended for any server whose job is keeping data safe, but it isn't a special ZFS requirement. Our guide to ECC RAM covers the debate.
Planning a Pool
- Decide the vdev layout first. It's the hardest thing to change. RAIDZ2 for bulk storage on large disks; mirrors for VMs and databases.
- Buy disks of the same size within a vdev.
- Set `ashift=12` (4K sectors) when creating the pool; it can't be changed later.
- Enable LZ4 compression at the pool root.
- Leave free space. Performance drops as a pool fills; plan to stay below about 80% full.
- Create datasets per purpose with their own snapshots and quotas.
- Schedule scrubs and snapshots, and alert on errors.
- Keep backups elsewhere. Snapshots on the same pool don't protect against losing the pool. Our home server vs NAS guide covers the hardware side.
Is ZFS Worth It?
Is ZFS worth it for you? For a NAS, file server, backup target or virtualisation host holding data you care about, usually yes: checksums, snapshots and replication solve real problems that ext4 on mdadm doesn't. For a laptop, a single-disk desktop or a throwaway cloud server, the planning and memory overhead often aren't worth it, and a simpler filesystem is fine.
Common Mistakes
- Adding a single disk to a redundant pool as a new vdev, making the whole pool depend on it.
- Using RAIDZ1 with large disks for important data.
- Filling the pool close to 100%.
- Turning on dedup without understanding its memory cost.
- Using hardware RAID underneath ZFS. Give ZFS the raw disks through an HBA in IT mode.
- Treating snapshots as backups.
FAQ
Is ZFS good for a home NAS?
Yes. Its checksums, snapshots and RAIDZ protect data well, and NAS operating systems such as TrueNAS make it easy to manage.
Can I add disks to a ZFS pool later?
You can always add another vdev. Since OpenZFS 2.3, you can also add a disk to an existing RAIDZ vdev with RAIDZ expansion.
Does ZFS work on Linux?
Yes, through OpenZFS, as a kernel module. Some distributions, such as Ubuntu, package it directly; others need it installed separately.
Is ZFS faster than ext4?
Not always. ext4 is often faster on a single disk for simple workloads. ZFS can be faster on pools with large caches and compression, but its main advantage is data integrity, not raw speed.
What does a ZFS scrub do?
It reads every block in the pool, checks it against its checksum and repairs damaged blocks from redundant copies or parity.