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 7cfdfcf2..1be17ba8 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 @@ -68,9 +68,9 @@ create_lvmgrp() { local vg=${vgrp#/dev/} cat >> "$LAYOUT_CODE" <> "$LAYOUT_CODE" <&2 ; then LogPrint "Sleeping 3 seconds to let udev or systemd-udevd create their devices..." sleep 3 >&2 - create_volume_group=0 - create_logical_volumes=0 + create_volume_group=( \$( RmInArray "$vg" "\${create_volume_group[@]}" ) ) + create_logical_volumes=( \$( RmInArray "$vg" "\${create_logical_volumes[@]}" ) ) +EOF + if is_true "${FORCE_VGCFGRESTORE-no}"; then + cat >> "$LAYOUT_CODE" <&2 ; then sleep 3 >&2 # All logical volumes have been created, except Thin volumes and pools - create_volume_group=0 - create_thin_volumes_only=1 + create_volume_group=( \$( RmInArray "$vg" "\${create_volume_group[@]}" ) ) + create_thin_volumes_only+=( "$vg" ) +EOF + fi + cat >> "$LAYOUT_CODE" <> "$LAYOUT_CODE" < in the first argument) +# doesn't contain any LVs that use kernel metadata. +# If the function returns true, we can safely use vgcfgrestore to restore the VG. +function lvmgrp_supports_vgcfgrestore() { + if is_true "${FORCE_VGCFGRESTORE-no}"; then + # If we are willing to use vgcfgrestore --force and then remove broken volumes, + # then everything can be considered supported. Don't do it by default though. + return 0 + fi + + local lvmvol vgrp lvname size layout kval + + local supported_layouts=("linear" "striped") + + while read lvmvol vgrp lvname size layout kval; do + [ "$vgrp" == "$1" ] || BugError "vgrp '$vgrp' != '$1'" + if ! IsInArray $layout "${supported_layouts[@]}"; then + LogPrint "Layout '$layout' of LV '$lvname' in VG '$vgrp' not supported by vgcfgrestore" + return 1 + fi + done < <(grep "^lvmvol $1 " "$LAYOUT_FILE") +} + # vim: set et ts=4 sw=4: