Theory: RAID Levels & Usable Capacity
Disks are the part of a server most likely to fail. RAID lets a server lose a disk and keep running. This lesson covers the three building blocks (striping, mirroring, parity), the common RAID levels, how to calculate usable capacity, why rebuilds are dangerous, how to choose a level, and the most important limit of all: RAID is not backup.
What Is RAID?
RAID (Redundant Array of Independent Disks) combines many physical disks into one logical disk. Its main goal is to keep the system running when a disk fails.
RAID is built from three techniques:
| Technique | How it works | Goal |
|---|
| Striping | Split data into blocks and spread them across disks (A1 on disk 1, A2 on disk 2, …) | Speed: disks work in parallel |
| Mirroring | Write the same data to two disks (A1 on disk 1, A1 on disk 2) | A full copy |
| Parity | Store a calculated value P from which lost data can be rebuilt (A1, A2, P) | Protection with less waste than mirroring |
RAID 0: Striping
File A is split into blocks A1–A8; odd blocks go to disk 1 and even blocks to disk 2, so both disks work at the same time.
| Disk 1 | Disk 2 |
|---|
| A1 | A2 |
| A3 | A4 |
| A5 | A6 |
| A7 | A8 |
- Fastest level, and 100% of capacity is usable.
- No protection: if one disk fails, ALL data is lost (every file has blocks on both disks).
- Use for temporary data that can be recreated.
Common mistake: RAID 0 is not really “redundant”. It is about speed only, and it is less reliable than a single disk, because any one of several disks failing destroys everything.
RAID 1: Mirroring
Every block is written to both disks.
| Disk 1 | Disk 2 (copy) |
|---|
| A1 | A1 |
| A2 | A2 |
| A3 | A3 |
- Survives one disk failure: the copy keeps working.
- Simple rebuild: just copy the surviving disk to the new one.
- Only 50% capacity with two disks: pay for 2 disks, use 1.
- Use for OS disks and small critical servers.
RAID 1 buys safety by paying for twice the disks. (A mirror can have more than two copies, an N-way mirror; usable space is still one disk.)
How Parity Works (XOR)
Parity uses the XOR (exclusive OR, ⊕) operation, applied bit by bit:
| a | b | a⊕b |
|---|
| 0 | 0 | 0 |
| 1 | 1 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
Rule of thumb: same → 0, different → 1. The key property is that XOR undoes itself: if P=D1⊕D2, then D2=D1⊕P and D1=D2⊕P.
Mini-example: write, lose, rebuild
1. Write data and parity. D1=1010, D2=0110:
P=D1⊕D2=1010⊕0110=1100
2. Disk 2 fails. Its contents are unknown (????). Rebuild from the survivors:
D2=D1⊕P=1010⊕1100=0110
This matches the original D2 ✓. Lost data is calculated back from the survivors. With more data disks the same rule applies: parity is the XOR of all data blocks in the stripe, and any one missing block equals the XOR of all the others.
What if two disks fail at the same time? With single parity you now have one equation and two unknowns, so the data cannot be rebuilt. That is why RAID 6 adds a second parity block.
RAID 5 and RAID 6
| RAID 5: single parity | RAID 6: double parity |
|---|
| Parity blocks per stripe | 1 (P) | 2 (P and Q) |
| Minimum disks | 3 | 4 |
| Failures survived | 1 | 2 |
| Usable disks | N−1 | N−2 |
Example layouts (each row is one stripe):
| RAID 5 | Disk 1 | Disk 2 | Disk 3 |
|---|
| Stripe A | A1 | A2 | Pa |
| Stripe B | B1 | Pb | B2 |
| Stripe C | Pc | C1 | C2 |
| RAID 6 | Disk 1 | Disk 2 | Disk 3 | Disk 4 |
|---|
| Stripe A | A1 | A2 | Pa | Qa |
| Stripe B | Pb | Qb | B1 | B2 |
| Stripe C | Qc | C1 | C2 | Pc |
Parity is spread across all disks, so no single disk becomes a bottleneck (every write must update parity, and rotating it shares that work).
RAID 10: Mirror, then Stripe
Disks are first paired into mirrors, then data is striped across the pairs.
| Mirror pair 1: Disk 1 | Disk 2 | Mirror pair 2: Disk 3 | Disk 4 |
|---|
| A1 | A1 | A2 | A2 |
| A3 | A3 | A4 | A4 |
- Fast reads and writes, and a fast rebuild (a simple copy from the partner disk, no parity maths).
- Survives 1 disk per pair: two failures in different pairs = still running; two failures in the same pair = data lost.
- 50% capacity, minimum 4 disks.
- Use for busy databases.
Calculating Usable Capacity
Let N = number of disks and S = size of one disk.
Usable capacity formulas
RAID 0RAID 1RAID 5RAID 6RAID 10=N×S=S(N-way mirror)=(N−1)×S=(N−2)×S=2N×S
Example: 6 × 4 TB (24 TB raw)
| Level | Formula | Usable | Failures survived |
|---|
| RAID 0 | 6×4 | 24 TB | 0 |
| RAID 5 | (6−1)×4 | 20 TB | 1 |
| RAID 6 | (6−2)×4 | 16 TB | 2 |
| RAID 10 | (6×4)/2 | 12 TB | 1 guaranteed (up to 3, if each is in a different pair) |
| RAID 1 | 4 (6-way mirror) | 4 TB | 5 |
More usable space usually means less protection.
Rebuild Risk and Hot Spares
When a disk fails, the array goes through four states:
Diagram loads as you scroll.
The real danger is a second disk failing during the rebuild. The rebuild reads every block of every surviving disk, which puts heavy load on the rest of the disks, which are often the same age and from the same batch. A RAID 5 array that loses a second disk during rebuild loses everything.
A hot spare is an idle disk already installed in the server. When a disk fails, the rebuild starts automatically, with no waiting for someone to notice, buy and insert a replacement. This shortens the time spent degraded.
Large disks = long rebuilds. For big disks prefer RAID 6 (still protected during the rebuild) or RAID 10 (fast copy rebuild), and keep a hot spare.
Choosing RAID at MediCare Plus
| System | Need | Choice | Why |
|---|
| EMR database | Fast and always on | RAID 10 | Best speed; fast rebuild by copying |
| Imaging & file server | Large capacity, safe | RAID 6 | Survives 2 disk failures; good capacity |
| Temporary workspace | Speed only | RAID 0 | Data can be recreated; failure is OK |
The management question is always: what does an outage cost, compared with what the protection costs?
RAID Is Not Backup
| Event | RAID helps? | Backup helps? | Why |
|---|
| One disk fails | ✓ | ✓ (slower) | RAID keeps running; a backup needs a restore |
| File deleted by mistake | ✗ | ✓ | The deletion hits all disks at once |
| Ransomware encrypts data | ✗ | ✓ | Encrypted data is written to all disks |
| Fire or flood in the server room | ✗ | ✓ only if offsite | All disks are in one room; needs an offsite copy |
| Data corrupted | ✗ | ✓ | RAID copies bad data faithfully |
RAID protects against hardware failure. Backup protects against data loss. RAID copies every write, good or bad, to every disk, instantly.
Immutable / WORM Storage
Backups only help if the attacker cannot destroy them. Immutable or WORM (Write Once, Read Many) storage guarantees that:
- Write once: data is stored once.
- Nobody can change or delete it, not even an admin, until the retention period ends.
- Read many: it can be read (restored) as often as needed.
| Where it is used | Why it beats ransomware | Trade-offs |
|---|
| Object lock on cloud storage, immutable cloud backup vaults, WORM tape | A stolen admin password still cannot delete or encrypt it | Only the admin-proof mode really protects; longer retention = higher cost |
Link to Week 8: the same idea protects logs and evidence from being changed, which is an integrity control.
Worked Examples
Exercise 1
A RAID 5 array has three data disks and one parity block per stripe. In one stripe, D1=1011, D2=0110, D3=1100.
- (a) Calculate the parity P.
- (b) Disk 2 fails. Rebuild D2 from the survivors.
Show solution ↓Hide solution ↑
Solution
(a) Parity is the XOR of all data blocks. Work two at a time, bit by bit (same → 0, different → 1):
D1⊕D2=1011⊕0110=1101P=1101⊕D3=1101⊕1100=0001(b) The missing block is the XOR of everything that survived:
D1⊕D3=1011⊕1100=0111D2=0111⊕P=0111⊕0001=0110Answer: (a) P=0001; (b) D2=0110, which matches the original value ✓.
Exercise 2
MediCare Plus buys 8 disks of 2 TB for the imaging server. Calculate the usable capacity with RAID 5, RAID 6 and RAID 10. Which level should be used, and why?
Show solution ↓Hide solution ↑
Solution
N=8, S=2 TB, raw capacity =8×2=16 TB.
| Level | Working | Usable | Failures survived |
|---|
| RAID 5 | (8−1)×2 | 14 TB | 1 |
| RAID 6 | (8−2)×2 | 12 TB | 2 |
| RAID 10 | (8×2)/2 | 8 TB | 1 guaranteed (up to 4 in different pairs) |
Choice: RAID 6. Imaging needs large capacity and safety, not maximum write speed.
- RAID 5 gives 2 TB more, but survives only one failure; a second failure during a long rebuild loses every image.
- RAID 10 is fast but wastes half the disks (only 8 TB), and imaging is not a busy transactional database.
- RAID 6 keeps 12 TB (75% of raw) and survives 2 disk failures, so the array is still protected while it rebuilds.
Answer: RAID 5 = 14 TB, RAID 6 = 12 TB, RAID 10 = 8 TB; choose RAID 6.
Exercise 3
A RAID 10 array has 8 disks in four mirror pairs: (1, 2), (3, 4), (5, 6), (7, 8). For each set of failed disks, say whether data survives.
- (a) Disks 1 and 3
- (b) Disks 1 and 2
- (c) Disks 2, 4, 6 and 8
- (d) Disks 5, 6 and 7
Then: if disk 1 has already failed, what is the chance that a random second failure destroys the array?
Show solution ↓Hide solution ↑
Solution
The rule: RAID 10 loses data only if both disks of the same pair fail.
| Set | Pairs hit | Result |
|---|
| (a) 1, 3 | pair 1 once, pair 2 once | Survives |
| (b) 1, 2 | pair 1 twice | Data lost |
| (c) 2, 4, 6, 8 | each pair once | Survives (4 failures!) |
| (d) 5, 6, 7 | pair 3 twice | Data lost |
Second failure: 7 disks remain, and only one of them (disk 2, the partner of disk 1) is fatal.
P(fatal)=71≈14%Answer: (a) survives, (b) lost, (c) survives, (d) lost; chance of a fatal second failure = 1/7. This is why RAID 10 “guarantees” only 1 failure even though it can sometimes survive many.
Exercise 4
A RAID 5 array uses 16 TB disks. During a rebuild, the controller can write the replacement disk at about 100 MB/s (1 TB = 1012 bytes, 1 MB = 106 bytes).
- (a) Roughly how long does the rebuild take?
- (b) Why is this a risk, and what two changes reduce it?
Show solution ↓Hide solution ↑
Solution
(a) The whole 16 TB disk must be rebuilt.
t=100×106 B/s16×1012 B=10816×1012=160000 s160000 s÷3600≈44.4 h≈1.9 days(b) For almost two days the array is degraded: RAID 5 has already used its one allowed failure, so a second failure loses all the data. The rebuild also puts heavy load on the remaining disks, which makes a second failure more likely. (In practice the rebuild is often slower than this, because users keep working on the array.)
Two changes:
- Use RAID 6, so the array still survives one more failure during the rebuild.
- Add a hot spare, so the rebuild starts automatically instead of waiting for someone to replace the disk.
Answer: about 44 h (≈ 1.9 days); switch to RAID 6 and add a hot spare.
Exercise 5
(In-class review) The pharmacy server uses RAID 6. It is also backed up every night to immutable storage. For each event, say whether RAID helps and whether the backup helps, with a one-line reason.
- (a) One disk fails at 10:00.
- (b) A pharmacist deletes the drug price list by mistake.
- (c) Ransomware encrypts the whole server.
Show solution ↓Hide solution ↑
Solution
Ask for each event: is it a hardware problem (RAID’s job) or a data problem (backup’s job)?
| Event | RAID helps? | Backup helps? | Reason |
|---|
| (a) One disk fails | ✓ | ✓ (not needed) | RAID 6 survives up to 2 failures, so the server keeps running with no data loss; a restore would only cost downtime and the changes since last night |
| (b) Price list deleted | ✗ | ✓ | The deletion is written to all disks at once; restore the file from last night’s backup (today’s edits to it are lost) |
| (c) Ransomware | ✗ | ✓ | Encrypted data is written to all disks; the immutable backup cannot be changed or deleted, even with a stolen admin password |
Answer: (a) RAID ✓ (backup not needed); (b) RAID ✗, backup ✓; (c) RAID ✗, backup ✓.
Exercise 6
Choose a RAID level for each system and justify it in one line.
- (a) A video-editing scratch area whose files are copied from originals each morning.
- (b) The operating-system disks of a small domain controller (2 disks).
- (c) A busy pharmacy order database that must be fast and rebuild quickly.
- (d) A 12-disk archive of scanned paper records where capacity matters most but losing the array is unacceptable.
Show solution ↓Hide solution ↑
Solution
| System | Choice | Justification |
|---|
| (a) Scratch area | RAID 0 | Data can be recreated; speed and 100% capacity matter, failure is acceptable |
| (b) OS disks, 2 disks | RAID 1 | Simple mirror for a small critical server; survives one failure with a simple rebuild |
| (c) Busy database | RAID 10 | Fastest for heavy reads and writes; rebuild is a simple copy from the partner |
| (d) 12-disk archive | RAID 6 | (12−2)/12≈83% usable and survives 2 failures during long rebuilds |
And for every one of them: RAID is not backup, so the important data in (b), (c) and (d) still needs real backups.