Robbie Ferguson

How does parity work... really?

Recommended Posts

My basic RAID experience has my brain thinking in terms of RAID1... a mirror.


My conventional mind thinks, if I have a 400 GB drive, I need 400 GB on another drive to have redundancy.


How is it then, I can have a 750 GB parity drive, but then two 500 GB data drives (which would total more in sum than the entire capacity of the parity drive), yet still have redundancy without striping?

Share this post

Link to post
Share on other sites

I don't know the mathematics to it.

Yet I do know that matching blocks on each drive is XOR'ed with one another and written to the parity drive.


Think in terms of RAID4 only with out stripping across multiple drives.


Instead of stripping a filesystem across multiple drives, a filesystem is contiguous on one spindle.

Multiple matching sectors across multiple drives are used to calculate a parity.






In the image,

DISK 0 is a filesystem,

but block A1, A2, A3 (on each filesystem) is used to create the parity for the respectively addressed block.


When the system sees that a disk has ended, ot assumes 0 in the XOR calculation and just uses what is left.

DISK3, Parity needs to be the largest disk. so that there is at least one parity block for every sector on other drives.


Hope my oversimplified explanation helps.


In updating parity, there is a bit of performance penalty for a sector.

The process is:

    * Read the old data block

    * Read the old parity block

    * Compare the old data block with the write request. For each bit that has flipped (changed from 0 to 1, or from 1 to 0) in the data block, flip the corresponding bit in the parity block

    * Write the new data block

    * Write the new parity block


Share this post

Link to post
Share on other sites

Thanks so much!  Reminding myself that digital data is stored in 1 or 0 makes it all make sense now.


In honesty though, now that I understand it, I'm astonished.  It's really ... brilliant!  I hope someone won a prize for creating parity-based redundancy  :)

Share this post

Link to post
Share on other sites
yet still have redundancy without striping?

Now that you have gotten a good idea how "parity" works...  The "striping" part just puts part of the parity data on each disk rather than all on one disk.  In the same way, for any given file, part of it is on all the remaining disks for that stripe.  This was originally done for speed... (Older disks were slower, and to issue 5 "read" operations, each for 1/5th of the file's data, you could get each disk to respond in parallel and get to the total data faster)


striping is done to improve performance, by having each disk do a fraction of the I/O, but with all of them spinning.  It is also why losing two disks in a normal RAID5 array loses all the data on ALL drives... because 2/5ths of each block of data on the disks is missing.  If you are using striping, all the disks in the array have to be the same size (or be limited by the size of the smallest drive)


parity is done for protection of data loss.  The two concepts are often used together in a RAID array.

Raid5 is illustrated here:


unRAID is actually RAID4, but without striping.  (There is no official name for it as a "RAID" standard)

Share this post

Link to post
Share on other sites

Copyright © 2005-2017 Lime Technology, Inc. unRAID® is a registered trademark of Lime Technology, Inc.