vgimportclone doesn't work

Bug #695759 reported by Kris Lindgren
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
lvm2 (Ubuntu)
Fix Released
Undecided
Unassigned
Precise
Won't Fix
Low
Unassigned

Bug Description

Binary package hint: lvm2

Ubuntu Version:
Ubuntu 10.04.1 LTS (however this also effects 10.10 With latest updates as well)

LVM2 version:
lvm2:
  Installed: 2.02.54-1ubuntu4.1
  Candidate: 2.02.54-1ubuntu4.1
  Version table:
 *** 2.02.54-1ubuntu4.1 0
        500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main Packages
        500 http://security.ubuntu.com/ubuntu/ lucid-security/main Packages
        100 /var/lib/dpkg/status
     2.02.54-1ubuntu4 0
        500 http://us.archive.ubuntu.com/ubuntu/ lucid/main Packages

vgimportclone is suppose to import and rename a duplicated volume group on the specified PV device. However, every volumegroup except for the specified PV is modified and you still end up with duplicate VG uuid's and names.

I am using xen with the VM running in PV mode for my testing however anything that supports the ability to make a clone of a volume will work.

1.) Create a new disk for the VM
2.) Partition the disk: fdisk /dev/xvdb
 type: n <enter> p <enter> 1 <enter> <enter> <enter> t <enter> 8e <enter> w <enter>
3.) Create a PV on the new partition: pvcreate /dev/xvdb1
4.) Create a Volume Group: vgcreate myvol /dev/xvdb1
5.) Create a Logical Volume on the volume group: lvcreate -L 9G myvol -n vol0
6.) Format the new disk with ext3: mke2fs -j /dev/myvol/vol0
7.) Detach the disk from the vm and copy the virtual disk file
8.) Reattach the disk to the VM
9.) Attach the copy of the virtual disk file to the VM as well

At this point you should have two identical copies of the same volume and a pvscan should report that /dev/xvdc1 and /dev/xvdb1 have a duplicate PV:
# pvscan
Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  PV /dev/xvdc1 VG myvol lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvda5 VG localhost lvm2 [39.53 GiB / 0 free]
  Total: 2 [49.53 GiB] / in use: 2 [49.53 GiB] / in no VG: 0 [0 ]

10.) run vgimportclone which is suppose to rename and re-signature the VG and PV on the specified PV: vgimportclone /dev/xvdc1
output from command is below:
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  Volume group "myvol" successfully changed
  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  Volume group "myvol" successfully renamed to "myvol1"
Volume Group /dev/xvdc1, exported, skipping.
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  Volume group "localhost" successfully changed
  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  Volume group "localhost1" successfully renamed to "localhost1"
Volume Group /dev/xvda5, exported, skipping.
  Reading all physical volumes. This may take a while...
  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  Found volume group "myvol1" using metadata type lvm2
  Found volume group "localhost1" using metadata type lvm2

Actual result:
The original volume and cloned volume still have the same PV UUID and and while it did change the VG name it changed it on *both* VG's. In addition it also renames the VG that the root filesystem is on which results in a machine that is not longer bootable unless fixed. A pvscan after the vgimportclone will show:

  Found duplicate PV eUd4WtLf5v552pWUsT1Wi37gTRs9NSUS: using /dev/xvdc1 not /dev/xvdb1
  PV /dev/xvdc1 VG myvol1 lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvda5 VG localhost1 lvm2 [39.53 GiB / 0 free]
  Total: 2 [49.53 GiB] / in use: 2 [49.53 GiB] / in no VG: 0 [0 ]

Expected Result:
The cloned volume (/dev/xvdc1) has its uuid changed for both the PV and VG and the VG is renamed to myvol1. No other Volume Groups are change and a pvscan shows:
  PV /dev/xvdc1 VG myvol1 lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvdb1 VG myvol lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvda2 VG localhost lvm2 [39.50 GiB / 0 free]
  Total: 3 [59.49 GiB] / in use: 3 [59.49 GiB] / in no VG: 0 [0 ]

In testing running this same procedure against a CentOS 5.5 and Fedora14 vm gives the expected results. Output from the commands ran against a fedora 14 VM:
# pvscan
  Found duplicate PV eQR7dX6WLFW4cn5eWBYHYd5i1Xf1Ri89: using /dev/xvdc1 not /dev/xvdb1
  PV /dev/xvdc1 VG myvol lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvda2 VG VolGroup lvm2 [39.50 GiB / 0 free]
  Total: 2 [49.50 GiB] / in use: 2 [49.50 GiB] / in no VG: 0 [0 ]

