Bug#851340: vgimportclone: fails with duplicated volume group
Brett Wuth
wuth at acm.org
Sat Jan 14 07:18:53 UTC 2017
Source: lvm2
Version: 2.02.111-2.2+deb8u1
Severity: normal
Tags: patch
Dear Maintainer,
vgimportclone's primary use is to import an attached media which is
has the same Volume Group as already exists. Such a situation occurs
when attaching external media which is a backup (copy) of an existing
Physical Volume.
vgimportclone fails in such situations, with an error message like:
---cut---
root at arc:/# vgimportclone -vv /dev/loop0
...
Duplicate PV V9fzvpn7u3cAAAAAnN8tLLKkd0FpzJLr on /dev/loop0 - using /dev/sda5
...
Failed to find physical volume "/dev/loop0"
---cut---
The problem is that vgimportclone fails to detect that the device is a
Physical Volume, because 'pvs' rejects it because it has a duplicate
Volume Group.
The solution is to run 'pvs' with options to look only at the device
in question and ignore all other devices. The following patch
accomplishes this fix:
---cut---
--- /sbin/vgimportclone 2016-05-27 03:08:32.000000000 -0600
+++ vgimportclone 2017-01-07 15:12:11.000000000 -0700
@@ -204,7 +204,7 @@
do
if [ -b "$ARG" ]
then
- PVS_OUT=`"${LVM}" pvs ${LVM_OPTS} --noheadings -o vg_name "$ARG"`
+ PVS_OUT=`"${LVM}" pvs ${LVM_OPTS} --config 'devices { filter = [ "a|^'$ARG'$|", "r|.*|" ] }' --noheadings -o vg_name "$ARG"`
checkvalue $? "$ARG could not be verified to be a PV without errors."
PV_VGNAME=$(echo $PVS_OUT | $GREP -v '[[:space:]]+$')
[ -z "$PV_VGNAME" ] && die 3 "$ARG is not in a VG."
---cut---
-- System Information:
Debian Release: 8.6
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 3.16.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
More information about the pkg-lvm-maintainers
mailing list