Linux Commands

How Does MDADM RAID Work on Linux

RAID or Redundant Array of Independent/Inexpensive Disks is a method of combining multiple physical disks to create a larger capacity logical disk, also known as a RAID array. It is also used to add redundancy to the data to protect them against data loss due to hardware failures.

MDADM is a tool used to create, manage, and monitor software RAID devices on Linux, supporting different types of RAID configurations.

In this article, I am going to discuss some of the MDADM terms. I am also going to discuss how different types of MDADM RAID configurations work and their requirements.

Active and Spare MDADM Devices

An MDADM RAID configuration can have active and spare devices. Active and Spare devices work together to ensure that your data is protected when one or more storage devices added to the RAID array fail.

Active Devices: The storage devices that the MDADM is currently using.

Spare Devices: The storage devices that the MDADM is not using currently but they will be added to the MDADM RAID array (as Active Devices) if one or more Active Devices fail.

The working principles of MDADM Active and Spare storage devices are described in the figures below. On the left figure, we have a 4-storage device MDADM RAID which is configured with two spare storage devices for fail-safety. When a storage device of the MDADM RAID array fails (e.g., disk 3 on the right of the figure), a Spare storage device will be added to the MDADM array as an Active storage device (e.g., disk 5 on the right of the figure).

MDADM Supported RAID Types:

MDADM supports different types of RAID configurations:

  • RAID 0
  • RAID 1
  • RAID 5
  • RAID 6
  • RAID 10 (or RAID 1+0)

In the next sections, I am going to explain the requirements for different MDADM RAID configurations and how different MDADM RAID configurations work.

How MDADM RAID-0 Works

To create an MDADM RAID array in the RAID-0 configuration, you must have at least two storage devices. The MDADM RAID-0 configuration does not need any Spare storage devices. The MDADM RAID-0 array spreads the data across all the storage devices added to the array. RAID-0 does not provide any data redundancy. So, if any one of the storage devices in the RAID-0 array fails, the entire RAID array fails (you will lose all the data). RAID-0 is mainly used to create a big storage device out of a few smaller storage devices. RAID 0 is not used in mission-critical applications.

The properties of the MDADM RAID-0 configuration are summarized below:

Minimum required storage devices: 2

Spare storage device requirements: None

Data safety: None

Data read speed: Combined read speed of all the storage devices added to the RAID-0 array.

Data write speed: Combined write speed of all the storage devices added to the RAID-0 array.

Available disk space for data storage: The total size of all the disks added to the RAID-0 array.

An example of an MDADM RAID-0 array is given in the figure below. If 2x100GB storage devices are used in the MDADM RAID-0 configuration, you can store about 200GB of data in the RAID array.

How MDADM RAID-1 Works

To create an MDADM RAID array in the RAID-1 configuration, you must have at least two storage devices. The MDADM RAID-1 configuration can have any number of Spare storage devices. The MDADM RAID-1 array stores the same data on all the storage devices added to the array. RAID-1 maximizes data redundancy. As long as one of the storage devices in the RAID-1 array is in good condition, your data will be safe. RAID-1 is mainly used to provide maximum protection for the data and is ideal for mission-critical applications.

The properties of the MDADM RAID-1 configuration are summarized below:

Minimum required storage devices: 2

Spare storage device requirements: As many as you need.

Data safety: Maximum data safety is ensured. Data is safe as long as at least one storage device is in good condition.

Data read speed: Combined read speed of all the storage devices added to the RAID-1 array.

Data write speed: Write speed of the slowest storage device of the RAID-1 array.

Available disk space for data storage: The disk space of one of the storage devices of the RAID-1 array.

An example of an MDADM RAID-1 array is given in the figure below. If 2x100GB storage devices are used in the MDADM RAID-1 configuration, you can store about 100GB of data in the RAID array. If you have added 1x100GB storage device to the RAID-1 array as a Spare device, and one of the storage devices of the RAID-1 array fails, the Spare storage device will become the Active storage device of the RAID-1 array.

How MDADM RAID-5 Works

To create an MDADM RAID array in the RAID-5 configuration, you must have at least three storage devices. The MDADM RAID-5 configuration can include any number of Spare storage devices. The MDADM RAID-5 array calculates a single parity out of the data stored on the array and spreads it among the storage devices added to the array. A single disk worth of storage space is used for storing the parity information, and the rest of the disk space can be used for storing data. The MDADM RAID-5 array can tolerate a single disk failure. RAID-5 maximizes data storage space while providing data safety. RAID-5 is good enough for storing important data.

The properties of the MDADM RAID-5 configuration are summarized below:

Minimum required storage devices: 3

Spare storage device requirements: As many as you need.

Data safety: Uses single parity to provide tolerance of a single disk failure.

Data read speed: Combined read speed of all the storage devices added to the RAID-5 array minus one storage device (as it will be used for storing parity information, not actual data).

Data write speed: Combined write speed of all the storage devices added to the RAID-5 array minus one storage device (as it will be used for storing parity information, not actual data).

Available disk space for data storage: One disk worth of storage space in the RAID-5 array is used to store parity information, not actual data. The rest of the disk space of the RAID-5 array can be used for data storage.

An example of an MDADM RAID-5 array is given in the figure (left) below. If 3x100GB storage devices are used in the MDADM RAID-5 configuration, you can store about 200GB of data in the RAID array. One storage device worth of disk space – 100GB is used to store the parity information of the RAID-5 array.

