Public bug reported:
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 / 0free]
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 myvol1lvm2 [10.00 GiB / 1020.00 MiB free]
PV /dev/xvda5 VG localhost1 lvm2 [39.53 GiB / 0free]
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 / 0free]
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 / 0free]
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