# vgimportclone /dev/xvdc1
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  Physical volume "/tmp/snap.ECGQVQW0/vgimport0" changed
  1 physical volume changed / 0 physical volumes not changed
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  Volume group "myvol" successfully changed
  Volume group "myvol" successfully renamed to "myvol1"
  Reading all physical volumes. This may take a while...
  Found volume group "myvol1" using metadata type lvm2
  Found volume group "myvol" using metadata type lvm2
  Found volume group "VolGroup" using metadata type lvm2

# pvscan
  PV /dev/xvdc1 VG myvol1 lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvdb1 VG myvol lvm2 [10.00 GiB / 1020.00 MiB free]
  PV /dev/xvda2 VG VolGroup lvm2 [39.50 GiB / 0 free]
  Total: 3 [59.49 GiB] / in use: 3 [59.49 GiB] / in no VG: 0 [0 ]

and a vgdisplay confirms that vgimportclone works as expected:

# vgdisplay
  --- Volume group ---
  VG Name myvol1
  System ID
  Format lvm2
  Metadata Areas 1
  Metadata Sequence No 5
  VG Access read/write
  VG Status resizable
  MAX LV 0
  Cur LV 1
  Open LV 0
  Max PV 0
  Cur PV 1
  Act PV 1
  VG Size 10.00 GiB
  PE Size 4.00 MiB
  Total PE 2559
  Alloc PE / Size 2304 / 9.00 GiB
  Free PE / Size 255 / 1020.00 MiB
  VG UUID pafrn7-OQjU-T062-T2h7-03Wm-4FYj-IwWy2q

  --- Volume group ---
  VG Name myvol
  System ID
  Format lvm2
  Metadata Areas 1
  Metadata Sequence No 2
  VG Access read/write
  VG Status resizable
  MAX LV 0
  Cur LV 1
  Open LV 0
  Max PV 0
  Cur PV 1
  Act PV 1
  VG Size 10.00 GiB
  PE Size 4.00 MiB
  Total PE 2559
  Alloc PE / Size 2304 / 9.00 GiB
  Free PE / Size 255 / 1020.00 MiB
  VG UUID EkmKKh-VGkn-JWes-KGkH-9nh6-ncWC-RaFnV4

  --- Volume group ---
  VG Name VolGroup
  System ID
  Format lvm2
  Metadata Areas 1
  Metadata Sequence No 3
  VG Access read/write
  VG Status resizable
  MAX LV 0
  Cur LV 2
  Open LV 2
  Max PV 0
  Cur PV 1
  Act PV 1
  VG Size 39.50 GiB
  PE Size 32.00 MiB
  Total PE 1264
  Alloc PE / Size 1264 / 39.50 GiB
  Free PE / Size 0 / 0
  VG UUID J4ZVmb-rTab-OycL-k2Oe-3pun-4s5j-jk1saA

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in lvm2 (Ubuntu):
status: New → Confirmed
Revision history for this message
Clayton Smith (argilo) wrote :

I just got hit by this bug too. On a fully patched Ubuntu Server 10.04.4 LTS box, I used vgimportclone and it renamed a different volume group than I asked it to, leaving me with an unbootable system until I was able to rename the volume group back.

Revision history for this message
Tony Abbott (t-abbott) wrote :

I have just had the same problem on a fully updated 12.04 LTS box. I scratched around and discovered that vgimportclone is a shell script that makes a temporary copy of your lvm.conf and sets up a filter in that custom config so as to only operate on the physical volumes you specify on the command line. It uses awk to do this customisation work but its awk scripts do not work under nawk (which is the awk implementation installed by default on Ubuntu). This results in an empty filter in the config file, so it finds all physical volumes and ends up renaming all volume groups instead of scoping itself to those specified on the command line.

vgimportclone should be fixed to use more portable awk syntax but as a workaround installing gawk fixed it for me. This changed /etc/alternatives/awk from nawk to gawk - I'm not sure if this breaks anything else that might rely on alternatives pointing to nawk but I haven't seen any ill effects thus far.

Revision history for this message
Tony Abbott (t-abbott) wrote :

See http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=660839

and

from ftp://sources.redhat.com/pub/lvm2/WHATS_NEW

Version 2.02.89 - 26th January 2012
===================================
...
  Replace :space: with [\t ] for awk in vgimportclone (not widely supported).

12.04 LTS still uses 2.02.66

Changed in lvm2 (Ubuntu):
status: Confirmed → Fix Released
Changed in lvm2 (Ubuntu Precise):
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
Steve Langasek (vorlon) wrote :

The Precise Pangolin has reached end of life, so this bug will not be fixed for that release

Changed in lvm2 (Ubuntu Precise):
status: Confirmed → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.