MDADM

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

MDADM

Baffometo

Baffometo

Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays.

You should be able to use any block storage devices in a RAID. Any standard directions for setting up a RAID using SATA HDD’s should be applicable when using USB storage as well. You’ll have to set it up so that the USB devices are assembled as members of the RAID array.

Example

sudo mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb1

Change the devices to the ones used by the USB storage devices. Then assemble the array:

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

Verifying the status of the RAID arrays

Checking the status/health of a RAID (also useful for checking a RAID is rebluilding):

cat /proc/mdstat

or

mdadm --detail /dev/md0

Create a new RAID array

Create (mdadm –create) is used to create a new array:

mdadm --create --verbose /dev/md0 --level=1 /dev/sda1 /dev/sdb2

If you get “mdadm: no raid-devices specified” try adding the raid-devices option

mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb2
sudo mke2fs /dev/md0

Remove a disk from an array

We can’t remove a disk directly from the array, unless it is failed, so we first have to fail it (unless it already is):
Fail sda1

mdadm --fail /dev/md0 /dev/sda1

Remove sda1 from array

mdadm --remove /dev/md0 /dev/sda1

Add a disk to an existing array

Normally done when replacing a failed disk:

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

Stop and delete a RAID array

If we want to completely remove a raid array we have to stop if first and then remove it:

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

Remove Superblock

mdadm --zero-superblock /dev/sda

Share Post

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp

Related Posts