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 4th 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!
37 Comments
Gabor /
17, 02 2013 01:12:41Hello,
Could you please explain to me how the raid6 works when two drives missing?
Thanks
Mansij /
10, 03 2013 03:15:50.Its really a good & easy explaination…,
about raid…
adam /
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?
Janusz Bak /
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.
Samit Mandol /
30, 06 2013 02:45:23Very good explanation!!