Skip to content

Lesson 4 of 9 · 28m

ZFS Pools, VDEVs, and Layout Decisions That Hurt Later

Understand vdev topology, mirrors versus raidz, recordsize, ashift, compression, and why pool layout is difficult to retrofit.

ZFS rewards careful design and punishes vibes. It is not a single RAID level you choose at install time; it is a storage pool built from virtual devices, each with its own redundancy and performance behavior. The painful part is that many layout decisions are effectively permanent. You can add vdevs, but you generally cannot reshape existing ones in place.

Pools are stripe collections of vdevs

zpool status tank
zpool list -o name,size,alloc,free,fragmentation,capacity,health

Conceptually:

pool: tank
  vdev: mirror-0    disk1 + disk2
  vdev: mirror-1    disk3 + disk4
  vdev: mirror-2    disk5 + disk6

ZFS stripes writes across the top-level vdevs. Losing one disk in a mirror degrades that mirror; losing both disks in the same mirror destroys the entire pool. This is why "the pool has six disks" is not a redundancy statement. Topology is the redundancy statement.

Mirrors versus raidz

Mirrors usually win for latency-sensitive, random I/O workloads and simpler expansion. They cost capacity. raidz1, raidz2, and raidz3 are capacity-efficient but have more complicated write and rebuild behavior. For large disks, raidz2 is a common minimum because rebuilds are long and double parity buys time. Wide raidz vdevs can be efficient for archival data, but they change IOPS and space accounting in ways newcomers often misjudge.

Set physical properties correctly at creation

ashift tells ZFS the disk sector size as a power of two. Modern disks are usually 4 KiB physical sectors, meaning ashift=12 even when they emulate 512-byte sectors:

zpool create -o ashift=12 -O compression=lz4 -O atime=off   tank mirror /dev/disk/by-id/ata-...-part1 /dev/disk/by-id/ata-...-part1

Use stable disk IDs rather than /dev/sda names. Device letters move; serial-based paths do not. Enable lz4 compression almost universally unless you have measured a reason not to. Disable atime unless an application truly depends on it.

Recordsize and workload shape

ZFS stores files in blocks up to recordsize, defaulting historically to 128 KiB. Large sequential files benefit from large blocks. Small random-write databases often do better with smaller records or dedicated volume tuning because partial-block rewrites amplify I/O:

zfs create -o recordsize=16K tank/postgres
zfs create -o recordsize=1M tank/media

Do not copy tuning numbers blindly. Benchmark with representative workloads and understand write amplification before changing defaults across every dataset.

Special vdevs, cache, and expectations

A special vdev for metadata can help a pool with huge numbers of small files, but losing it can kill the pool; it needs the same redundancy seriousness as data vdevs. L2ARC is read cache, not a substitute for RAM. SLOG devices only accelerate synchronous writes and must be low-latency, power-loss protected devices. Adding cache toys to a badly laid out pool does not fix the layout.

Field notes

  • ZFS expands by adding vdevs; it does not casually rebalance existing data across new vdevs.
  • A single-vdev pool has no redundancy even if the filesystem checksums every block.
  • Use zpool status -v and zpool get all when inheriting a system; defaults hide important history.
  • Deduplication is almost never the free space win it appears to be; RAM and metadata costs are severe.
  • Test zpool import with the disks detached from normal boot assumptions before depending on portability.

Was this lesson helpful?

Sign in to rate