{"id":43213,"date":"2020-11-26T15:03:40","date_gmt":"2020-11-26T14:03:40","guid":{"rendered":"http:\/\/blog.open-e.com\/?p=43213"},"modified":"2025-04-14T13:38:56","modified_gmt":"2025-04-14T13:38:56","slug":"raid-5-how-does-it-work","status":"publish","type":"post","link":"https:\/\/www.open-e.com\/blog\/raid-5-how-does-it-work\/","title":{"rendered":"RAID 5: How does it work?"},"content":{"rendered":"<p>\t\t\t\t<strong><em>Updated 23\/09\/2021<\/em><\/strong><\/p>\n<p>A few years ago, we published an article <em>\u2018How does RAID 5 work? The shortest and easiest explanation ever\u2019<\/em>. We have to admit that this article enjoyed great popularity among our readers. That\u2019s why we would like to explain this matter once again, but this time we also considered our readers\u2019 questions.<\/p>\n<div style=\"border: #999999 2px solid; float: right; padding: 5px; margin: 2px; font-size: 10px; width: 250px; text-align: left; margin-left: 15px;\">\n<p>RAID (redundant array of independent disks; originally redundant array of inexpensive disks) is a data storage virtualization technology that combines multiple disk drive components into a logical unit for the purposes of data redundancy or performance improvement.<\/p>\n<div style=\"font-size: 10px; text-align: right;\"><strong>Source: <a href=\"https:\/\/en.wikipedia.org\/wiki\/RAID\">Wikipedia<\/a><\/strong><\/div>\n<\/div>\n<h3><\/h3>\n<h3>RAID 5 <strong>explained<br \/>\n<\/strong><\/h3>\n<p>RAID 5 requires a minimum of 3 drives to implement. Each data block is written on a data disk, and parity for blocks in the same rank is generated on Writes and checked on Reads.<\/p>\n<p>&nbsp;<\/p>\n<p><span style=\"text-decoration: underline;\">In order to understand RAID 5, you must know XOR:<\/span><\/p>\n<p><strong><span style=\"color: #000000;\">The binary XOR (exclusive OR) operation has two inputs and one output.\u00a0 The inputs to a binary XOR operation can only be 0 or 1 and the result can only be 0 or 1.<\/span><\/strong><\/p>\n<p>XOR function result is equal 1 if both arguments are different.<\/p>\n<p>XOR (0, 1) = 1<br \/>\nXOR (1, 0) = 1<\/p>\n<p>XOR function output is equal 0 if both arguments are the same.<\/p>\n<p>XOR (0, 0) = 0<br \/>\nXOR (1, 1) = 0<\/p>\n<p><strong>Now let us assume we have 3 drives with the following bits:<\/strong><\/p>\n<p>| 101 | 010 | 011 |<\/p>\n<p>We calculate XOR of those data and place it on the 4<sup>th<\/sup> drive.<\/p>\n<p>XOR (101, 010, 011) = 100 (XOR (101,010) = 111 and then XOR (111, 011) = 100<\/p>\n<p>So the data on the four drives looks like this:<\/p>\n<p>| 101 | 010 | 011 | <strong>100<\/strong> |<\/p>\n<p>In case of using more than 3 drives, you must use the same calculation for XOR:<\/p>\n<p>XOR (0, 0) = 0<br \/>\nXOR (0, 1) = 1<br \/>\nXOR (1, 0) = 1<br \/>\nXOR (1, 1) = 0<\/p>\n<p><strong>This time, lets assume we are using four drives with the following data:<\/strong><\/p>\n<p>1,1,0,1<br \/>\n1,0,0,0<br \/>\n0,0,1,0<br \/>\n0,1,1,0<\/p>\n<p>We calculate XOR of those data and place it on the 5<sup>th<\/sup> drive.<\/p>\n<p>XOR (1,1,0,1) = 1<br \/>\nXOR (1,0,0,0) = 1<br \/>\nXOR (0,0,1,1) = 1<br \/>\nXOR (o,1,1,0) = 0<\/p>\n<p>So the data looks like this:<\/p>\n<p>1,1,0,1,1<br \/>\n1,0,0,0,1<br \/>\n0,0,1,0,1<br \/>\n0,1,1,0,0<\/p>\n<p><strong>And now let&#8217;s simulate a break of the 3<sup>rd<\/sup> drive:<\/strong><\/p>\n<p>1,1,x,1,1<br \/>\n1,0,x,0,1<br \/>\n0,0,x,0,1<br \/>\n0,1,x,0,0<\/p>\n<p>In order to get data from this drive, calculate XOR for x from 1<sup>st<\/sup>, 2<sup>nd<\/sup>, 4<sup>th<\/sup>, and 5<sup>th<\/sup> drive:<\/p>\n<p>x for the 1<sup>st<\/sup> from XOR (1,1,1,1) = 0 \/ why? 1,1=0 -&gt; 0,1=1 -&gt; 1,1=0<br \/>\nx for the 2<sup>nd<\/sup> line from XOR (1,0,0,1) = 0<br \/>\nx for the 3<sup>rd<\/sup> line from XOR (0,0,0,1) = 1<br \/>\nx for the 4<sup>th<\/sup> line from XOR (0,1,0,0) = 1<\/p>\n<p>You have to always calculate the sum of two numbers and the result with the next number. Action is alternate for XOR.<\/p>\n<p><strong>Let\u2019s assume the second drive has failed.<\/strong><\/p>\n<p>When we calculate XOR all the remaining data will be present from the missing drive.<\/p>\n<p>| 101 | <span style=\"color: red;\"><strong><em><span style=\"text-decoration: line-through;\">010<\/span><\/em> <\/strong><\/span> | 011 | 100 |<\/p>\n<p>XOR (101, 011, 100) = 010<\/p>\n<p>You can check the other missing drives and XOR of the remaining data, which will always give you the exact data of your missing drive.<\/p>\n<p>| 101 | 010 | <span style=\"color: red;\"><strong><em><span style=\"text-decoration: line-through;\">011<\/span><\/em><\/strong><\/span> | 100 |<\/p>\n<p>XOR (101, 010, 100) = 011<\/p>\n<p>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 (65,536 * 8 = 524,288 bits).<\/p>\n<p>The real XOR engine only needs to deal with 524,288 bits and not 3 bits as in our exercise. This is why RAID 5 needs a very efficient XOR engine in order to calculate it fast.<\/p>\n<p>When adding one drive for parity, you will be able to rebuild the missing data in case of any drive failure.<\/p>\n<p>In our example, we have explained RAID 4 where parity is on a dedicated drive. The only difference between RAID 4 and RAID 5 is that RAID 5 distributes parities evenly between all drives and RAID 4 keeps parities in a dedicated drive. Distributed parity provides a slight increase in performance but the XOR magic is the same.<\/p>\n<p>&nbsp;<\/p>\n<p>A more detailed description of what Redundant Array of Independent Disks means you can find in the newest article by Grzegorz Walasek: <a title=\"The Fundamentals of RAID\" href=\"https:\/\/www.open-e.com\/blog\/the_fundamentals_of_raid\/\">The Fundamentals of RAID<\/a><\/p>\n<h3>RAID &#8211; The Series. Check out:<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.open-e.com\/blog\/the_fundamentals_of_raid\/\">The Fundamentals of RAID<\/a><\/li>\n<li><a href=\"https:\/\/www.open-e.com\/blog\/what-is-raid-0\/\" target=\"_blank\" rel=\"noopener noreferrer\">RAID 0<\/a><\/li>\n<li><a href=\"https:\/\/www.open-e.com\/blog\/what-are-raid-1-raid-10-and-raid-01\/\" target=\"_blank\" rel=\"noopener noreferrer\">RAID 1, RAID 1+0 and RAID 0+1 <\/a><\/li>\n<li><a href=\"https:\/\/www.open-e.com\/blog\/raid-2-raid-3-raid-4-what-it-is-how-it-works-the-history-lesson\/\">RAID 2, RAID 3, RAID 4<\/a><\/li>\n<li><a href=\"https:\/\/www.open-e.com\/blog\/raid-5-raid-6-or-other-alternativee\/\">RAID 5, RAID 6, RAID 5E, RAID 5EE<\/a><\/li>\n<\/ul>\n<hr \/>\n<h3>RAID Calculator<\/h3>\n<p>We know that your data is priceless \u2013 calculate how many disks you need to get it safe with <a href=\"https:\/\/www.open-e.com\/storage-and-raid-calculator\/joviandss\/\">Open-E JovianDSS Storage &amp; RAID Calculator<\/a><a href=\"https:\/\/www.open-e.com\/raid-calculator\/\">!<br \/>\n<\/a><\/p>\n<hr \/>\n<p>&nbsp;\t\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Updated 23\/09\/2021 A few years ago, we published an article \u2018How does RAID 5 work? The shortest and easiest explanation ever\u2019. We have to admit that this article enjoyed great&nbsp;&#8230;<\/p>\n","protected":false},"author":11,"featured_media":55472,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[28],"tags":[293,296,523,526,552,634,748],"class_list":["post-43213","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-raid","tag-hard-disk","tag-hardware-2","tag-raid","tag-raid-5","tag-rebuild","tag-storage","tag-xor"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/posts\/43213","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/users\/11"}],"replies":[{"embeddable":true,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/comments?post=43213"}],"version-history":[{"count":1,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/posts\/43213\/revisions"}],"predecessor-version":[{"id":55473,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/posts\/43213\/revisions\/55473"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/media\/55472"}],"wp:attachment":[{"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/media?parent=43213"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/categories?post=43213"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.open-e.com\/blog\/wp-json\/wp\/v2\/tags?post=43213"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}