Working with Linux software RAID

RAID (an acronym for redundant array of independent disks) is a method whereby information is spread across several disks in one of several ways called "RAID levels". Depending on what level of redundancy and/ or performance is required. Most RAID levels will allow you to keep systems up and running, in case of common hardware problems (disk failure). It is not in itself a complete data safety solution. This is very important to realize.

Most commonly used RAID levels

  • RAID 0 - Striping without parity the data is broken into blocks and these are written to their respective drives simultaneously. This allows smaller sections of the entire chunk of data to be read off the disks in parallel. It provides improved performance and additional storage but no fault tolerance. A single disk failure destroys the entire array. To setup RAID 0 one will need a minimum of 2 physical disks.
  • RAID 1 - With mirroring data is written identically to multiple disks. It provides fault tolerance but no performance improvements. The array continues to operate as long as one disk is still functioning. To setup RAID 1 one will need a minimum of 2 physical disks.
  • RAID 5 - Striping with distributed parity. The data along with the parity is written to all drives. The array is not destroyed by a single disk failure. Upon disk failure, any subsequent reads can be calculated from the distributed parity such that the disk failure is masked from the end user. However, a single disk failure results in reduced performance of the entire array until the failed disk has been replaced and the associated data rebuilt. RAID 5 provides fault tolerance and performance improvements when the array is not degraded. To setup RAID 5 one will need a minimum of 3 physical disks.
  • RAID 10 - This level is a combination of RAID 0 and RAID 1. Mirror sets are striped without parity together to create the array. RAID 10 provides fault tolerance and performance improvements even during a degraded array. Under the correct conditions this level can allow the array not to be destroyed even with a 2 disks failure. To setup RAID 10 one will need a minimum of 4 physical disks.

Mdadm also know as Linux software RAID gives you full control over your RAID configuration. If you are booting a system that has a Linux RAID configuration already configured, with a Live CD one will have to install mdadm to be able to access the raid devices. When using Linux RAID it is a good idea to know how mdadm works.

Mdadm disk Array Operation

To check status of your RAID array

cat /proc/mdstat

To assemble the exciting array /dev/md0 from the partitions /dev/sda1 and /dev/sdb1

mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1

Alternatively you can use

mdadm --assemble --scan

To create a RAID 1 (mirror) array from two partitions. If the partitions differ in size, the array is the size of the smallest partition.

mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1

To fail a drive in the array

mdadm /dev/md0 --fail /dev/sdb1

To remove a failed drive from the array

mdadm /dev/md0 --remove /dev/sdb1

To add a new drive to the array

mdadm /dev/md0 --add /dev/sdb1

Clearing any previous raid info on a disk (eg. reusing a disk from another decommissioned raid array)

mdadm --zero-superblock /dev/sdb1

To examine a partition

mdadm -E /dev/sdb1

To print details of an array

mdadm --detail /dev/md0

That's pretty much it. As long as you have mdadm available, you can create / assemble raid arrays out of identical partitions. Once you've assembled the array, treat it the same way you would a partition on a physical disk. I hope this will help someone, feel free to leave a comment below.

Posted by Deon Spengler
Last updated on Dec. 20, 2012, 12:12 p.m.

Tags: Disk Configuration

Follow Me