How do I calculate the parity bit? In a RAID 3 odd parity with 5 disks. How do I get the parity bit?
The answer was
But I want to know how is this calculated?
How do I calculate the parity bit? In a RAID 3 odd parity with 5 disks. How do I get the parity bit?
The answer was
But I want to know how is this calculated?
Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here. If this question can be reworded to fit the rules in the help center, please edit the question.
"Odd parity" means the sum of all the its is odd. This is the same as saying the number of 1 bits is odd. So if the number of one bits is odd, the parity bit must be 0 to keep it that way. If it's even, the parity bit must be 1 to make it odd.
The parity is calculated via a logical "exclusive-or" operation, XOR.
It results in true (1
) if one or the other of the values that it's calculating on is true, but not if both are true - if neither or both values are true, the result is false (0
). Using this logic, the array generates extra data that it is able to use to reconstruct the data on a lost disk.
The catch with odd-parity is that it's reversed - if the XOR operation results in a 1
, a 0
is stored instead. I'm not 100% sure, but I don't believe that odd parity gets much use in the real world.
So, in the examples above, the second row:
1(disk0) XOR 0(disk1) = 1
1(last result) XOR 1(disk2) = 0
0(last result) XOR 1(disk3) = 1 (result of the XOR across the entire row)
In odd parity, flip the result and that's the result bit; 0
, in this case.
The reason that this is interesting and useful? Let's say disk 2 is lost, and you need to figure out what was in it.
1(parity bit from disk4) XOR 1(disk0) = 0
0(last result) XOR 0(disk1) = 0
0(last result) XOR 1(disk3) = 1 (calculated disk2 data)
Using the parity, data from a lost disk can be reconstructed with the data from the parity disk plus all of the other disks - this is the reason that this type of RAID group can tolerate the loss of any one disk, but will fail if a second disk fails.