Mascote

notes to self.

Replacing a Failing Disk on CentOS 6

Create a identical partition map from the original disk:

1
# sfdisk -d /dev/sda | sfdisk --force /dev/sdb

search the UUID of /boot partition:

1
2
3
4
# dumpe2fs -h /dev/sda1 | grep UUID

dumpe2fs 1.42 (29-Nov-2011)
Filesystem UUID:          d22792ce-822a-4eeb-9e4f-1522214026c6

create a same filesystem type in new disk:

1
# mkfs.ext4 -U d22792ce-822a-4eeb-9e4f-1522214026c6 /dev/sdb1

copy /boot content to new disk mounted at /mnt:

1
2
3
# mount /dev/sdb1 /mnt

# rsync -avrP /boot /mnt

set the new disk as hd0 on grub:

1
2
3
# grub 
grub> find /grub/stage1
grub> device (hd0) /dev/sdb

We made the second drive /dev/sdb device (hd0) because putting grub on it this way puts a bootable mbr on the 2nd drive and when the first drive is missing the second drive will boot.

install grub on new device:

1
2
3
grub> root (hd0,0)
grub> setup (hd0)
grub> quit

add the new disk partition to volume group:

1
# vgextend VolGroup00 /dev/sdb2

move content from old to new disk:

1
# pvmove /dev/sda2 /dev/sdb2

remove old disk partition from volume group:

1
# vgreduce VolGroup00 /dev/sda2

now, you can remove the old disk without reboot, to disable the disk to remove safely:

1
# echo 1 > /sys/block/sda/device/delete

enjoy!