RAID management

  • RAID (Redundant Array of Independent Disks) - is a data storage virtualization technology that combines multiple physical disk drive components into one or more logical units for the purposes of data redundancy, performance improvement, or both.

Tip

mdadm is a tool for managing Linux software RAID devices (eg. RAID 0, RAID 1, RAID 5, etc.)

Commands:

  • mdadm --manage /dev/md0 --add /dev/sdX - add a new disk to RAID

  • mdadm --manage /dev/md0 --fail /dev/sdX - mark a disk as faulty

  • mdadm --manage /dev/md0 --remove /dev/sdX - remove a disk from RAID

  • mdadm --detail /dev/md0 and cat /proc/mdstat - display RAID status and show information about RAID

  • mdadm --stop /dev/md0 - stop RAID

  • mdadm --run /dev/md0 - start RAID

  • mdadm --assemble --run /dev/md0 /dev/sdX /dev/sdY /dev/sdZ /dev/sdW - assemble RAID from disks and start it

  • mount /dev/md0 /srv/... - mount RAID

  • fdisk -l - list disks and partitions

  • lsblk - list block devices

  • blkid - locate/print block device attributes

How to replace a faulty disk in RAID with a new one:

  1. Identify a faulty disk: mdadm --detail /dev/md0 or cat /proc/mdstat

  2. Mark a disk as faulty: mdadm --manage /dev/md0 --fail /dev/sdX

  3. Remove a disk from RAID: mdadm --manage /dev/md0 --remove /dev/sdX

  4. Turn off RAID: mdadm --stop /dev/md0

  5. Physically replace a faulty disk with a new one

  6. Add the new disk to the RAID array: mdadm --manage /dev/md0 --add /dev/sdY

  7. Start RAID: mdadm --run /dev/md0

  8. Verify RAID status: mdadm --detail /dev/md0 or cat /proc/mdstat