version 1.0.0, 2014-07-05 : Initial version
RAID management commands on RedHat based distributions
These are various logical RAID management commands.You’ll need the mdadm package here.
Creating a logical /dev/md0 RAID 5 device from /dev/sdb1, /dev/sdc1 and /dev/sdd1 partitions.
# First verify that all the partitions have been created using fdisk fdisk -l # If not, create them fdisk /dev/sdd # Finally create the RAID mdadm -Cv /dev/md0 --level=5 -n3 /dev/sdb1 /dev/sdc1 /dev/sdd1
Then verify the status using
# First verify the md number taken by the RAID cat /proc/mdstat # Then get the details mdadm --detail /dev/md0
Fail a given disk of md0 using
mdadm /dev/md0 -f /dev/sdb1
Remove a disk from the array using
mdadm /dev/md0 -r /dev/sdb1
Or combine them using: mdadm -v /dev/md0 -f /dev/sdb1 -r /dev/sdb1
Add a disk in the array using
mdadm /dev/md0 -a /dev/sdb1
Add then the RAID device to LVM using the classic pvcreate /dev/md0
Drop the array using
# First switch array offline after removing from LVM using pvremove mdadm -vS /dev/md0 # Then remove the device (seems not needed on Centos 6.5) mdadm --remove /dev/md0 # Finally, zero the superblock mdadm --zero-superblock /dev/sdb1 /dev/sdc1 /dev/sdd1
Find stopped RAID arrays:
# mdadm -v --examine --scan ARRAY /dev/md/0 level=raid5 metadata=1.2 num-devices=3 UUID=187b93af:44c4a179:06ae2b77:59e32205 name=RHEL01:0 devices=/dev/sdd1,/dev/sdc1,/dev/sdb1
Changing the device name from a given device. Here our device is called
/dev/md127
and we would like to start it as /dev/md0
, do:
# First switch array offline after removing from LVM using pvremove mdadm -vS /dev/md127 # Then scan the offline devices to get the UUID mdadm -v --examine --scan # And use this UUID to start the device with the new device name mdadm --assemble --run -u 187b93af:44c4a179:06ae2b77:59e32205 /dev/md0 # And check the drive is now available from /proc/mdstat cat /proc/mdstat # If you want your new configuration to be preserved between reboots mdadm --detail --brief /dev/md0 >> /etc/mdadm.conf # And remove the line related to the old configuration of this device if exists # in this configuration file.
Warning
/boot
can only use basic partitions or logical RAID 1 because GRUB
don’t undestand the other types of RAID.