How does RAID5 work?

7

2

In a raid 5 setup, you get 4 TB of usable space out of 3 x 2 TB disks. How is that possible?

Simple minded as I am, I would think that you need 4TB to store your things, and use the remaining 2TB for recovery. But how can I recover 4TB out of only 2TB? If 1kb is gone, I only have 0.5kb to recover from. And if that is sufficient, why not use 0.5kb for storage right from the start.

I know this is a naive question. But what is the answer?

exolab

Posted 2010-11-15T07:31:33.913

Reputation: 335

Question was closed 2014-01-31T22:00:57.153

RAID5 only allows for one disk to fail. – ta.speot.is – 2011-05-22T00:59:30.380

Answers

13

For the example, we have 3 disks. One disk holds the parity information, the other two the data (thus you lose 1 disk worth of space to parity). Now, for every bit the parity is calculated, such that all of the disks contain always an even number of bits at the same position. (This example is the basic theory, the implementation might differ slightly):

   Data 1   Data 2      Parity
      0        0             0
      0        1             1
      1        0             1
      1        1             0

If you lose one disk and have now (for this position on every disk) the information 1?1 you know, that the ?must be 0 because you have to get an even number of bits. Same for e.g. ?00 (==000) or any other combination, also with more data parts (works the same also for 20 data and 1 parity disks). Also long as you lose only any one disk (one bit per parity group), you're fine.

Note: The position of the parity rotates (with RAID-5) over the disks for every stripe (RAID block, something between 2k and 64k bytes), to spread the load on the disks evenly.

knitti

Posted 2010-11-15T07:31:33.913

Reputation: 871

Aah. So it is magic :) No, seriously: I had not really understood the parity bit bit. But that makes perfect sense, of course. – exolab – 2010-11-15T08:18:56.177

2

With RAID 5, the rule of thumb is that you lose the equivalent of one drive out of your set to parity. It also means that you can lose a maximum of one drive from your RAID set before recovery is impossible.

So with three drives (the minimum for RAID 5), you would have 3TB in total, but 2TB usable. As you increase the number of drives, your chances of failure increase, because you are only able to lose one drive out of the entire set.

So your files are saved like this:

Drive 1: Striped Data
Drive 2: Striped Data
Drive 3: Parity

The parity bits are randomly distributed across the disks, so from one byte to the next, you don't know specifically which drive your file is on, and which is parity.

Does that help?

user3463

Posted 2010-11-15T07:31:33.913

Reputation:

0

The kicker is really this: You could actually get 99 TB out of 100x1TB disks, thus only loose 1%.

However, with 100 physical disks, the chance of two disks failing at (nearly) the same time starts to become rather uncomfortable.

stolsvik

Posted 2010-11-15T07:31:33.913

Reputation: 910