1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

28 Commits

Author SHA1 Message Date
Zdenek Kabelac
f678052385 shellcheck: updates
Ehance some shellcheck reported issues.
2021-04-23 23:00:55 +02:00
Zdenek Kabelac
35df4b10eb shellcheck: some apostrophe changes and cleanups 2017-10-25 22:02:54 +02:00
Zdenek Kabelac
73bbd5528c tests: scripts double quote 2017-07-10 14:23:53 +02:00
Zdenek Kabelac
afa0bd916e vgimportclone.sh: do not quote regex
Don't quote rhs of =~, it'll match literally rather than as a regex.
2017-06-29 22:23:16 +02:00
Zdenek Kabelac
ef4506069a vgimportclone.sh: use well defined tests
Prefer [ p ] && [ q ] as [ p -a q ] is not well defined.
Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
2017-06-29 22:23:16 +02:00
Zdenek Kabelac
8dc29d7cc7 vgimportclone.sh: drop extra $
$/${} is unnecessary on arithmetic variables.
2017-06-29 22:23:16 +02:00
Zdenek Kabelac
16a38dede9 vgimportclone.sh: add -r to read
read without -r will mangle backslashes.
2017-06-29 22:23:16 +02:00
Zdenek Kabelac
588b12e71d vgimportclone.sh: avoid legacy syntax
Use $(..) instead of legacy `..`.
2017-06-29 22:23:16 +02:00
Zdenek Kabelac
d745593e89 vgimportclone.sh: cannot trap signal 9 2017-06-29 22:23:16 +02:00
Zdenek Kabelac
275eeb4631 vgimportclone.sh: double quote 2017-06-29 22:23:16 +02:00
Zdenek Kabelac
96a2e00240 vgimportclone.sh: no mixing string and array
Argument mixes string and array. Use * or separate argument.
2017-06-29 22:23:16 +02:00
Peter Rajnoha
55056c2d16 vgimportclone: fix VG name variable reference in error message after failed PV uuid change 2016-01-21 14:47:48 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Peter Rajnoha
75420282e1 vgimportclone: make sure there's no prefix in VG name list
Make sure log/prefix is set to "" when getting the list of VG names.
We need this for the format to be correct so it's properly searched
through later on.
2015-10-12 12:54:59 +02:00
Peter Rajnoha
38df48d108 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
2015-10-12 11:11:34 +02:00
Peter Rajnoha
1f30ba6178 vgimportclone: cleanup the script and remove dependency on awk, grep, cut and tr
We can replace the expressions with awk/grep/cut/tr with --select now and
more suitable reporting options and modes. Also, we don't need to check
the temporary lvm.conf generated within vgimportclone script since we're
generating it ourselves now using lvmconfig, not using sed anymore like
it was before (so we can be pretty sure it's correct - we use lvmconfig
now even for generating the lvm.conf itself).
2015-10-09 16:31:02 +02:00
Zdenek Kabelac
e42ee69988 vgimporeclone: use correct cache dir path
Commit 00b36ef06a had a typo
and missed '{' for shell variable, thus command used slightly
different 'tmp' dir name for cache dir (with extra '}').

Such change was unnoticed until a recent fix in persistent
filter, lvm2 missed to update cache file when --config
was specified.

