Question: How many drives are necessary for an array?

Standard RAID levels


In computer storage, the standard RAID levels comprise a basic set of RAID (redundant array of independent disks) configurations that employ the techniques of striping, mirroring, or parity to create large reliable data stores from multiple general-purpose computer hard disk drives (HDDs). The most common types are RAID0 (striping), RAID1 and its variants (mirroring), RAID5 (distributed parity), and RAID6 (dual parity). RAID levels and their associated data formats are standardized by the Storage Networking Industry Association (SNIA) in the Common RAID Disk Drive Format (DDF) standard.[1]
While most RAID levels can provide good protection against and recovery from hardware defects or defective sectors/read errors (hard errors), they do not provide any protection against data loss due to catastrophic failures (fire, water) or soft errors such as user error, software malfunction, or malware infection. For valuable data, RAID is only one building block of a larger data loss prevention and recovery scheme – it cannot replace a backup plan.
RAID 0

RAID0 (also known as a stripe set or striped volume) splits ("stripes") data evenly across two or more disks, without parity information, redundancy, or fault tolerance.  Since RAID0 provides no fault tolerance or redundancy, the failure of one drive will cause the entire array to fail; as a result of having data striped across all disks, the failure will result in total data loss.  This configuration is typically implemented having speed as the intended goal.[2][3]  RAID0 is normally used to increase performance, although it can also be used as a way to create a large logical volume out of two or more physical disks.[4]
A RAID0 setup can be created with disks of differing sizes, but the storage space added to the array by each disk is limited to the size of the smallest disk. For example, if a 120GB disk is striped together with a 320GB disk, the size of the array will be 120GB× 2= 240GB. However, some RAID implementations allow the remaining 200GB to be used for other purposes.
The diagram in this section shows how the data is distributed into Ax stripes on two disks, with A1:A2 as the first stripe, A3:A4 as the second one, etc.  Once the stripe size is defined during the creation of a RAID0 array, it needs to be maintained at all times.  Since the stripes are accessed in parallel, an n-drive RAID0 array appears as a single large disk with a data rate n times higher than the single-disk rate.
Performance
A RAID0 array of n drives provides data read and write transfer rates up to n times as high as the individual drive rates, but with no data redundancy.  As a result, RAID0 is primarily used in applications that require high performance and are able to tolerate lower reliability, such as in scientific computing[5] or computer gaming.[6]
Some benchmarks of desktop applications show RAID0 performance to be marginally better than a single drive.[7][8]  Another article examined these claims and concluded that "striping does not always increase performance (in certain situations it will actually be slower than a non-RAID setup), but in most situations it will yield a significant improvement in performance".[9][10]  Synthetic benchmarks show different levels of performance improvements when multiple HDDs or SSDs are used in a RAID0 setup, compared with single-drive performance.  However, some synthetic benchmarks also show a drop in performance for the same comparison.[11][12]

RAID 1


RAID1 consists of an exact copy (or mirror) of a set of data on two or more disks; a classic RAID1 mirrored pair contains two disks. This configuration offers no parity, striping, or spanning of disk space across multiple disks, since the data is mirrored on all disks belonging to the array, and the array can only be as big as the smallest member disk. This layout is useful when read performance or reliability is more important than write performance or the resulting data storage capacity.[13][14]
The array will continue to operate so long as at least one member drive is operational.[15]
Performance
Any read request can be serviced and handled by any drive in the array; thus, depending on the nature of I/O load, random read performance of a RAID1 array may equal up to the sum of each member's performance,[lower-alpha 1] while the write performance remains at the level of a single disk.  However, if disks with different speeds are used in a RAID1 array, overall write performance is equal to the speed of the slowest disk.[14][15]
Synthetic benchmarks show varying levels of performance improvements when multiple HDDs or SSDs are used in a RAID1 setup, compared with single-drive performance.  However, some synthetic benchmarks also show a drop in performance for the same comparison.[11][12]

RAID 2

RAID2, which is rarely used in practice, stripes data at the bit (rather than block) level, and uses a Hamming code for error correction. The disks are synchronized by the controller to spin at the same angular orientation (they reach index at the same time), so it generally cannot service multiple requests simultaneously.[16][17]  However, depending with a high rate Hamming code, many spindles would operate in parallel to simultaneously transfer data so that "very high data transfer rates" are possible[18] as for example in the DataVault where 32 data bits were transmitted simultaneously.
With all hard disk drives implementing internal error correction, the complexity of an external Hamming code offered little advantage over parity so RAID2 has been rarely implemented; it is the only original level of RAID that is not currently used.[16][17]

