summaryrefslogtreecommitdiff
path: root/scripts/vgimportclone.sh
Commit message (Collapse)AuthorAgeFilesLines
* shellcheck: updatesZdenek Kabelac2021-04-231-6/+6
| | | | Ehance some shellcheck reported issues.
* shellcheck: some apostrophe changes and cleanupsZdenek Kabelac2017-10-251-4/+4
|
* tests: scripts double quoteZdenek Kabelac2017-07-101-7/+7
|
* vgimportclone.sh: do not quote regexZdenek Kabelac2017-06-291-1/+1
| | | | Don't quote rhs of =~, it'll match literally rather than as a regex.
* vgimportclone.sh: use well defined testsZdenek Kabelac2017-06-291-5/+3
| | | | | Prefer [ p ] && [ q ] as [ p -a q ] is not well defined. Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
* vgimportclone.sh: drop extra $Zdenek Kabelac2017-06-291-2/+2
| | | | $/${} is unnecessary on arithmetic variables.
* vgimportclone.sh: add -r to readZdenek Kabelac2017-06-291-2/+2
| | | | read without -r will mangle backslashes.
* vgimportclone.sh: avoid legacy syntaxZdenek Kabelac2017-06-291-11/+11
| | | | Use $(..) instead of legacy `..`.
* vgimportclone.sh: cannot trap signal 9Zdenek Kabelac2017-06-291-1/+1
|
* vgimportclone.sh: double quoteZdenek Kabelac2017-06-291-11/+10
|
* vgimportclone.sh: no mixing string and arrayZdenek Kabelac2017-06-291-1/+1
| | | | Argument mixes string and array. Use * or separate argument.
* vgimportclone: fix VG name variable reference in error message after failed ↵Peter Rajnoha2016-01-211-1/+1
| | | | PV uuid change
* doc: change fsf addressZdenek Kabelac2016-01-211-1/+1
| | | | | Hmm rpmlint suggest fsf is using a different address these days, so lets keep it up-to-date
* vgimportclone: make sure there's no prefix in VG name listPeter Rajnoha2015-10-121-1/+1
| | | | | | 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.
* vgimportclone: fix vgimportclone with -n to not add number unnecessarily to ↵Peter Rajnoha2015-10-121-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* vgimportclone: cleanup the script and remove dependency on awk, grep, cut and trPeter Rajnoha2015-10-091-62/+25
| | | | | | | | | 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).
* vgimporeclone: use correct cache dir pathZdenek Kabelac2015-09-141-2/+2
| | | | | | | | | | | | | Commit 00b36ef06acb15c82d7c9b37872753f02c638316 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.
* vgimportclone: remove arg check that uses pvsDavid Teigland2015-01-201-5/+0
| | | | | | | | | 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.)
* vgimportclone: Say safe to ignore lvmetad message.Alasdair G Kergon2015-01-171-0/+1
|
* vgimportclone: also notify lvmetad about changes if it's usedPeter Rajnoha2014-12-101-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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...
* vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf ↵Peter Rajnoha2014-12-101-11/+11
| | | | | | | | | | | | 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.
* vgimportclone: remove 2>/dev/null from three lvm commandsMike Snitzer2013-10-211-4/+4
| | | | | | | | | 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.
* vgimportclone: override global_filter in lvm.confPetr Rockai2013-06-021-0/+1
| | | | | | 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.
* The lvmetad client-side integration. Only active when use_lvmetad = 1 is set inPetr Rockai2012-02-231-0/+1
| | | | lvm.conf *and* lvmetad is running.
* Replace char class :space: with explicit charsZdenek Kabelac2011-09-071-5/+6
| | | | | | | | | | | | | | | | 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.
* Use /bin/bash for scripts with bashismsZdenek Kabelac2010-05-141-1/+1
|
* Various vgimportclone fixes:Mike Snitzer2009-06-171-10/+42
| | | | | | | | | | | - 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
* Add vgimportclone and install it and the man page by default.Mike Snitzer2009-05-141-0/+334