How to calculate RAID Parity Bit? [closed]

How do I calculate the parity bit? In a RAID 3 odd parity with 5 disks. How do I get the parity bit?

But I want to know how is this calculated?

-

closed as off topic by Jason Berg, EEAA♦, gWaldo, Iain, MDMarraNov 19 '11 at 22:14

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.

Homework question? RAID 3 is bad and nobody uses it. – Nic Nov 19 '11 at 4:14
Why ever would you need to know this?! The only thing that I can think of is that you're writing a RAID Controller! Also, don't use RAID3; use RAID5 or 6 – gWaldo Nov 19 '11 at 4:14
@Nic, yes homework. Computer Organization to be exact :) Just for knowledge? What is commonly used? RAID0 & 1 for home, 5 for enterprise? I suppose there are higher levels ones that I missed? – Jiew Meng Nov 19 '11 at 6:24
@gWaldo, like Nic mentioned, its homework. I also don't know why the want to teach a CS student just low level stuff actually. Its only useful if you really specialize into maybe hardware? Or hardcore optimization etc I'd say – Jiew Meng Nov 19 '11 at 6:26
Agreed, @jiewmeng - Nic got his comment in 4 seconds before I did... – gWaldo Nov 19 '11 at 19:33

"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.

-