RAID 3

RAID3, which is rarely used in practice, consists of byte-level striping with a dedicated parity disk. One of the characteristics of RAID3 is that it generally cannot service multiple requests simultaneously, which happens because any single block of data will, by definition, be spread across all members of the set and will reside in the same physical location on each disk. Therefore, any I/O operation requires activity on every disk and usually requires synchronized spindles.
This makes it suitable for applications that demand the highest transfer rates in long sequential reads and writes, for example uncompressed video editing. Applications that make small reads and writes from random disk locations will get the worst performance out of this level.[17]
The requirement that all disks spin synchronously (in a lockstep) added design considerations to a level that provided no significant advantages over other RAID levels, so it quickly became useless and is now obsolete.[16] Both RAID3 and RAID4 were quickly replaced by RAID5.[19] RAID3 was usually implemented in hardware, and the performance issues were addressed by using large disk caches.[17]

RAID 4

RAID4 consists of block-level striping with a dedicated parity disk.  As a result of its layout, RAID4 provides good performance of random reads, while the performance of random writes is low due to the need to write all parity data to a single disk.[20]
In diagram 1, a read request for block A1 would be serviced by disk 0. A simultaneous read request for block B1 would have to wait, but a read request for B2 could be serviced concurrently by disk 1.

RAID 5

RAID5 consists of block-level striping with distributed parity. Unlike in RAID4, parity information is distributed among the drives. It requires that all drives but one be present to operate. Upon failure of a single drive, subsequent reads can be calculated from the distributed parity such that no data is lost.[5] RAID5 requires at least three disks.[21]
In comparison to RAID4, RAID5's distributed parity evens out the stress of a dedicated parity disk among all RAID members. Additionally, write performance is increased since all RAID members participate in the serving of write requests. Although it won't be as efficient as a striping (RAID0) setup, because parity must still be written, this is no longer a bottleneck.[22]
Since parity calculation is performed on the full stripe, small changes to the array experience write amplification: in the worst case when a single, logical sector is to be written, the original sector and the according parity sector need to be read, the original data is removed from the parity, the new data calculated into the parity and both the new data sector and the new parity sector are written.

RAID 6

RAID6 extends RAID5 by adding another parity block; thus, it uses block-level striping with two parity blocks distributed across all member disks.[23]
According to the Storage Networking Industry Association (SNIA), the definition of RAID6 is: "Any form of RAID that can continue to execute read and write requests to all of a RAID array's virtual disks in the presence of any two concurrent disk failures. Several methods, including dual check data computations (parity and Reed-Solomon), orthogonal dual parity check data and diagonal parity, have been used to implement RAID Level 6."[24]
Performance
RAID6 does not have a performance penalty for read operations, but it does have a performance penalty on write operations because of the overhead associated with parity calculations. Performance varies greatly depending on how RAID6 is implemented in the manufacturer's storage architecture—in software, firmware, or by using firmware and specialized ASICs for intensive parity calculations. RAID 6 can read up to the same speed as RAID 5 with the same number of physical drives.[25]
When either diagonal or orthogonal dual parity is used, a second parity calculation is necessary for write operations.  This doubles CPU overhead for RAID-6 versus single parity RAID levels.  When a Reed Solomon code is used the second parity calculation is unnecessary.  Reed Solomon has the advantage of allowing all redundancy information to be contained within a given stripe.  
Simplified parity example
Suppose we would like to distribute our data over 



n


{\displaystyle n}

 chunks. Our goal is to define two parity values 




P



{\displaystyle \mathbf {P} }

 and 




Q



{\displaystyle \mathbf {Q} }

, known as syndromes, resulting in a system of 



n
+
2


{\displaystyle n+2}

 physical drives that is resilient to the loss of any two of them. In order to generate more than a single independent syndrome, we will need to perform our parity calculations on data chunks of size 



k
>
1.


{\displaystyle k>1.}

 A typical choice in practice is a chunk size 



k
=
8


{\displaystyle k=8}

, i.e. striping the data per-byte. We will denote the base-2 representation of a data chunk 



