In this post I will describe steps to replace a failed mirror disk in a software RAID array. As an example we will use /dev/sda1 as good partition, and /dev/sdb1 as failing partition. Before starting it is recommended to backup the original disk. Before removing raid disk, please run the following command to write all disk caches to the disk:
# syncSet disk as failed
# mdadm --manage /dev/md0 --fail /dev/sdb1To verify command status check /proc/mdstat:
# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0] sdb1[2](F)
      976773168 blocks [2/1] [U_]
md1 : active raid1 sda2[0] sdb2[1]
      976773168 blocks [2/2] [UU]Remove disk
# mdadm --manage /dev/md0 --remove /dev/sdb1Now disk can be replaced with a new one.
Copy partition table to new disk
# sfdisk -d /dev/sda | sfdisk /dev/sdbCreate the mirror of the disk
# mdadm --manage /dev/md0 --add /dev/sdb1Test changes
# /sbin/mdadm --detail /dev/md0Status for RAID recovery can be shown by running command:
# cat /proc/mdstatNeed help managing or recovering Linux-based storage infrastructure?
→ Explore our Infrastructure Support Services
2 Comments
Beth Robinson · July 21, 2022 at 2:59 am
Do you have to rebuild grub?