Categories
shellinfo tips

MDADM – Managing RAID in Linux

mdadm is a Linux utility used to manage and monitor software RAID devices. The name is derived from the term “multiple device administrator”. It is a powerful tool that can be used for a variety of tasks related to RAID arrays, such as creating, managing, and monitoring them.

Here are some examples of what you can do with mdadm:

Create a RAID array: You can use mdadm to create a new RAID array. Here’s an example of how you might create a RAID 5 array with three devices:

mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sda1 /dev/sdb1 /dev/sdc1

In this example, /dev/md0 is the name of the new RAID device, –level=5 specifies that it should be a RAID 5 array, and –raid-devices=3 indicates that there should be three devices in the array. The devices /dev/sda1, /dev/sdb1, and /dev/sdc1 are the partitions that will be included in the array.

Monitor a RAID array: mdadm can also be used to monitor the status of a RAID array. For example, you can use the following command to check the status of the /dev/md0 array:

mdadm --detail /dev/md0

This command will display detailed information about the array, such as its level, size, and the status of each device in the array.

Add a new device to an existing RAID array: If you want to add a new device to an existing RAID array, you can use the –add option. For example, to add a new device /dev/sdd1 to the /dev/md0 array, you would use the following command:

mdadm --manage /dev/md0 --add /dev/sdd1

Remove a device from a RAID array: Similarly, you can remove a device from an array using the –remove option. For example, to remove the device /dev/sdd1 from the /dev/md0 array, you would use the following command:

mdadm --manage /dev/md0 --remove /dev/sdd1

Stop and delete a RAID array: If you no longer need a RAID array, you can stop it and then delete it using mdadm. Here’s how you might do that:

mdadm --stop /dev/md0
mdadm --remove /dev/md0

These are just a few examples of what you can do with mdadm. It’s a very powerful tool with many more options and capabilities. Always make sure to check the man page (man mdadm) or other documentation for more information and to understand the implications of any command before you run it.

Leave a Reply

Your email address will not be published. Required fields are marked *