The result was, /tmp dir was accumulating snap.XXXXX} dirs when
running vgimportclose  script.
2015-09-14 09:31:26 +02:00
David Teigland
a164d603d3 vgimportclone: remove arg check that uses pvs
The arg check using pvs is unnecessary.  If the arg is not a PV,
the command will just fail later.  Using the pvs command at this
point in the command is a problem when lvmetad is running, because
the pvs command does not report duplicate PVs when using lvmetad.
(Alternatively, use_lvmetad could be disabled by adding a --config
override to this pvs command.)
2015-01-20 13:08:22 -06:00
Alasdair G Kergon
8f90f632f5 vgimportclone: Say safe to ignore lvmetad message. 2015-01-17 11:29:38 +00:00
Peter Rajnoha
b21a8412c4 vgimportclone: also notify lvmetad about changes if it's used
All the LVM commands are run in mode without lvmetad use (since lvmetad
can't handle duplicates). When we're finished with vgimportclone, we
need to notify lvmetad about changes.

Before this patch (/dev/sda and /dev/sdb contains a copy VG called "vg"):
$ vgimportclone --basevgname vg_snap /dev/sdb
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Physical volume "/tmp/snap.zcJ8LCmj/vgimport0" changed  1 physical volume changed / 0 physical volumes not changed
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully changed
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully renamed to "vg_snap"
  Reading all physical volumes.  This may take a while...
  Found volume group "vg" using metadata type lvm2
  Found volume group "fedora" using metadata type lvm2

$ vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  fedora   1   2   0 wz--n-   9.50g      0
  vg       1   1   0 wz--n- 124.00m 120.00m

(...lvmetad doesn't see the new "vg_snap"!)

With this patch applied:
$ vgimportclone --basevgname vg_snap /dev/sdb
  ...
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully renamed to "vg_snap"
Notifying lvmetad about changes since it was disabled temporarily.
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_snap" using metadata type lvm2
  Found volume group "fedora" using metadata type lvm2
  Found volume group "vg" using metadata type lvm2

$ vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  fedora    1   2   0 wz--n-   9.50g      0
  vg        1   1   0 wz--n- 124.00m 120.00m
  vg_snap   1   1   0 wz--n- 124.00m 120.00m

The "restart lvmetad before enabling it" message is a bit misleading
here - we should probably suppress this one, but we can't suppress
warning messages selectively at the moment and we don't want to lose
other warning/error messages printed...
2014-12-10 14:00:56 +01:00
Peter Rajnoha
00b36ef06a vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf for vgimportclone
With current dumpconfig, we can generate lvm.conf easily - we can merge
current lvm.conf with the config given on cmd line:
  lvm dumpconfig --mergedconfig --config "..."

This is a bit simpler than using awk and it also avoids problems when some of
the configuration is missing in existing lvm.conf file and hardcoded defaults
are used instead. The dumpconfig handles this transparently.
2014-12-10 13:59:38 +01:00
Mike Snitzer
65456a4a29 vgimportclone: remove 2>/dev/null from three lvm commands
There is no point eating stderr for these commands.  In fact the
redirect causes confusion and hurts dubugging.

Also reword an error message if the pvs command fails so as not be
certain that a device is not a PV.  Coupled with removing the stderr
redirect this will improve the user experience in the face of errors.
2013-10-21 18:04:14 -04:00
Petr Rockai
05bf4b8cc3 vgimportclone: override global_filter in lvm.conf
The global filter in system's lvm.conf may conflict with the custom filter we
set up in vgimportclone (they can easily fail to intersect). Since we explicitly
avoid talking to lvmetad in vgimportclone, it is safe and reasonable to do so.
2013-06-02 00:47:17 +02:00
Petr Rockai
dae0822698 The lvmetad client-side integration. Only active when use_lvmetad = 1 is set in
lvm.conf *and* lvmetad is running.
2012-02-23 13:11:07 +00:00
Zdenek Kabelac
77f771ebc3 Replace char class :space: with explicit chars
Some major distributions are still using 'mawk' and they are not using
the latest version - we end here with hidden dependency on the latest
version of mawk (1.3.4) while i.e. Debian Lenny seems to stay with 1.3.3.
So we end with completely broken  vgimportclone script on such system.

We would need to check for proper support of :space: and abort build if
it doesn't work or simplier replace [:space:] with [ \t] which seems
sufficient to make it work (as can be seen in this patch)

A better fix would be to use command line parameter override - leaving
as FIXME comment.

This patch makes t-vgimportclone.sh test passing on Lenny.
2011-09-07 08:31:16 +00:00
Zdenek Kabelac
7515338726 Use /bin/bash for scripts with bashisms 2010-05-14 11:33:20 +00:00
Mike Snitzer
8742213863 Various vgimportclone fixes:
- validate the specified device is a PV and that it is in a VG
- automatically enable DEBUG (-d) if >= 4 -v instances were supplied
- preserve TMP_LVM_SYSTEM_DIR if it contains an lvm.conf and -d was
  specified
- fix handling of special-case where PV is listed as "unknown device"
- more descriptive error when a PV is missing ("unknown device")
- unset LVM_SYSTEM_DIR if it was not originally set
- skip final vgscan if no changes were made
2009-06-17 15:47:01 +00:00
Mike Snitzer
761e574190 Add vgimportclone and install it and the man page by default. 2009-05-14 16:46:12 +00:00