Sub topic 11
RAID 5: Distributed Parity
This chapter assumes you know what striping and parity are (from the RAID building blocks chapter) and that you can read basic Python. RAID 5 is the most common parity-based array on the A+ exam.
How RAID 5 works
RAID 5 stripes data across three or more drives. For each stripe, one block holds parity instead of data. Parity is the XOR of the data blocks in that stripe. The parity block rotates from drive to drive, so no single drive becomes a bottleneck. This is why it is called distributed parity.
Key facts for the exam
| Property | RAID 5 |
|---|---|
| Minimum drives | 3 |
| Fault tolerance | One drive failure |
| Usable capacity | (N − 1) × drive size |
| Read performance | Good |
| Write performance | Slower, because parity must be recalculated |
Why XOR can rebuild a lost drive
XOR has a useful property. If you XOR all the surviving blocks with the parity block, you get the missing block back. The controller does this for every stripe when a drive fails.
# Three data blocks striped across three drives (4-bit values for readability)
a = 0b1010
b = 0b0110
c = 0b1100
# The parity block is the XOR of all data blocks
parity = a ^ b ^ c
print(format(parity, "04b")) # 0000
# If the drive holding b fails, XOR the survivors to rebuild it
rebuilt_b = a ^ c ^ parity
print(format(rebuilt_b, "04b")) # 0110
print(rebuilt_b == b) # TrueDegraded mode and rebuilds
When one drive fails, the array keeps working in degraded mode. Reads of the missing data are computed on the fly from the other drives, so performance drops. You replace the failed drive, and the controller rebuilds its contents onto the new one. A hot spare, covered in a later chapter, can start this rebuild automatically.
A second failure during a degraded state or rebuild destroys the array. Rebuilds stress every remaining drive, and large drives take many hours to rebuild. This is the main reason RAID 6 exists.
Common errors
- Using two drives. RAID 5 needs at least three.
- Mixing drive sizes and expecting all the space. The array uses the smallest drive's size for every member.
- Calculating capacity as N × size. One drive's worth of space always goes to parity.
- Treating RAID 5 as a backup. It does not protect against deletion, malware, or controller failure.
Capacity check
Four 2 TB drives in RAID 5 give (4 − 1) × 2 = 6 TB usable. Eight of those drives give 14 TB. The parity overhead shrinks as you add drives, but the risk of a second failure grows.
Exercise
A technician builds a RAID 5 array from five 4 TB drives. How much usable capacity does it have, and how many drive failures can it survive?
Show answer
Usable capacity is (5 − 1) × 4 TB = 16 TB. The array survives one drive failure.
Exercise
An array in RAID 5 is running slowly after a drive failed, but users can still open files. What state is the array in, and what should the technician do?
Show answer
The array is in degraded mode. The technician should replace the failed drive promptly so the array can rebuild, and confirm that a current backup exists in case a second drive fails.