D   A   T   A   W   O   K





Creation: January 01 1970
Modified: June 27 2019

Raid1 Mini How-To

For this how-to I've preferred to use loopback devices in place of real hard drives. This allows to better play with the storage devices in a more destructive way.

Preparation

We'll set up a raid1 device using two block devices and one spare device.

Management

The two extra disks are detected by the system as sdb and sdc. The disks are mirrored in RAID 1.

$ mdadm --create --verbose /dev/md0 --level=mirror \
    raid-devices=2 /dev/sdb1 /dev/sdc1

Eventually one ore more devices can be added to the array as stand-by spare disks. Spare disks will automatially become part of the mirror if one of the active devices break.

$ mdadm --create --verbose /dev/md0 --level=mirror \
    raid-devices=2 /dev/sdb1 /dev/sdc1 --spare-devices=1 /dev/sdd1

To examine the details

$ mdadm --detail /dev/md0

To stop a running raid device

$ mdadm --stop /dev/md0

To reassemle an already created raid

$ mdadm --assemble /dev/md0 /dev/sdb1 /dev/sdc1

Troubleshooting

For various reasons can happen that a raid device is showed as removed E.g.

$ mdadm --detail /dev/md0
...
Number   Major   Minor   RaidDevice State
   3       8       17        0      active sync   /dev/sdb1
   2       8       33        1      removed       /dev/sdc1

In this case the device should be re-added "by-hand" to the raid array. First zero out the device super block

$ mdadm --zero-superblock /dev/sdc1

Then add the device

$ mdadm /dev/md0 --add /dev/sdc1

Once added, the device starts syncing the device with the array.

$ mdadm --detail /dev/md0
...
Number   Major   Minor   RaidDevice State
   3       8       17        0      active sync        /dev/sdb1
   2       8       33        1      spare rebuilding   /dev/sdc1

The process can be monitored via the /proc/mdstat file

$ watch cat /proc/mdstat