WeRecoverData

RAID-Z, RAID-Z2 and RAID-Z3: how ZFS parity levels differ

RAID-Z is ZFS's integrated parity RAID. Unlike a hardware controller sitting beneath a file system, the file system and the RAID layer are the same thing: ZFS writes variable-width stripes using copy-on-write, so a stripe is either fully committed or not committed at all. That removes the classic parity write hole, and it also changes what a failed pool looks like in the laboratory. The tables below compare the three parity levels, contrast RAID-Z with conventional RAID 5 and 6, and list the failure modes we actually see on ZFS pools.

RAID-Z parity levels compared

RAID-Z parity levels compared
LevelParity devices per vdevMinimum disks (practical)Disks that can failUsable capacity (n disks)Resilver exposureTypical use
RAID-Z1 (RAID-Z)131(n − 1)/nA second disk failure during resilver loses the vdev, and with it the whole poolSmall pools built from small, low-latency disks
RAID-Z2242(n − 2)/nStill tolerates one further failure while resilveringThe general-purpose choice for most production pools
RAID-Z3353(n − 3)/nTolerates two further failures while resilveringWide vdevs and high-capacity disks where resilvers run for days

RAID-Z compared with conventional RAID 5 and RAID 6

RAID-Z compared with conventional RAID 5 and RAID 6
PropertyRAID-Z (ZFS)Hardware / software RAID 5 and 6
Parity write holeNot present — copy-on-write means a stripe is never partially updated in placePresent unless the controller has a battery- or flash-backed cache
Stripe widthVariable; each record is written across as many disks as it needsFixed stripe size configured at array creation
Integrity checkingEvery block is checksummed; scrub verifies and repairs from parityParity is normally only consulted during a rebuild; silent corruption can go undetected
Rebuild scopeResilver copies only allocated blocks, so an empty pool resilvers quicklyRebuild reads and writes every sector regardless of use
Layout knowledge needed for recoveryRead from the on-disk ZFS labels and uberblocks rather than vendor metadataMember order, stripe size, parity rotation and offset must be solved
ExpansionHistorically by adding whole vdevs; single-disk expansion depends on the ZFS implementation and version in useMany controllers support online capacity expansion of an existing array
Effect of a controller changePools are portable between hosts because layout metadata lives on the disksOften controller-specific; a different controller may not import the array

RAID-Z failure modes and what determines recoverability

RAID-Z failure modes and what determines recoverability
What happenedWhy it is difficultWhat determines the outcome
More disks failed than the vdev has parity (2 on Z1, 3 on Z2, 4 on Z3)The pool cannot be imported; a single unrecoverable vdev takes the whole pool offlineWhether the failed members can be individually imaged well enough to reconstruct the missing stripes
Resilver started and then failed or was interruptedPartly rewritten state on the replacement device alongside a degraded vdevStop further resilver attempts; recovery works from images of the pre-resilver members
Pool labels or uberblocks damagedZFS refuses to import a pool whose metadata does not verifyWhether an earlier uberblock or a redundant label copy can be used as a rollback point
Accidental zpool destroy, dataset or zvol deleteSpace is released and copy-on-write may reuse it on the next writeHow much has been written since; the pool should be taken offline immediately
Snapshot or dataset removed and the pool kept in serviceFreed blocks become allocation candidatesTime and write volume between the deletion and taking the pool offline
HBA, cable or expander corruptionBad data is written and checksummed as valid on arrivalScrub history and whether known-good copies of the affected blocks exist
Whole batch of identical disks aging out togetherMultiple members reach their failure point within the same window, often during a resilverHow many members are still readable and how much of each can be imaged
ZFS native encryption or a self-encrypting disk set, key unavailableThe blocks can be recovered as ciphertext but not decodedAvailability of the encryption key or passphrase; without it the plaintext cannot be produced

Notes