Wednesday, 2 November 2011

Replace HDD in Linux LVM Software RAID

Lets say a drive fails and it happens to be /dev/sdb and you insert a new
unformatted drive we need to take the following actions to get the LVM SW
RAID up and running again. The OS in question is Citrix XenServer 5.6 so
the commands are specific to that partition layout.

1. Copy the partition table from /dev/sda to /dev/sdb you can use dd

dd if=/dev/sda of=/dev/sdb bs=512 count=1

2. Now set the partition table up on /dev/sda the way it should be for
Linux RAID. This means setting the partition types to 0xfd.

echo -e "\nt\n1\nfd\nt\n3\nfd\nw\nx" | fdisk /dev/sdb

3. Now we need to add the drive to RAID partitions

mdadm -a /dev/md0 /dev/sdb1
mdadm -a /dev/md1 /dev/sdb3

4. Check to see both partitions are rebuilding.

mdadm -D /dev/md0 the end of output you should see

Rebuild Status : 6% complete

UUID : 5ab2841a:99cd3850:17d24f1b:97040b83
Events : 0.52

Number Major Minor RaidDevice State
2 8 1 0 spare rebuilding /dev/sda1
1 8 17 1 active sync /dev/sdb1

run the same command for the /dev/md1 partition

mdadm --monitor /dev/md0 -1
(change to /dev/md1 for second partition)

If you get the output below - the array is still rebuilding. If you get no
output, the RAID is in sync.

Nov 2 15:18:20: DegradedArray on /dev/md0

No comments:

Post a Comment