Task 3 โ Database Recovery with RAID 4 18 marks
Six data disks, one dedicated parity disk, 4-bit blocks. Draw the structure (6), compute the parity block, and recover D5 after a disk failure โ plus 12 viva marks.
What RAID 4 is
RAID (Redundant Array of Independent Disks) Level 4 = block-level striping with a dedicated parity disk. Data is split into fixed-size blocks written across the data disks; a seventh disk stores a parity block computed as the bitwise XOR of the corresponding blocks on every data disk. Any one failed disk can be rebuilt by XOR-ing everything that survives.
3(a) โ RAID Level 4 structure
3(b) โ Parity calculation
Blocks stored in the array:
| Block | Description | 4-bit value | Disk |
|---|---|---|---|
| Block 1 | Employee data | 1010 | D1 |
| Block 2 | Department data | 1100 | D2 |
| Block 3 | Attendance data | 0111 | D3 |
| Block 4 | Leave data | 1001 | D4 |
| Block 5 | Salary data | 0011 | D5 |
| Block 6 | Designation data | 1110 | D6 |
Method 1 โ bit-by-bit (count the 1s)
XOR of a column = 0 if the number of 1s is even, 1 if it is odd (even parity).
| Bit position | D1 | D2 | D3 | D4 | D5 | D6 | # of 1s | P = XOR |
|---|---|---|---|---|---|---|---|---|
| Bit 3 (MSB) | 1 | 1 | 0 | 1 | 0 | 1 | 4 (EVEN) | 0 |
| Bit 2 | 0 | 1 | 1 | 0 | 0 | 1 | 3 (ODD) | 1 |
| Bit 1 | 1 | 0 | 1 | 0 | 1 | 1 | 4 (EVEN) | 0 |
| Bit 0 (LSB) | 0 | 0 | 1 | 1 | 1 | 0 | 3 (ODD) | 1 |
Method 2 โ running XOR, block by block
| Step | Operation | Result |
|---|---|---|
| 1 | 1010 โ 1100 | 0110 |
| 2 | 0110 โ 0111 | 0001 |
| 3 | 0001 โ 1001 | 1000 |
| 4 | 1000 โ 0011 | 1011 |
| 5 | 1011 โ 1110 | 0101 |
Parity disk stores P = 0101 โ and both methods agree, which is the check you should show in the viva.
3(c) โ Recovering the failed disk D5
D5 (Salary data) fails. XOR is its own inverse, so from P = D1 โ D2 โ D3 โ D4 โ D5 โ D6 we can XOR both sides by every surviving disk:
D5 = P โ D1 โ D2 โ D3 โ D4 โ D6
Bit-by-bit
| Bit position | P | D1 | D2 | D3 | D4 | D6 | # of 1s | D5 = XOR |
|---|---|---|---|---|---|---|---|---|
| Bit 3 (MSB) | 0 | 1 | 1 | 0 | 1 | 1 | 4 (Even) | 0 |
| Bit 2 | 1 | 0 | 1 | 1 | 0 | 1 | 4 (Even) | 0 |
| Bit 1 | 0 | 1 | 0 | 1 | 0 | 1 | 3 (Odd) | 1 |
| Bit 0 (LSB) | 1 | 0 | 0 | 1 | 1 | 0 | 3 (Odd) | 1 |
Running XOR
| Step | Operation | Result |
|---|---|---|
| 1 | 0101 โ 1010 | 1111 |
| 2 | 1111 โ 1100 | 0011 |
| 3 | 0011 โ 0111 | 0100 |
| 4 | 0100 โ 1001 | 1101 |
| 5 | 1101 โ 1110 | 0011 |
Recovered D5 = 0011 โ exactly the original Salary-data block (
0011). A single-disk failure is fully recovered from parity: that is the reliability guarantee of RAID 4. Why this matters for recovery โ and RAID 4โs limits
| Property | RAID 4 |
|---|---|
| Disks tolerated failing | Exactly one. Two failures in a stripe lose the data โ one equation, two unknowns. |
| Storage overhead | 1 disk out of 7 โ 14 % (vs 50 % for RAID 1 mirroring). |
| Reads | Fast and parallel โ different blocks come from different disks; P is not read. |
| Writes | Bottlenecked. Every write updates P, so the parity disk serialises all writes (the โsmall writeโ problem). |
| Efficient parity update | Pnew = Pold โ Dold โ Dnew โ 2 reads + 2 writes, no need to read every disk. |
| Comparison | RAID 0 = striping, no redundancy ยท RAID 1 = mirroring ยท RAID 5 = RAID 4 with parity distributed across all disks (removes the bottleneck) ยท RAID 6 = two parity blocks, survives two failures. |
RAID protects against media/disk failure only. It is not a backup: a wrong
DELETE, a dropped table or a ransomware write is faithfully striped across all disks. Full database recovery still needs log-based recovery (undo/redo, WAL, checkpoints) plus off-site dumps โ mention this, it is a favourite follow-up question.