## How does RAID 5 work? The Shortest and Easiest explanation ever!

**We all have limited time to study long and complicated information about RAID theories, but you may be interested as to how RAID 5 works. We made it simple for you by providing the shortest and easiest explanation ever. **

### RAID 5 – how it works?

First we need to remind you XOR definition:

XOR function result is equal 1 if both arguments are different.

XOR (0, 1) = 1

XOR (1, 0) = 1

XOR function output is equal 0 if both arguments are same.

XOR (0, 0) = 0

XOR (1, 1) = 0

Now let us assume we have 3 drives with the following bits:

| 101 | 010 | 011 |

And we calculate XOR of those data and place it on 4^{th} drive

XOR (101, 010, 011) = 100 (XOR (101,010) = 111 and then XOR (111, 011) = 100

So the data on the four drives looks like this below:

| 101 | 010 | 011 | **100** |

Now let’s see how the XOR MAGIC works. Let’s assume the second drive has failed. When we calculate XOR all the remaining data will be present from the missing drive.

| 101 | ** 010 ** | 011 | 100 |

XOR (101, 011, 100) = 010

You can check the missing other drives and XOR of the remaining data will always give you exactly the data of your missing drive.

| 101 | 010 | ** 011** | 100 |

XOR (101, 010, 100) = 011

What works for 3 bits and 4 drives only, works for any number of bits and any number of drives. Real RAID 5 has the most common stripe size of 64k (65536 * 8 = 524288 bits )

So the real XOR engine only needs to deal with 524288 bits and not 3 bits as in our exercise. This is why the RAID 5 needs a very efficient XOR engine in order to calculate it fast.

So when adding one drive for parity you will be able to rebuild the missing data in case of any drive failure.

In our example we have explained RAID 4 where parity is on a dedicated drive. RAID 5 will distribute parities evenly between all drives. Distributed parity provides a slight increase in performance but the XOR magic is the same.

To learn more about RAID 5 please go to Wikipedia article.

### RAID – The Series. Check out:

### RAID Calculator

We know that your data is priceless – calculate how many disks you need to get it safe!

How does RAID 5 work? The Shortest and Easiest explanation ever!,

## 39 Comments

## RichardS

September 03, 09 2010 05:26:07Good catch!

I really like this explanation 🙂

+6(from 6 votes)## Lukas

September 06, 09 2010 01:19:59This is realy easy ! like 1 + 1 = 0. Thanks for this.

+7(from 7 votes)## Alaa S.

November 23, 11 2010 08:17:58I give it XOR(111,011)% score, thank you very much for that.

+8(from 10 votes)## Pankaj

April 11, 04 2012 11:51:54It should be XOR(110,010,001) % Score……. 🙂

+5(from 11 votes)## Haydn Bell

December 23, 12 2010 10:48:50Understood 3 drive, but wasn’t sure how 4 drive worked. Excellent explaination, simply phrased so even I could catch it on first read. Have just built my first 4 drive Raid 5 PC. Many thanks !!!

+1(from 1 vote)## Lukas

January 08, 01 2011 10:50:53I will try to help you …

In case of using more than 3 drivers you must use the same calculation for xor:

XOR 0,0=0

XOR 0,1=1

XOR 1,0=1

XOR 1,1=0

Example

4 drives with following data:

1,1,0,1

1,0.0.0

0,0,1,0

0,1,1,0

We calculate XOR of those data and place it on 5th drive;

for the 1st line XOR(1,1,0,1)=1

for the 2nd line XOR(1,0,0,0)=1

for the 3th line XOR(0,0,1,0)=1

for the 5th line XOR(0,1,1,0)=0

so the data looks like these:

1,1,0,1,1

1,0,0,0,1

0,0,1,0,1

0,1,1,0,0

and now let simulate break of 3rd drive

1,1,x,1,1

1,0,x,0,1

0,0,x,0,1

0,1,x,0,0

so we must get the data for this drive so we must calculate XOR for x from 1st 2nd 4th and 5th drive:

x for the 1st line from XOR(1,1,1,1)=0 why ? 1,1=0 -> 0,1=1 -> 1,1=0

x for the 2nd line from XOR(1,0,0,1)=0

x for the 3rd line from XOR(0,0,0,1)=1

x for the 4th line from XOR(0,1,0,0)=1

You have to always calculate sum of two numbers and the result calculate with the next number. Action is alternately for XOR.

I hope this helps.

+6(from 10 votes)## Austin Data

October 12, 10 2011 09:44:04this is short! and easy! THANK GOODNESS because raid5 is a terrible bore. thank you!

0(from 4 votes)## Jack

February 21, 02 2012 05:59:26Very good explain. Thanks

If my 2 disks are failed at a time, out of 7 disks, is it possible to get the data in raid 5. I know raid can tolerate only one disk failure, sometime it makes me confuse.

Thanks in advanced.

0(from 2 votes)## Mike

March 07, 03 2012 08:36:42No, the data is unrecoverable. simply put, raid 5 only tolerates a single drive failure because of the way xor works, if you had data of 1010, and lost 2 drives making it x01x, there’s no way to calculate both of the missing values. Raid 6 would work because of a double parity.

0(from 2 votes)## Mike

March 07, 03 2012 08:38:29Actually, I should have used 7 drives in my example, but the math is the same, 0101010, 2 drives missing, 01x101x, still don’t know if the total string should add up to a 1 or a 0.

-1(from 1 vote)## Chimpidi

March 12, 03 2012 12:52:06Excellent explanation. I tried in different sites and got the concept but I was not clear about how the parity plays a role. The explantion given here, clears off my questions. Thanks alot for the details.

0(from 2 votes)## Nima0102

April 01, 04 2012 07:20:07Excellent and simple explanation.

Thanks a lot.

-2(from 2 votes)## Shirish

April 04, 04 2012 01:39:40Gr8 Explanation !!

But Need to explain how your read/write operation works on RAID5.. that is actual point .. in case of parity ..

–Shirish Shukla

0(from 2 votes)## TJ

October 02, 10 2012 09:31:15What do you guys mean great explanation??? This is a half-way explanation. How about starting out by EXPLANING what the heck XOR is??? What does it stand for? What is it? Where did it come from? Is it just a variable?? That’s like those people who tell stories about people you’ve never heard of before as if you should know who they are: “So me and Bill went to John’s house and then Phil walked in”. Come on…..

And if that’s not enough, how about explaning what XOR (101,010) = 111 actually means. I’m guessing by way of simple addition that they are adding the bits together on the left side and then subtracting them on the other, but still……….NO EXPLANATION!!! You know how I can tell a developer write this little “explanation”? Because this is exactly the type of stuff developers do and they have no idea why people have to keep asking them 50 questions. It’s not because we’re stupid, it’s because they give half explanations.

But other than that it’s pretty cool. 😛

-7(from 25 votes)## kerry

December 27, 12 2013 06:05:12Did you read the article or are you just dumb? The author very clearly explained XOR. I am not a developer and I have never heard of XOR before. I understood RAID generally but could not understand how you got redundancy with only 4 drives and capacity equal to 3 drives w/ RAID 5. This explanation cleared it up for me. You still have questions b/c you can’t read or (more likely), you have low intellect.

+1(from 7 votes)## nyc seo expert

November 30, 11 2012 12:15:20Great info. Lucky me I recently found your site by accident (stumbleupon).

I’ve saved as a favorite for later!

-3(from 3 votes)## Market

January 01, 01 2013 01:15:35Thank you for simplifying RAID 5, much easier to understand with your XOR example.

0(from 2 votes)## Gabor

February 17, 02 2013 01:12:41Hello,

Could you please explain to me how the raid6 works when two drives missing?

Thanks

-1(from 1 vote)## Kasia Kolodziej

February 19, 02 2013 08:30:59Hey Gabor!

For RAID6, the minimum required disks are four. Two drives can be missing and the system will still work. However, you have to remember that in case these two drives will be rebuilding, the performance might be slower.

You can find more info here and here.

+3(from 3 votes)## Hugo

January 02, 01 2017 10:15:42Yeah but if you are using 4 drives in raid 6, you may as well use raid 10 because you get the same capacity and redundancy and you get better performance. Also raid 10 is way less complicated and doesn’t require a raid controller which will set you back a good $200.

0(from 0 votes)## Mansij

March 10, 03 2013 03:15:50.Its really a good & easy explaination…,

about raid…

-2(from 2 votes)## adam

June 28, 06 2013 01:11:12clear and simple. so does this mean that there is always a disk dedicated to the “checksum” in a raid5 configuration? Or is both data and XOR bits are distribuited on all drives?

+1(from 1 vote)## Janusz Bak

June 28, 06 2013 03:24:50Your question is answered in last 2 sentences of my article. In fact I was describing RAID4, but my goal was to make clear how XOR magic works for parity in RAID. My goal was also to make the explanation really easy and short. This is why I have started with RAID4 and referenced to RAID5 Wikipedia post which is already long and much more complicated to understand. The difference between RAID4 and RAID5 is only that RAID5 distributes parity and RAID4 keeps parity in a dedicated drive. It is not so important if you want just understand how parity calculation works.

+1(from 1 vote)## Samit Mandol

June 30, 06 2013 02:45:23Very good explanation!!

+1(from 1 vote)## Mohammad

October 13, 10 2013 08:55:37So in RAID4 if the parity drive fails, all your data could be lost right?

0(from 0 votes)## Kasia Kolodziej

October 14, 10 2013 08:16:00Losing the parity disk in RAID 4 is NOT a problem for the data.

You will just have the data without parity.

So, your RAID array is in the degraded mode – as next disk fail will cost data loss.

After replacing the drive, the rebuild task will re-create the parity based on the data.

Once the parity is re-created, your RAID array status switches from degraded to normal.

And now, the array is ready to tolerate the next disk fail and does not lose all the data.

+1(from 3 votes)## Jignesh Rajguru

December 26, 12 2013 07:19:46Really thanks you very much for explanations.

+1(from 1 vote)## Subrahmanyam

January 31, 01 2014 09:35:43Good explanation. Thanks 🙂

-2(from 2 votes)## Mahsaa

December 29, 12 2014 05:59:04Its really Good .

thx lot

+1(from 1 vote)## Solz

March 03, 03 2015 02:20:29Thank you very much for the explanation

0(from 0 votes)## Jenny

February 09, 02 2016 07:50:03This is crtyasl clear. Thanks for taking the time!

0(from 0 votes)## John

April 25, 04 2016 08:18:07Very nice post, good job:-)! Best regards for you!

0(from 0 votes)## hannah

July 23, 07 2016 07:38:26while this is an old post… I’ve got to say well done… excellent piece of work… now I get the parity stuff! Thanks!

0(from 0 votes)## Eswaran.S

October 05, 10 2016 09:44:03I,m Esay to learn this parity topic……Thank u for giving that good example

0(from 0 votes)## Siba Sankar

October 20, 10 2016 08:36:32This is kind of an explanation I was searching for. Thank You very much

0(from 0 votes)## viswa

October 27, 10 2016 11:29:05excellent ..

Thank you for making me to understand clearly

0(from 0 votes)## john smith

February 20, 02 2017 03:54:05you lost me at XOR , what is XOR?

0(from 0 votes)## Karolina Pletnia

February 27, 02 2017 11:47:07Hello John! RAID 5 uses the bitwise “exclusive OR” (XOR) function to compute the parity values from the array data. So XOR = “exclusive OR”.

0(from 0 votes)## Jinny Mcreath

March 30, 03 2017 05:19:32Your way of describing everything in this article is actually fastidious, every one can without difficulty understand it, Thanks a lot.

0(from 0 votes)