Officially known as Multiple Disk and Device Management, mdadm is a Linux utility that is used in the creation, management, and monitoring of software-based RAID devices. In modern Linux distros, it's a command line tool that serves as a replacement for outdated utilities like raidtools and raidtools2.
But how exactly is mdadm used to configure RAID, and how can it make your life easier?
Creating a RAID Array with mdadm
The process of creating a RAID array is one of mdadm's most basic features. Start by entering the following command:
- # mdadm --create /dev/md/test --homehost=any --metadata=1.0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
Note that the command string above contains some custom parameters. These include:
- Homehost: This corresponds with the name of your computer, which must match the name that's stored in the attributes of RAID. To disable this restriction, use the name "any".
- Metadata: The metadata parameter is used to indicate the format and location of RAID metadata, which contains technical information on the RAID array.
- Level: This is used to indicate how data is distributed across other devices in the RAID array. Level 1, for example, is commonly known as disk mirroring.
- RAID-Devices: Use this parameter to indicate the number of devices that comprise the final RAID array.
Assembling and Starting a RAID Array with mdadm
This is another basic feature of mdadm. To force a RAID assembly and startup, use the command:
- # mdadm --assemble --run /dev/md/test /dev/sda1
Note that this command will work even a member of the RAID array is missing. If you want to check the status of your assembled RAID arrays, use the command:
Stopping and Deleted a RAID Array with mdadm
You can also use mdadm to stop or delete a RAID array. To stop a current RAID array, use the command:
- # mdadm --stop /dev/md/test
If you want to delete a previously created RAID array, use the command:
- # mdadm --zero-superblock /dev/sda1 /dev/sdb1
Benefits of mdadm RAID
Now that you have a better idea of how to use mdadm to configure and manage RAID arrays, it's time to identify some of the biggest benefits and advantages of mdadm. These include:
- Freeware: Not only is mdadm freeware, but it's had enough time to fully mature throughout its development cycle.
- Upgradeable: The process of upgrading mdadm is much easier than having to flash the BIOS of a hardware-based RAID controller.
- Monitoring: Not only does mdadm facilitate routine array verifications, but it doesn't obstruct SMART monitoring that is present in some drives.
- Additional Features: mdadm includes many features that aren't included in hardware-based RAID controllers.
- Performance: Although motherboard-based RAID still outperforms mdadm's software-based RAID in some areas, their day-to-day performance is comparable.
- Compatibility: Since mdadm is compatible with nearly any type of hardware, including any RAID or non-RAID HDD controllers that are support by the Linux kernel, it's usable in almost any modern system.
While hardware-based RAID will still be the more reliable option, software-based RAID via mdadm is becoming an increasingly popular choice amongst Linux users.