RAID (Redundant Array of Independent Disks) allows an administrator to form an array of several hard drives into one logical drive recognized as one drive by the operating system. It also spreads the data stored over the array of drives to decrease disk access time and accomplish data redundancy. The data redundancy can be used to recover data should one of the hard drives in the array crash.
There are two types of RAID: hardware RAID and software RAID. Hardware RAID is implemented through the disk controller for the system. Instructions for configuring hardware RAID differ from controller to controller, so refer to the manual for your disk controller for instructions. Software RAID is implemented through the operating system and does use some processor and memory resources, although some software RAID implementations can produce faster disk access times than hardware RAID.
During installation, it is possible to configure software RAID as discussed. This section explains the different RAID levels available with software RAID so you can decide which level is best for you. Software RAID allows for RAID levels 0, 1, 5, and 6. RAID level 0, or striping, means that data is written across all hard drives in the array to accomplish the fast disk performance. No redundancy is used, so the size of the logical RAID drive is equal to the size of all the hard drives in the array. Because there is no redundancy, recovering data from a hard drive crash is not possible through RAID.
RAID level 1, or mirroring, means that all data is written to each disk in the array, accomplishing redundancy. The data is “mirrored” on a second drive. This allows for easy recovery should a disk fail. However, it does mean that, for example, if there are two disks in the array, the size for the logical disk is size of the smaller of the two disks because data must be mirrored to the second disk.
RAID level 5 combines striping and parity. Data is written across all disks as in RAID 0, but parity data is also written to one of the disks. Should a hard drive failure occur, this parity data can be used to recover the data from the failed drive, including while the data is being accessed and the drive is still missing from the array?
RAID level 6 is RAID level 5 with dual parity. Data is written across all disks as in RAID 5, but two sets of parity data is calculated. Performance is slightly worse than RAID 5 because the extra parity data must be calculated and written to disk. RAID 5 allows for recovery using the parity data if only one drive in the array fails. Because of the dual parity, RAID 6 allows for recovery from the failure of up to two drives in the array.
Setting Up RAID Devices
For best results, software RAID should be configured during installation, but it can be configured after installation if necessary. To set up software RAID devices after installation, install the mdadm software package. This section provides an overview of post-installation software RAID configuration. It shows you how to create a RAID array and then move the data from the existing filesystem onto it. Be sure to test the process on a test system before attempting it on a production system.
Remember to back up all data before converting partitions to software RAID devices. As with any process that modifies disk partitions and partition tables, data loss is possible.
Before starting the conversion, add the appropriate number of hard drives with the proper sizes for the RAID level. For example, two partitions are needed for RAID 1 (mirroring) and at least three partitions are needed for RAID 5. To use all the benefits of RAID, each partition in a RAID device should be on separate hard drives so each member of the RAID device can be written to at the same time and there is redundancy across separate hard drives should one fail.
It is possible to configure a RAID array with a missing partition so that the data on the existing partition can be copied to the degraded array. The existing partition is reconfigured as a RAID partition and then added to the RAID array to complete it. However, the process for doing so is more complicated and not recommended because it is easier to lose the existing data. It is recommended that new drives be used to set up the RAID device and for the existing data to then be copied to the new RAID device.
When creating partitions to use for the RAID device, make sure they are of type Linux raid auto. In fdisk, this is partition id fd. After creating the partitions for the RAID device, use the following syntax as the root user to create the RAID device:
mdadm --create /dev/mdX --level=<num> --raid-devices=<num> <device list>
The progress of the device creation can be monitored with the following command as root:
tail -f /proc/mdstat
For example, to create a RAID level 1 device /dev/md0 from three partitions, use the following command:
mdadm --create /dev/md0 --level=1 --raid-devices=3 /dev/sda5 /dev/sda6 /dev/sda7
The command cat /proc/mdstat should show output similar.