# RAID 5 parity bits - recovering data

This is an old topic but I have a question about RAID 5 parity bits that confuse me.

My question is:

So that, in every explanation of RAID 5, it is said that RAID 5 has parity bit in every disk. And in every demonstration, all sources shows raid 5 like:

``````Disk 1 | Disk 2 | Disk 3 | Disk 4
Data     Data     Data     Parity
Data     Data     Parity   Data
Data     Parity   Data     Data
Parity   Data     Data     Data
Figure a
``````

Internet sources that demonstrate RAID 5 shows that, every disk has a Parity bit (only 1) in their blocks. This makes sense in 4 disk 4 block scenario because if for example disk 4 fails, we can recover all of the data's because we got the exact amount of parity bits to recover all the data that is lost in disk 4. But, in order to recover the data in more blocked disks (for example 8 blocks), the picture should be like this:

``````Disk 1 | Disk 2 | Disk 3 | Disk 4
Data     Data     Data     Parity
Data     Data     Parity   Data
Data     Parity   Data     Data
Parity   Data     Data     Data
Data     Data     Data     Parity
Data     Data     Parity   Data
Data     Parity   Data     Data
Parity   Data     Data     Data
Figure b
``````

The thing is, as I mentioned, all the sources says that RAID 5 has 1 parity bit in every disk as I showed in figure a. However, in order to recover data from 8 blocked storage for example, we need something like Figure b. , so that there is 2 parity information in 1 disk (Parity information should be more if there is more disks). But, the RAID 5 explanations doesn't explain it like that and also there is RAID 6 configurations whose speciality is to have 2 parity bit. So this scenario is all wrong. The correct picture should look like this:

``````Disk 1 | Disk 2 | Disk 3 | Disk 4
Data     Data     Data     Parity
Data     Data     Parity   Data
Data     Parity   Data     Data
Parity   Data     Data     Data
Data     Data     Data     Data
Data     Data     Data     Data
Data     Data     Data     Data
Data     Data     Data     Data
Figure c
``````

In this scenario, the RAID 5's explanation is accurate. Again lets assume that disk 4 is dead. How is the data in the 5,6,7 and 8th block in disk 4 will be recovered? My assumption is, the raid-controller takes 1 parity bit (for example; disk 1's parity bit) and after that, from the 5th blocks of disks (5,6,7,8th block of 2,3rd disk), it XOR's the parity bit of the 1st disk's parity(4th block of 1st disk (parity)) and the data's in 5,6,7,8th blocks of disk 2 and 3. So that, raid-controller can take a random parity bit and XOR the 1,2,3rd disk's data's from the 5,6,7 and 8'th blocks. I guess my assumption is false.

The abstract of the question is, How RAID 5 handles the parity bits and recovers the data with 8 block disks?

Thank you all for your concern.

• I would say the Figure b is right. Can you cite from and link to these sources you refer to? Please edit the question. – Kamil Maciorowski Jan 22 at 10:44
• @KamilMaciorowski I have added my sources. I have looked at this topic from some other sources and videos as well but I couldn't find them right now. – G.Baysec Jan 22 at 13:16
• @KamilMaciorowski If figure b is correct, what is the difference between RAID 5 and RAID 6? Because RAID 6's speciality is to have 2 parity bits in 1 disk. Also If figure b is correct, if the disk has more blocks such as 16 or sth, 1 disk should have 4 parity-bit. It is not true for the definition of RAID 5 I guess – G.Baysec Jan 22 at 13:17

Figure b is the right one.

First of all, you used the word "bit" for "block". Bit is either 0 or 1. We're talking about "data blocks" and "parity blocks" (or "parity units", depending on the source, whatever; but not just single "bits"). Blocks in theory may be 1-bit in size but in practice 512 bytes is the minimum, since this is the common sector size of block devices.

One of your sources contains a picture of three disks and four stripes creating RAID 5. One of the disks contains two parity blocks (this obviously contradicts with your figure c). Then the article reads:

Every stripe has a column containing a parity stripe unit and columns containing data. The parity is spread over all of the disks in the array [...]

(To be clear: in your figures a stripe is a single line like `Data Data Parity Data`).

This means every stripe (not "every disk"!) has exactly one parity block in RAID 5 (in RAID 6 every stripe has exactly two parity blocks). If one disk fails (up to two disks for RAID 6), each stripe contains enough information to rebuild the missing part of this particular stripe independently from other stripes.

• So, the misunderstanding is, every stripe has one parity, not every disk. So that, a disk may contain 1 parity for every stripe of data blocks, am I right? Than my figure b is correct.Thank you very much. It all just make sense now. – G.Baysec Jan 22 at 13:53