When LVM volume groups collide

I took my hard drive and connected it to another computer with Linux installed. Both HDs had a PV which contained a VG named “vg00”. This collistion was the first time I had encounterd this situation and had to solve it to get access to files on both VGs.

During boot I noticed messages saying there two vg00 on the machine and one is taken precedence over the other. Example message:

[lvm] WARNING: Duplicate VG name vg00: Existing
K0qKAk-Ph5i-BcAX-y4yp-SPF3-TZgj-DufR3L (created here) takes precedence
over K0qKAk-Ph5i-BcAX-y4yp-SPF3-TZgj-DufR3L

The trivial solution is to rename the extra VG to something different and get the access I want to the files. But there are two problems:

  1. As the first vg00 has precedence, I can’t do actions on the second one. The LVM commands ignore the second one.
  2. I can’t act on the first VG as it’s active for most of the system’s file systems.

Trying vgrename command with the second VG UUID didn’t work. I had to deactivate the first VG first (luckily I have the root FS outside of LVM), rename it, and rename the second VG and then rename the first VG again.

This resulted in having vg00 and vg01. And now I could activate them both and access the files.

I hope to have the time to reproduce the problem on another distro to make sure that’s a general LVM2 problem. Having renmae by UUID would save time to fix the problem and help people who need to boot from CD just to get their VG deactivated (since root FS is on LVM).


Filed under Debian GNU/Linux, Red Hat Enterprise Linux

11 responses to “When LVM volume groups collide

  1. I encountered this problem years ago with LVM1. Nice to see it still isn’t solved :-/

    I learned then to name my volume groups after hostnames.

  2. It would be great if the installer asked for a name for the volume group before creation. And even better that it used the host’s name (asked when setting up the network) to name the volume group automagically.

  3. Anonymous

    @Marius: Same here; I always include hostnames in LVM names.

  4. That’s certainly how AIX does it FWIW – rename by UUID.

  5. abubasim

    When importing volume groups in AIX you chose the VG name. The name is machine specific. Linux’ LVM has gaps; for example there’s nothing AIX’s redefinevg which is very useful when handling FlashCopy of VG LUNs.

  6. Fred Richards

    I just ran into this issue. I have a habit of calling all my lvm2 vg’s “vg0”. Well my laptop died, but not the hard drive. I took it out and made it into an external usb drive, connected to my main workstation machine, and whups, here comes the error (both workstation and now-external laptop drive have “vg0”).

    What you can do to remedy it is modify /etc/lvm/lvm.conf to filter out the drives you don’t want. In my case the external usb drive is /dev/sdg (with the offending LVM partition as /dev/sdg4). Seeing as the drives in my workstation never change (/dev/sd[a,b]) I can say filter out /dev/sdg4, but allow all other /dev/sd.* drives:

    filter = [ “r|/dev/sdg4|”, “a|/dev/sd.*|” ]

    Works perfectly. If you have an issue with the usb drive (it may not be sdg upon next plug-in), try some udev trickery to make sure it keeps the same sd? letter every time…

  7. ‘vgimportclone’ takes care of this automagically.

    • fedor

      GREAT TIP, I just did it with vgimportclone successfully :

      vgimportclone -i /dev/md6 /dev/md7 /dev/md8 /dev/md9 /dev/md10
      (md6 ~ md10 are added from other server, with equal VG names..)
      PV VG Fmt Attr PSize PFree
      /dev/md1 vg0 lvm2 a- 27.94g 2.80g

      /dev/md10 vg21 lvm2 a- 931.49g 613.49g
      /dev/md2 vg1 lvm2 a- 435.86g 435.86g
      /dev/md3 vg1 lvm2 a- 931.32g 931.32g
      /dev/md4 vg1 lvm2 a- 465.66g 465.66g
      /dev/md6 vg01 lvm2 a- 27.93g 12.11g
      /dev/md7 vg11 lvm2 a- 435.86g 9.79g
      /dev/md8 vg21 lvm2 a- 465.66g 672.00m
      /dev/md9 vg11 lvm2 a- 465.76g 78.00g

  8. gvimportclone didn’t do the trick
    # vgimportclone -i /dev/sdb5
    WARNING: Activation disabled. No device-mapper interaction will be attempted.
    WARNING: Duplicate VG name hostname: Existing LjcfWS-ok9f-Dbue-hvqo-BodS-TfkF-2rhrLB (created here) takes precedence over cyX90R-DEpo-UX75-K5nY-t5Qj-2vTW-IOfA9y
    Volume group “hostname” successfully changed
    WARNING: Duplicate VG name hostname: Existing PZDBMD-mdJG-OjtH-nphc-Cb8L-cev4-fP4z2i (created here) takes precedence over cyX90R-DEpo-UX75-K5nY-t5Qj-2vTW-IOfA9y
    Found more than one VG called hostname. Please supply VG uuid.
    Fatal: Unable to rename travelmate to hostname1, error: 5

    but i found which uuid belongs where with
    # vgdisplay
    and then rename it with
    # vgrename cyX90R-DEpo-UX75-K5nY-t5Qj-2vTW-IOfA9y vg0

  9. Not sure when it was added, but vgrename now accepts a UUID.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s