commit bca0e7a92af16cb7fb82ef04401cdb3286068081 Merge: d2d2300b f36bfe9b Author: pcahyna Date: Thu Jul 28 12:11:04 2022 +0200 Merge pull request #2839 from pcahyna/lvm-y Pass -y to lvcreate instead of piping the output of yes diff --git a/usr/share/rear/conf/GNU/Linux.conf b/usr/share/rear/conf/GNU/Linux.conf index 82007719..7e47b912 100644 --- a/usr/share/rear/conf/GNU/Linux.conf +++ b/usr/share/rear/conf/GNU/Linux.conf @@ -5,7 +5,7 @@ ip less parted readlink -# For noninteractive confirmation in lvm commands during layout recreation +# For noninteractive confirmation in commands yes ) diff --git a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh index 0bd863ac..6089cc09 100644 --- a/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh +++ b/usr/share/rear/layout/prepare/GNU/Linux/110_include_lvm_code.sh @@ -287,28 +287,16 @@ create_lvmvol() { # so e.g. 'lvcreate -L 123456b -n LV VG' becomes 'lvcreate -l 100%FREE -n LV VG' fallbacklvopts="$( sed -e 's/-L [0-9b]*/-l 100%FREE/' <<< "$lvopts" )" - # In SLES11 "man lvcreate" does not show '-y' or '--yes' - # so we cannot use "lvm lvcreate -y ..." - # see https://github.com/rear/rear/issues/2820#issuecomment-1161934013 - # instead we input as many 'y' as asked for by "lvm lvcreate" - # see https://github.com/rear/rear/issues/513 - # and https://github.com/rear/rear/issues/2820 - # plus be safe against possible 'set -o pipefail' non-zero exit code of 'yes' via '( yes || true ) | ...' - # see https://github.com/rear/rear/issues/2820#issuecomment-1162804476 - # because 'yes' may get terminated by SIGPIPE when plain 'yes | ...' is used - # see https://github.com/rear/rear/issues/2820#issuecomment-1162772415 - # and suppress needless "yes: standard output: Broken pipe" stderr messages - # that appear at least with newer 'yes' in coreutils-8.32 in openSUSE Leap 15.3 cat >> "$LAYOUT_CODE" </dev/null || true ) | lvm lvcreate $lvopts $vg ; then - LogPrintError "Failed to create LVM volume '$vg/$lvname' with lvcreate $lvopts $vg" - if ( yes 2>/dev/null || true ) | lvm lvcreate $fallbacklvopts $vg ; then - LogPrintError "Created LVM volume '$vg/$lvname' using fallback options lvcreate $fallbacklvopts $vg" + if ! lvm lvcreate -y $lvopts $vg ; then + LogPrintError "Failed to create LVM volume '$vg/$lvname' with lvcreate -y $lvopts $vg" + if lvm lvcreate -y $fallbacklvopts $vg ; then + LogPrintError "Created LVM volume '$vg/$lvname' using fallback options lvcreate -y $fallbacklvopts $vg" else - LogPrintError "Also failed to create LVM volume '$vg/$lvname' with lvcreate $fallbacklvopts $vg" + LogPrintError "Also failed to create LVM volume '$vg/$lvname' with lvcreate -y $fallbacklvopts $vg" # Explicit 'false' is needed to let the whole 'if then else fi' command exit with non zero exit state # to let diskrestore.sh abort here as usual when a command fails (diskrestore.sh runs with 'set -e'): false