Mirror raid disk replacement

I had mirror raid disk faulty today so I need to swap one disk in array

It was /dev/sda hard drive

So to to this I need to remove it from raid and then add another disk into it.

Removing broken one
cat /proc/mdstat
mdadm --manage /dev/md0 --fail /dev/sda1
mdadm --manage /dev/md1 --fail /dev/sda2
mdadm --manage /dev/md2 --fail /dev/sda3

cat /proc/mdstat
mdadm --manage /dev/md0 --remove /dev/sda1
mdadm --manage /dev/md1 --remove /dev/sda2
mdadm --manage /dev/md2 --remove /dev/sda3

cat /proc/mdstat
shutdown -h now

Adding The New Hard Disk

if you have common partition table you just need to do:

sfdisk -d /dev/sdb | sfdisk --Linux /dev/sda

but in my case GUID partition table used so I need to use:

sgdisk -R=/dev/sda /dev/sdb
sgdisk -G /dev/sda

mdadm --manage /dev/md0 --add /dev/sda1
mdadm --manage /dev/md1 --add /dev/sda2
mdadm --manage /dev/md2 --add /dev/sda3

cat /proc/mdstat
or if you going to watch how it is rebuilder
watch cat /proc/mdstat

Leave a Reply

Your email address will not be published. Required fields are marked *