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