Sunday 24 October 2010

How raid 5 works and the parity calculated

RAID 5, required 3 disks minimum. The total storage afterward is (n-1) disk capacity, and YES all disks must have same size.

How they calculate it the parity is like this:

disk1 disk2 disk3 .... diskLast
0 1 0 parity:disk1 XOR disk2 then the result is XOR to disk3
parity 0 0 1

Above example of disk stripe segment of 1 bit, in real world the normal ones is between 4bits to 256bits.


The magic is when disk1/2/3 failed, it can rebuild from the result, as following:
disk2 XOR disk3 then XOR to parity(above is in diskLast) = disk1

It is not magic though, it is only about:
if bits same then it friend (0 XOR 0 = 0 (friends) 1 XOR 1 = 0 (friends) )
if bits differs then it is enemy.
So from the friend/enemy, you can figure the other bit from the partner bit.

Here is the best explanation:
http://www.scottklarr.com/topic/23/how-raid-5-really-works/

The other thing you must know, when the drive failed, the server will use more IO and CPU, cause when read operation happening it will calculate to result the missing data ( i wanna say that everything is in place as normal, NOT like the idea where if a drive failed then the parities are all calculated and stores the missing bits to the parity bits place as replacing, it is NOT like that)

When a new drive comes, rebuild happens and same exactly as the failed one + the parity from the write operation after failed time.

No comments:

Post a Comment