diff options
author | Peter Rajnoha <prajnoha@redhat.com> | 2015-10-12 11:11:34 +0200 |
---|---|---|
committer | Peter Rajnoha <prajnoha@redhat.com> | 2015-10-12 11:11:34 +0200 |
commit | 38df48d108e3b040501edfd9e0517bfcb31373de (patch) | |
tree | 5ea57609d9a046ef620db8ced540a0e5f10e3865 /scripts/vgimportclone.sh | |
parent | 21a8ac0cd3a392feaa049ab509c4727eee548d6b (diff) | |
download | lvm2-38df48d108e3b040501edfd9e0517bfcb31373de.tar.gz |
vgimportclone: fix vgimportclone with -n to not add number unnecessarily to base VG name
$ vgcreate vgA /dev/sda
Volume group "vgA" successfully created
$ dd if=/dev/sda of=/dev/sdb bs=1M
$ dd if=/dev/sda of=/dev/sdc bs=1M
(the new VG name is prefix of existing VG name)
$ vgimportclone -n vg /dev/sdb
(the new VG name is suffix of existing VG name)
$ vgimportclone -n gA /dev/sdc
Before this patch:
------------------
(we end up with "vg1" and "gA1" names with the "1" suffix which is not needed)
$ vgs -o vg_name
VG
gA1
vg1
vgA
With this patch applied:
------------------------
(we end up with "vg" and "gA" names as they're unique already and no extra suffix is added)
$ # vgs -o vg_name
VG
gA
vg
vgA
Of course, if the name supplied is not unique, the number is added correctly:
$ dd if=/dev/sda of=/dev/sdb bs=1M
$ vgimportclone -n vgA /dev/sdb
$ vgs -o vg_name
VG
vgA
vgA1
Diffstat (limited to 'scripts/vgimportclone.sh')
-rwxr-xr-x | scripts/vgimportclone.sh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/vgimportclone.sh b/scripts/vgimportclone.sh index d14a170a9..52f3884dc 100755 --- a/scripts/vgimportclone.sh +++ b/scripts/vgimportclone.sh @@ -48,7 +48,7 @@ function getvgname { NAME="${BNAME}" I=0 - while [[ "${VGLIST}" =~ "${NAME}" ]] + while [[ "${VGLIST}" =~ ":${NAME}:" ]] do I=$(($I+1)) NAME="${BNAME}$I" @@ -215,10 +215,12 @@ then fi ##################################################################### -### Get the existing state so we can use it later +### Get the existing state so we can use it later. +### The list of VG names is saved in this format: +### :vgname1:vgname2:...:vgnameN: ##################################################################### -OLDVGS=`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings` +OLDVGS=":`"${LVM}" vgs ${LVM_OPTS} -o name --noheadings --rows --separator :`:" checkvalue $? "Current VG names could not be collected without errors" ##################################################################### |