Replace defective HDD on CentOS 6 (mbr)

Prologue: sda old but works, sdc defective. I will replace sdc.

First of all, mark disk sdc as defective and remove from raid.

mdadm --manage /dev/md0 --fail /dev/sdc2
mdadm --manage /dev/md1 --fail /dev/sdc1
mdadm --manage /dev/md2 --fail /dev/sdc3
mdadm /dev/md0 -r /dev/sdc2
mdadm /dev/md1 -r /dev/sdc1
mdadm /dev/md2 -r /dev/sdc3

Physically replace disk and copy partition table to new one.

sfdisk -d /dev/sda | sfdisk /dev/sdc
OR you may try 
sfdisk /dev/sda > sda_parttable_mbr.bak
sfdisk /dev/sdc < sda_parttable_mbr.bak

Add new partitions to raid

mdadm /dev/md0 -a /dev/sdc2
mdadm /dev/md1 -a /dev/sdc1
mdadm /dev/md2 -a /dev/sdc3

Install grub (grub 1.x on CentOS6, so enter “grub” in shell and then

device (hd0) /dev/sdc
root (hd0,1)
setup (hd0)

Leave a Reply

Your email address will not be published.