D


{\displaystyle D}

 as 




d

0



d

1


.
.
.

d

k
−
1




{\displaystyle d_{0}d_{1}...d_{k-1}}

, where each 




d

i




{\displaystyle d_{i}}

 is either 0 or 1. 

If we are using a small number of chunks 



n
≤
k


{\displaystyle n\leq k}

, we can use a simple parity computation, which will help motivate the use of the Reed-Solomon system in the general case. For our first parity value  




P



{\displaystyle \mathbf {P} }

, we compute the simple XOR of the data across the stripes, as with RAID5. This is written 




P

=

D

0



⊕


D

1



⊕


D

2



⊕

.
.
.

⊕


D

n
−
1




{\displaystyle \mathbf {P} =D_{0}\;\oplus \;D_{1}\;\oplus \;D_{2}\;\oplus \;...\;\oplus \;D_{n-1}}

where 



⊕


{\displaystyle \oplus }

 denotes the XOR operator. The second parity value is analogous, but with each data chunk bit-shifted a different amount. Writing 




s
h
i
f
t

(
D
)
=

d

1


.
.
.

d

k



d

0




{\displaystyle \mathrm {shift} (D)=d_{1}...d_{k}d_{0}}

, we define  




Q

=

D

0


⊕

s
h
i
f
t

(

D

1


)
⊕


s
h
i
f
t


2


(

D

2


)
⊕
.
.
.
⊕


s
h
i
f
t


n
−
1


(

D

n
−
1


)


{\displaystyle \mathbf {Q} =D_{0}\oplus \mathrm {shift} (D_{1})\oplus \mathrm {shift} ^{2}(D_{2})\oplus ...\oplus \mathrm {shift} ^{n-1}(D_{n-1})}

In the event of a single drive failure, the data can be recomputed from 




P



{\displaystyle \mathbf {P} }

 just like with RAID5. We will show we can also recover from simultaneous failure of 2 drives. If we lose a data chunk and 




P



{\displaystyle \mathbf {P} }

, we can recover from 




Q



{\displaystyle \mathbf {Q} }

 and the remaining data by using the fact that 



D
⊕
D
=
0


{\displaystyle D\oplus D=0}

. Suppose on a system of  



n
=
4


{\displaystyle n=4}

 chunks, the drive containing chunk 




D

3




{\displaystyle D_{3}}

 has failed. We can compute 




Q

⊕

D

0


⊕

s
h
i
f
t

(

D

1


)
⊕


s
h
i
f
t


2


(

D

2


)
=


s
h
i
f
t


3


(

D

3


)


{\displaystyle \mathbf {Q} \oplus D_{0}\oplus \mathrm {shift} (D_{1})\oplus \mathrm {shift} ^{2}(D_{2})=\mathrm {shift} ^{3}(D_{3})}



and recover the lost data 




D

3




{\displaystyle D_{3}}

 by undoing the bit shift. We can also recover from the failure of two data disks by computing the XOR of 




P



{\displaystyle \mathbf {P} }

 and 




Q



{\displaystyle \mathbf {Q} }

 with the remaining data. If in the previous example, chunk 




D

0




{\displaystyle D_{0}}

 had been lost as well, we would compute



A
=

P

⊕

D

1


⊕

D

2


=

D

0


⊕

D

3




{\displaystyle A=\mathbf {P} \oplus D_{1}\oplus D_{2}=D_{0}\oplus D_{3}}





B
=

Q

⊕

s
h
i
f
t

(

D

1


)
⊕


s
h
i
f
t


2


(

D

2


)
=

D

0


⊕


s
h
i
f
t


3


(

D

3


)


{\displaystyle B=\mathbf {Q} \oplus \mathrm {shift} (D_{1})\oplus \mathrm {shift} ^{2}(D_{2})=D_{0}\oplus \mathrm {shift} ^{3}(D_{3})}

On a bitwise level, this represents a system of 



2
k


{\displaystyle 2k}

 equations in 



2
k


{\displaystyle 2k}

 unknowns which uniquely determine the lost data. 
This system will no longer work applied to a larger number of drives 



n
>
k


{\displaystyle n>k}

. This is because if we repeatedly apply the shift operator 



k


{\displaystyle k}

 times to a chunk of length 



k


{\displaystyle k}

