Edward’s Notes

Technical topics and photos.

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.
  2. $ mdadm --manage /dev/md1 --fail /dev/sda1
    $ mdadm --manage /dev/md1 --remove /dev/sda1
  3. 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.
  4. $ mdadm --zero-superblock /dev/sda1
    $ mdadm --query --examine /dev/sda1
  5. shutting down the machine
  6. removing the drive from the old machine and adding to the new machine.
  7. syncing the partition table. make sure you sync the right drive.
  8. $ sfdisk -d /dev/sda | sfdisk /dev/sdb
  9. adding raid partitions drives to each array.
  10. $ mdadm --manage /dev/md1 --add /dev/sda1
  11. waiting for the drives to finish syncing.
  12. $ watch cat /proc/mdstat
  13. 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.
  2. $ 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
  3. deactivate the logical volumes. If they are mounted you will need to unmount them first.
  4. $ vgchange -an raid1
  5. Rename the volume group you want to keep.
  6. $ vgrename rjHVel-8jZ0-bAfC-HRFo-fBoF-e1Tt-WZWeSV raidx
  7. Remove missing drives from the volume group you want to remove
  8. $ vgreduce --removemissing raid1
  9. Remove the volume group
  10. $ vgremove raid1
  11. Rename the volume group back to its original name.
  12. $ vgrename raidx raid1

Comments