MDRAID Common Commands
Creating an array
# mdadm --create --verbose /dev/md0 --level=1 --ind-devices = 2 /dev/sda1 /dev/sdb1
Then you need to create a configuration file mdadm.conf
# mdadm --detail --scan> /etc/mdadm/mdadm.conf
And write the changes to the boot image:
# update-initramfs -u
Work with array
Mark a disk as failed
The disk in the array can be conditionally failed, the key –fail (-f):
# mdadm /dev/md0 --fail /dev/sda1 # mdadm /dev/md0 -f /dev/sda1
Remove a failed disk
The failed disk can be removed with the –remove (-r) switch:
# mdadm /dev/md0 --remove /dev/sda1 # mdadm /dev/md0 -r /dev/sda1
Adding a new drive
You can add a new disk to the array using the –add (-a) and –re-add options:
# mdadm /dev/md0 --add /dev/sda1 # mdadm /dev/md0 -a /dev/sda1
Build an existing array
You can assemble an existing array using mdadm –assemble. As an additional argument, it is indicated whether the device should be scanned, and if not, which devices should be collected.
# mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 # mdadm --assemble --scan
Check array status and get information and array
Array Status:
# cat /proc/mdstat
Array Information:
# mdadm --detail /dev/md0
Information about the array element:
# mdadm --examine /dev/sda1
Integrity check
We oversaw the check
# echo check > /sys/block/md1/md/sync_action
see the result
# cat /proc/mdstat Personalities: [raid10] [raid1] md0: active raid1 sdb1 [1] sda1 [0] sdc1 [2] sdd1 [3] 128384 blocks [4/4] [UUUU] md1: active raid10 sdd2 [3] sdc2 [2] sda2 [0] sdb2 [1] 134222848 blocks 256K chunks 2 near-copies [4/4] [UUUU] [> ....................] check = 0.5% (787072/134222848) finish = 19.7min speed = 112440K / sec
Kill array
# mdadm --stop /dev/md0 # mdadm --zero-superblock /dev/sda ..