, we end up back where we started! If we tried to apply the algorithm above to a system containing 



k


{\displaystyle k}

 disks, the second set of equations would be 



B
=

D

0


⊕


s
h
i
f
t


k


(

D

k


)
=

D

0


⊕

D

k




{\displaystyle B=D_{0}\oplus \mathrm {shift} ^{k}(D_{k})=D_{0}\oplus D_{k}}

, which is the same as the first set of equations. This is only half as many as we need to solve for the missing values.
General parity system
It is possible to support a far greater number of drives by choosing the parity function more carefully. The issue we face is to ensure that a system of equations over the finite field 





Z


2




{\displaystyle \mathbb {Z} _{2}}

 has a unique solution, so we will turn to the theory of polynomial equations. Consider the Galois field 



G
F
(
m
)


{\displaystyle GF(m)}

 with 



m
=

2

k




{\displaystyle m=2^{k}}

. This field is isomorphic to a polynomial field 




F

2


[
x
]

/

(
p
(
x
)
)


{\displaystyle F_{2}[x]/(p(x))}

 for a suitable irreducible polynomial 



p
(
x
)


{\displaystyle p(x)}

 of degree 



k


{\displaystyle k}

 over 





Z


2




{\displaystyle \mathbb {Z} _{2}}

. We will represent the data elements 



D


{\displaystyle D}

as polynomials 




D

=

d

k
−
1



x

k
−
1


+

d

k
−
2



x

k
−
2


+
.
.
.
+

d

1


x
+

d

0




{\displaystyle \mathbf {D} =d_{k-1}x^{k-1}+d_{k-2}x^{k-2}+...+d_{1}x+d_{0}}

 in the Galois field. Let 





D


0


,
.
.
.
,


D


n
−
1


∈
G
F
(
m
)


{\displaystyle \mathbf {D} _{0},...,\mathbf {D} _{n-1}\in GF(m)}

 correspond to the stripes of data across hard drives encoded as field elements in this manner. We will use 



⊕


{\displaystyle \oplus }

 to denote addition in the field, and concatenation to denote multiplication. The reuse of 



⊕


{\displaystyle \oplus }

 is intentional: this is because addition in the finite field 





Z


2




{\displaystyle \mathbb {Z} _{2}}

 represents to the XOR operator, so computing the sum of two elements is equivalent to computing XOR on the polynomial coefficients. 
A generator of a field is an element of the field such that 




g

i




{\displaystyle g^{i}}

 is different for each nonnegative 



i
<
m
−
1


{\displaystyle i<m-1}

. This means each element of the field, except the value 



0


{\displaystyle 0}

, can be written as a power of 



g
.


{\displaystyle g.}

 A finite field is guaranteed to have at least one generator. Pick one such generator 



g


{\displaystyle g}

, and define 




P



{\displaystyle \mathbf {P} }

 and 




Q



{\displaystyle \mathbf {Q} }

 as follows:





P

=

⨁

i





D


i



=


D


0



⊕



D


1



⊕



D


2



⊕

.
.
.

⊕



D


n
−
1




{\displaystyle \mathbf {P} =\bigoplus _{i}{\mathbf {D} _{i}}=\mathbf {D} _{0}\;\oplus \;\mathbf {D} _{1}\;\oplus \;\mathbf {D} _{2}\;\oplus \;...\;\oplus \;\mathbf {D} _{n-1}}







Q

=

⨁

i




g

i




D


i



=

g

0




D


0



⊕


g

1




D


1



⊕


g

2




D


2



⊕

.
.
.

⊕


g

n
−
1




D


n
−
1




{\displaystyle \mathbf {Q} =\bigoplus _{i}{g^{i}\mathbf {D} _{i}}=g^{0}\mathbf {D} _{0}\;\oplus \;g^{1}\mathbf {D} _{1}\;\oplus \;g^{2}\mathbf {D} _{2}\;\oplus \;...\;\oplus \;g^{n-1}\mathbf {D} _{n-1}}


As before, the first checksum 




P



{\displaystyle \mathbf {P} }

 is just the XOR of each stripe, though interpreted now as a polynomial. The effect of 




g

i




{\displaystyle g^{i}}

 can be thought of as the action of a carefully chosen linear feedback shift register on the data chunk.[26]  Unlike the bit shift in the simplified example, which could only be applied 