If one of the storage devices in the RAID-5 array fails, as shown in the middle figure, your data remains accessible. If you have added a 1x100GB storage device to the RAID-5 array as a Spare device, as shown in the left figure, and one of the storage devices of the RAID-5 array fails, as shown in the middle figure, the Spare storage device will become the Active storage device of the RAID-5 array, as shown in the right figure.

Once the Spare storage device becomes Active, the parity information will be used to recalculate the lost data and the newly added storage device will be populated with the recalculated data.

A group of rectangular boxes with numbers Description automatically generated

How MDADM RAID-6 Works

To create an MDADM RAID array in the RAID-6 configuration, you must have at least four storage devices. The MDADM RAID-6 configuration can have any number of Spare storage devices. The MDADM RAID-6 array calculates two sets of parities out of the data stored on the array and spreads them among the storage devices added to the array. Two disks worth of storage space is used for storing the parity information, and the rest of the disk space can be used for storing data. The MDADM RAID-6 array can tolerate two disk failures at most. RAID-6 maximizes data storage space while providing better data safety than RAID-5. RAID-6 is very good for storing important data.

The properties of the MDADM RAID-6 configuration are summarized below:

Minimum required storage devices: 4

Spare storage device requirements: As many as you need.

Data safety: Uses double parity to provide tolerance of two disk failures.

Data read speed: Combined read speed of all the storage devices added to the RAID-6 array minus two storage devices (as they will be used for storing parity information, not actual data).

Data write speed: Combined write speed of all the storage devices added to the RAID-6 array minus two storage devices (as it will be used for storing parity information, not actual data).

Available disk space for data storage: Two disks worth of storage space in the RAID-6 array are used to store parity information, not actual data. The rest of the disk space of the RAID-6 array can be used for data storage.

An example of an MDADM RAID-6 array is shown in the left figure below. If 4x100GB storage devices are used in the MDADM RAID-6 configuration, you can store about 200GB of data in the RAID array. Two storage device worth of disk space – 2x100GB is used to store the parity information of the RAID-6 array.

If a maximum of two storage devices in the RAID-6 array fail, as shown in the middle figure, your data remains accessible. If you have added a 1x100GB storage device to the RAID-6 array as a Spare device,as shown in the left figure, and one of the storage devices of the RAID-6 array fails, the Spare storage device will become the Active storage device of the RAID-6 array, as shown in the right figure.

Once the Spare storage device becomes the Active storage device in the RAID-6 array, the parity information will be used to recalculate the lost data and the newly added storage device will be populated with the recalculated data.

A group of rectangular boxes with numbers Description automatically generated

How MDADM RAID 1+0 or RAID-10 Works

MDADM RAID 1+0, or RAID-10, is a hybrid RAID configuration. It’s composed of RAID-1 arrays and RAID-0 arrays. Some of the storage devices form RAID-1 arrays and the RAID-1 arrays are then used to form a RAID-0 array.

To create a RAID-10 array, you need an even number of storage devices. Each pair of storage devices forms a RAID-1 arrays, and all the RAID-1 arrays are combined to create a RAID-0 array. Thus, giving it the name RAID-10.

An example of a RAID-10 array, or RAID 1+0 array, is illustrated in the figure below. As you can see, disk 1 (100GB) and disk 2 (100GB) create a RAID-1 array with 100GB of disk space available for data storage. In the same way, disk 3 and disk 4 form another RAID-1 array (100GB). Then, the RAID-1 arrays are then combined into a RAID-0 array, giving you 200GB of disk space for data storage.

A group of rectangular boxes with numbers and symbols Description automatically generated with medium confidence

One benefit of the RAID-10 array is that each pair of storage devices forming RAID-1 arrays is modular. Within each modular RAID-1 array, one storage device can fail, but your data remains safe.

Because of the way RAID-1 and RAID-0 work together in the RAID-10 array, in case of disk failure, the RAID array can rebuild itself faster compared to RAID-5 and RAID-6, once the failed disk is replaced. The faster rebuild performance is mainly due to its modular design and because it doesn’t have to calculate parity information like RAID-5 and RAID-6. Also, while rebuilding the RAID, the performance of the entire RAID array remains unaffected, unlike RAID-5 and RAID-6. The only performance of the disk pair of the RAID-1 array where a disk failed will be affected.

You can also add Spare storage devices to RAID-10 arrays. Spare disks work in the same way in RAID-10 as in other MDADM RAID configurations, as you can see in the figure below.

The properties of the MDADM RAID-10 configuration are summarized below:

Minimum required storage devices: 4

Spare storage device requirements: As many as you need.

Data safety: One disk of each RAID-1 group can fail at a time. So, half of the storage devices can fail and your data will still be safe as long as at least one disk of each RAID-1 group is still okay.

Data read speed: Read speed of all the storage devices added to the RAID-10 array divided by 2.

Data write speed: Calculate the write speed of all the storage devices added to the RAID-10 array by dividing it by 2.

Available disk space for data storage: Half of the storage space of the RAID-10 array can be used for storing data.

Conclusion

I have discussed some of the MDADM RAID terms. I have also discussed how different types of MDADM RAID configurations work and their requirements.

About the author

Shahriar Shovon

Freelancer & Linux System Administrator. Also loves Web API development with Node.js and JavaScript. I was born in Bangladesh. I am currently studying Electronics and Communication Engineering at Khulna University of Engineering & Technology (KUET), one of the demanding public engineering universities of Bangladesh.