A minimum of 3 HDDs is required to create a RAID 5. Calculating a parity, the RAID 5 can work if one of the HDD is down.
Let's say we have a RAID 5, made of 4 HDDs. The file written on the RAID system is divided in small blocks with a length of X sectors. The first block of the file is written on the first HDD, the second one on the second HDD and the third one on the third HDD. Then from these 3 blocks, the parity is calculated (it is a XOR result of the 3 blocks). This parity is written on the fourth HDD. It goes on and on for each line.
To avoid having all the parities on the same HDD, the parity is written on a different HDD in a cyclic way.
The parity is a XOR (eXclusive OR) calculated on the data blocks. If a HDD fails, a block per line is missing. The missing block can then be calculated from the other blocks. This is a simple equation.
When replacing a failed HDD, the missing data is recreated, thanks to the other HDDs of the RAID 5.
Because of the parity, the data cannot be stored on one of the HDDs. For example, if you use 5 drives of 1To, you'll have 4To of free space on the RAID 5 (5 * 1To - 1To).
The common RAID 5 failures are :