k


{\displaystyle k}

 times before the encoding began to repeat, applying the operator 



g


{\displaystyle g}

 multiple times is guaranteed to produce 



m
=

2

k


−
1


{\displaystyle m=2^{k}-1}

 unique invertible functions, which will allow a chunk length of  



k


{\displaystyle k}

 to support up to 




2

k


−
1


{\displaystyle 2^{k}-1}

 data pieces.
If one data chunk is lost, the situation is similar to the one before. In the case of two lost data chunks, we can be compute the recovery formulas algebraically. Suppose that 





D


i




{\displaystyle \mathbf {D} _{i}}

 and 





D


j




{\displaystyle \mathbf {D} _{j}}

 are the lost values with 



i
≠
j


{\displaystyle i\neq j}

, then, using the other values of 



D


{\displaystyle D}

, we find constants 



A


{\displaystyle A}

 and 



B


{\displaystyle B}

:




A
=

P


⊕

(

⨁

ℓ
:

ℓ
≠
i


a
n
d


ℓ
≠
j




D

ℓ



)
=

D

i


⊕

D

j




{\displaystyle A=\mathbf {P} \;\oplus \;(\bigoplus _{\ell :\;\ell \not =i\;\mathrm {and} \;\ell \not =j}{D_{\ell }})=D_{i}\oplus D_{j}}






B
=

Q


⊕

(

⨁

ℓ
:

ℓ
≠
i


a
n
d


ℓ
≠
j




g

ℓ



D

ℓ



)
=

g

i



D

i


⊕

g

j



D

j




{\displaystyle B=\mathbf {Q} \;\oplus \;(\bigoplus _{\ell :\;\ell \not =i\;\mathrm {and} \;\ell \not =j}{g^{\ell }D_{\ell }})=g^{i}D_{i}\oplus g^{j}D_{j}}


We can solve for 




D

i




{\displaystyle D_{i}}

 in the second equation and plug it into the first to find  




D

j


=
(

g

n
−
i
+
j


⊕
1

)

−
1



g

n
−
i


B
⊕
A


{\displaystyle D_{j}=(g^{n-i+j}\oplus 1)^{-1}g^{n-i}B\oplus A}

,  and then 




D

i


=
A
⊕

D

j




{\displaystyle D_{i}=A\oplus D_{j}}

.
Unlike P, The computation of Q is relatively CPU intensive, as it involves polynomial multiplication in 




F

2


[
x
]

/

(
p
(
x
)
)


{\displaystyle F_{2}[x]/(p(x))}

. This can be mitigated with a hardware implementation or by using an FPGA.
Comparison


The following table provides an overview of some considerations for standard RAID levels. In each case:
Array space efficiency is given as an expression in terms of the number of drives, n; this expression designates a fractional value between zero and one, representing the fraction of the sum of the drives' capacities that is available for use. For example, if three drives are arranged in RAID3, this gives an array space efficiency of 1 − 1/n = 1 − 1/3 = 2/3 ≈ 67%; thus, if each drive in this example has a capacity of 250GB, then the array has a total capacity of 750GB but the capacity that is usable for data storage is only 500GB.


System Implications
In measurement of the I/O performance of five filesystems with five storage configurations—single SSD, RAID 0, RAID 1, RAID 10, and RAID 5 it was shown that F2FS on RAID 0 and RAID 5 with eight SSDs outperforms EXT4 by 5 times and 50 times, respectively. The measurements also suggest that RAID controller can be a significant bottleneck in building a RAID system with high speed SSDs.[27]
Nested RAID

Combinations of two or more standard RAID levels.  They are also known as RAID 0+1 or RAID 01, RAID 0+3 or RAID 03, RAID 1+0 or RAID 10, RAID 5+0 or RAID 50, RAID 6+0 or RAID 60, and RAID 10+0 or RAID 100.
Non-standard variants

In addition to standard and nested RAID levels, alternatives include non-standard RAID levels, and non-RAID drive architectures. Non-RAID drive architectures are referred to by similar terms and acronyms, notably JBOD ("just a bunch of disks"), SPAN/BIG, and MAID ("massive array of idle disks").
Notes



Further reading

, chapter 38 from the Operating Systems: Three Easy Pieces book by Remzi H. Arpaci-Dusseau and Andrea C. Arpaci-Dusseau