RAID 5 uses a technique that (1) writes a block of data across several disks (i.e., striping), (2) calculates a code from this data and stores the code on another disk (i.e., parity), and (3) in the event of a single-disk failure, uses the data on the working drives and the calculated code to "interpolate" what the missing data should be (i.e., rebuilding). A RAID 5 array "rotates" data and parity among all the drives on the array, in contrast with RAID 3, which stores all calculated parity values on one particular drive. The following is a simplified explanation of how RAID 5 calculates ECCs (error-correction codes).
Say, for example, that you have a five-drive array on which
you intend to store four values: The numbers 172, 106, 240, and 156. For the purpose of this example, the RAID controller stores the value 172 as the binary number 10101100 on disk 1 of the array, the value 106 as the binary number 01101010 on disk 2, and so on as shown in the table
"Error Detection: Bit by Bit"
. When our four values have been written to disks 1 through 4, the RAID controller examines the sum of each bit position. If the sum of the numbers of bit position x on disks 1 through 4 is an odd number, then the value of that bit position on disk 5 is assigned a 1; if the sum is an even number, the bit position on disk 5 is assigned a 0.
Now assume that disk 2 fails. The RAID controller can no longer see the value 0 at bit 7 on disk 2. However, the controller knows that its value can be only a 0 or a 1. And as disks 1, 3, 4, and 5 are still operating, the controller can perform the following calculation: 1 + ? + 1 + 1 = an odd number. Since 1 + (0) + 1 + 1 = an odd number
(3), the missing value on disk 2 must be 0. The RAID controller then performs the same calculation for the remaining bit positions. In this way, data missing due to a drive failure is rebuilt.
A RAID controller examines the sum of each bit position to assign an
even or an odd number to disk 5. If a disk fails, it assigns a 0 or a
1 to the missing value and performs a simple calculation. It repeats
this process across each bit position, rebuilding the data as it goes.
CONTENTS
ON DISK: BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0
Disk 1 172 1 0 1 0 1 1 0 0
Disk 2 106 0 1 1 0 1 0 1 0
Disk 3 240 1 1 1 1 0 0 0 0
Disk 4 156 1 0 1 1 1 1 0 0
Sum odd even even even odd even odd even
Disk 5 (parity) 1 0 0 0
1 0 1 0