In a Redundant Array of Inexpensive Disks (RAID) configuration, you can setup
a disk which will act as a parity disk which will act as a failover drive if
another within the array fails.
Parity works like this:
The XOR operator known also as "OR eXclusive" is similar to the OR operator
with a minor but significant difference. With the AND operator, all must be
true to evaluate to true. With the OR operator, any operand can be true and
the product is true. Example:
AND(0,0) = 0
AND(0,1) = 0
AND(1,0) = 0
AND(1,1) = 1
OR(0,0) = 0
OR(0,1) = 1
OR(1,0) = 1
OR(1,1) = 1
XOR or OR Exclusive states that if there are any differences within the
operands, the product is true. If there are no differences, the product
is false. Example:
XOR(0,0) = 0
XOR(0,1) = 1
XOR(1,0) = 1
XOR(1,1) = 0
The XOR concept is familiar to you from remedial algebra. If a positive
number is multiplied by a positive number, the product is also positive.
If you multiply a positive by a negative, you get a negative product, and
negative multiplied by a negative yields a positive product. Example:
(+x * +y) = +xy
(+x * -y) = -xy
(-x * -y) = +xy
If the operands are the same polarity, the product's polarity will be positive,
if the operands' polarities differ, the product will have a negative polarity.
I recently thought of another similarity of mathematic rules to the XOR
operator, simple addition. The concept is, when you add an even number with
an even number, the number is even. When you add an odd number with an odd
number, the number is even. When you add an even and an odd, you get an odd.
Thus, the XOR concept.
XOR, A Closer Observation
The XOR concept can be reversed to derive at the original operands. Thus,
very useful for parity such as in disk arrays. Example:
1 xor 1 = 0
1 xor 0 = 1
In the following, disk1 is the first disk in the array, disk2 is the second,
and diskx is the parity disk. The 0s and 1s are the data on each disk, as
with disk striping.
disk1 disk2 diskx
0 0 0
1 0 1
0 1 1
1 1 0
Now, diskx is simply the XORed value of the data strip on disk1 and disk2.
What if disk2 failed? You simply take the parity information and reconstruct
the data which should reside on disk2. Line by line from above, we will XOR
disk1 with the parity and derive at the original data missing from disk2:
disk1 disk2 diskx disk2
0 ? 0 0 XOR 0 is: 0
1 ? 1 1 XOR 1 is: 0
0 ? 1 0 XOR 1 is: 1
1 ? 0 1 XOR 0 is: 1
With XOR parity, you can reconstruct the missing data from disk2, you could
also have reconstructed the data of disk1 had it failed instead of disk2.
Thus diskx can be a backup of both disks given both do not fail at the same
time.
Using more than 3 disks will change the XOR concept by addition of more
complex parity generation routines. In an array, all disks are the same
size, with a 1200mb 5 disk array, all 5 disks will be the same size and
1 will be a parity disk.
1200mb/4 disk stripe = 300mb per disk
All disks would be 300mb as well as the parity disk which will be a failover
disk for any 1 of the 4 disks in the array. If more than 1 disks fail at the
same time, you had better have a tape backup.