Changing Hard Drives

I spent the weekend switching the RAID1 array of 1TB Seagate® Barracuda® 7200.11 drives on my server with the newer 1TB Seagate® Barracuda® 7200.12 RAID1 array in my workstation. There was an LVM volume group called raid1 running on top of each raid array. I had some problems because I forgot to remove the raid superblock from the first drives before adding them into the new machine, which resulted in a duplicate raid1 volume group. The following is the process I used to transfer the drives and how I resulted the duplicate volume group problem.

The full process of transferring drives

  1. removing a drive from each array.
    # mdadm --manage /dev/md1 --fail /dev/sda1
    # mdadm --manage /dev/md1 --remove /dev/sda1
  2. Removing raid superblocks from the partitions so they are not auto-assembled in the new machine. Query the partition to check the superblock has been removed.
    # mdadm --zero-superblock /dev/sda1
    # mdadm --query --examine /dev/sda1
  3. shutting down the machine
  4. removing the drive from the old machine and adding to the new machine.
  5. syncing the partition table. make sure you sync the right drive.
    # sfdisk -d /dev/sda | sfdisk /dev/sdb
  6. adding raid partitions drives to each array.
    # mdadm --manage /dev/md1 --add /dev/sda1
  7. waiting for the drives to finish syncing.
    # watch cat /proc/mdstat
  8. repeating the whole process with the second drive.

Unfortunately, I didn’t remove the superblocks from the first drive I moved so when I rebooted the system the raid arrays from the old machine were also assembled. Both the new and old raid arrays had LVM volume groups on them, which resulted in a duplicate LVM volume group. Unfortunately most lvm commands refer directly to the volume group name so it was a bit difficult to remove the old volume group. The method I used is given below.

Removing Duplicate LVM Volume Group

LVM volume groups are distinguished by a UUID. If two volume groups have the same name only the first found is activated at boot.

  1. Find the UUID for the volume group you want to keep.
    # vgdisplay
    .
    WARNING: Duplicate VG name raid1: Existing rjHVel-8jZ0-bAfC-HRFo-fBoF-e1Tt-WZWeSV (created here) takes precedence over QL8S9K-auqb-U74h-qStq-WIzP-FEaZ-oW62MX
  2. deactivate the logical volumes. If they are mounted you will need to unmount them first.
    # vgchange -an raid1
  3. Rename the volume group you want to keep.
    # vgrename rjHVel-8jZ0-bAfC-HRFo-fBoF-e1Tt-WZWeSV raidx
  4. Remove missing drives from the volume group you want to remove
    # vgreduce --removemissing raid1
  5. Remove the volume group
    # vgremove raid1
  6. Rename the volume group back to its original name.
    # vgrename raidx raid1
  7. Tue, 24 Nov 2009 12:59 Posted in

    Tags , , , ,

    Comment Changing Hard Drives


RSS