Here are some useful one-liner recipes to help manage Linux Device Mapper (sometimes also known as ‘software RAID’) devices. These are too short to warrant separate recipes. They're here because I need them for myself: no matter how many times I've done this, I always check again.
Create MD With Devices Initially Missing
mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb3 missing
That is, add the missing keyword in place of any and all missing parts of the array.
Change /dev/md0 to the RAID device name you wish to create, and /dev/sdb3 to the partition you wish to add to the newly created array. This will obviously be razed in the process.
Re-Insert a Previously Removed Device
Sometimes a disk is dropped from an array even though it's healthy. There are good reasons for this, such as a dead host adaptor or a failed power supply on an external disk enclosure. When connectivity is restored, or should you wish to force the disk to be re-inserted, say this:
mdadm --manage /dev/md0 --re-add /dev/sda3
The disk must have previously been part of the array, of course. This is preferable to the next recipe, which registers the disk as an altogether new device.
Hot-add New Devices to an MD Array
mdadm --manage /dev/md0 --add /dev/sda3
In this way, a RAID array may be assembled piecemeal, and the system allowed to synchronise it.
View Status Detail on an MD Array
mdadm --misc -D /dev/md0
Displays essential information on the RAID array in question.
cat /proc/mdstatsDisplays less information in a more compact form (but includes more rebuild details).

Add new comment