From 042822cbffa9613df66835523c462a6018389f17 Mon Sep 17 00:00:00 2001 From: Gratien D'haese Date: Wed, 3 Apr 2019 17:29:19 +0200 Subject: [PATCH 1/2] adding 640_verify_lvm_conf.sh script Signed-off-by: Gratien D'haese --- usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh diff --git a/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh b/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh new file mode 100644 index 0000000000..7f0fd494e8 --- /dev/null +++ b/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh @@ -0,0 +1,7 @@ +# build/GNU/Linux/640_verify_lvm_conf.sh +# Purpose is to turn off the "WARNING: Failed to connect to lvmetad. Falling back to device scanning" in the output during +# the 'rear recover' process - see issue https://github.com/rear/rear/issues/2044 for more details + +if test -f $ROOTFS_DIR/etc/lvm/lvm.conf ; then + sed -i 's/use_lvmetad =.*/use_lvmetad = 0/' $ROOTFS_DIR/etc/lvm/lvm.conf +fi From 8349f73bb1eb4d392a433a2916f2d7799cd47669 Mon Sep 17 00:00:00 2001 From: Gratien D'haese Date: Fri, 5 Apr 2019 12:47:08 +0200 Subject: [PATCH 2/2] update 640_verify_lvm_conf.sh with Johannes advises #2044 Signed-off-by: Gratien D'haese --- .../build/GNU/Linux/640_verify_lvm_conf.sh | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh b/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh index 7f0fd494e8..392b80d217 100644 --- a/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh +++ b/usr/share/rear/build/GNU/Linux/640_verify_lvm_conf.sh @@ -1,7 +1,31 @@ # build/GNU/Linux/640_verify_lvm_conf.sh -# Purpose is to turn off the "WARNING: Failed to connect to lvmetad. Falling back to device scanning" in the output during -# the 'rear recover' process - see issue https://github.com/rear/rear/issues/2044 for more details +# Purpose is to turn off the +# "WARNING: Failed to connect to lvmetad. Falling back to device scanning" +# in the output during the 'rear recover' process - see issue +# https://github.com/rear/rear/issues/2044 for more details -if test -f $ROOTFS_DIR/etc/lvm/lvm.conf ; then - sed -i 's/use_lvmetad =.*/use_lvmetad = 0/' $ROOTFS_DIR/etc/lvm/lvm.conf +# Nothing to do when there is no $ROOTFS_DIR/etc/lvm/lvm.conf file: +test -f $ROOTFS_DIR/etc/lvm/lvm.conf || return 0 + +# Determine whether or not lvmetad is in use: +local use_lvmetad_active="" + +# First try the older traditional 'lvm dumpconfig': +lvm dumpconfig | grep -q 'use_lvmetad=1' && use_lvmetad_active="yes" + +# If 'lvm dumpconfig' did not work use the newer 'lvmconfig': +if ! test "$use_lvmetad_active" ; then + lvmconfig | grep -q 'use_lvmetad=1' && use_lvmetad_active="yes" fi + +# As fallback try 'lvm version': +if ! test "$use_lvmetad_active" ; then + lvm version | grep -q -- '--enable-lvmetad' && use_lvmetad_active="yes" +fi + +# Skip enforcing 'use_lvmetad = 0' in $ROOTFS_DIR/etc/lvm/lvm.conf +# if lvmetad is not in use: +is_true "$use_lvmetad_active" || return 0 + +# Enforce 'use_lvmetad = 0' in $ROOTFS_DIR/etc/lvm/lvm.conf +sed -i -e 's/.*use_lvmetad =.*/# &/' -e '/global {/ a use_lvmetad = 0' $ROOTFS_DIR/etc/lvm/lvm.conf