One disk in your NAS dies, and every file is still there. That is not luck but arithmetic – and the same arithmetic preserves your mistakes just as faithfully.
The short answer
Parity is extra information computed from the data on several disks, from which the contents of one failed disk can be recalculated. How does parity work? In the simplest case with XOR: RAID 5 stores one such parity value, while RAID 6 adds a second, independent value and survives the loss of any two drives [2]. ZFS uses the idea in RAID-Z with one, two or three parity disks per group [3], and the classic Unraid array uses up to two dedicated parity drives [4]. Our assessment: parity protects you against a failing disk, not against deleting, overwriting or encrypting files. It is no backup.
How it works
- XOR in one line. XOR gives 1 when an odd number of inputs are 1. With the bits A = 1, B = 0 and C = 1 the parity is 0. If disk B fails, XOR of A, C and the parity gives 1 XOR 1 XOR 0 = 0, and B is back. Anvin's paper on RAID 6 calls this value P the ordinary XOR parity [2].
- From RAID 5 to RAID 6. The Berkeley report from 1987 introduced five levels of RAID and compared their cost and performance [1]. RAID 6 adds a second value Q, a Reed-Solomon code computed in the Galois field GF(2^8), so that any two drives may fail [2].
- RAID-Z in ZFS. The vdev types raidz1, raidz2 and raidz3 store single, double or triple parity [3]. A group of N disks of size X with P parity disks holds about (N−P)×X, and it needs at least one disk more than its parity count [3]. RAID-Z also eliminates the RAID-5 "write hole", where data and parity no longer match after a power loss [3].
- Unraid. The classic Unraid array takes up to two parity drives, and each must be at least as large as the largest data disk [4]. A new data disk may not be larger than the parity drives, and it is cleared before it joins a parity-protected array [5]. After you assign parity, a parity sync runs in the background; until it finishes, the array is unprotected [4].
- The rebuild. To recreate a failed disk, the array reads the remaining disks and recalculates the missing data from them [2]. Our reading: during that time an array with single parity has no reserve left, and a second failure costs data. That is the case for RAID 6, RAID-Z2 or dual parity.
- Why it is no backup. Parity follows every write. If you delete a file or ransomware encrypts it, parity faithfully protects the damaged state.
A practical example
Take four disks of 8 TB each. As RAID 5 or RAID-Z1 you get about (4 − 1) × 8 = 24 TB and may lose one disk; as RAID 6 or RAID-Z2 you get about 16 TB, and any two may fail [2][3]. In Unraid, the same disks give 24 TB with one parity drive and 16 TB with two [4]. If you later buy a 12 TB disk and use single parity, it first has to replace the parity drive, because no data disk may be larger than parity [5]. This is a calculation, not a setup we run.
Checklist
- Choose the parity level by how many disk failures you must survive during a rebuild [2][3].
- Make every Unraid parity drive at least as large as your largest data disk [4].
- Wait for the first parity sync to finish before you copy important data [4].
- Schedule regular parity checks or scrubs, so that errors show up before a disk fails.
- Keep a separate backup, because parity does not bring back deleted or encrypted files.