Skip invalid disk drives when saving layout
Upstream PR #3047 Resolves: RHEL-22863
This commit is contained in:
parent
5f383567e5
commit
822a050ced
60
rear-skip-invalid-drives-RHEL-22863.patch
Normal file
60
rear-skip-invalid-drives-RHEL-22863.patch
Normal file
@ -0,0 +1,60 @@
|
||||
diff --git a/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh b/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh
|
||||
index da6ce64c4..ab14ec83f 100644
|
||||
--- a/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh
|
||||
+++ b/usr/share/rear/layout/save/GNU/Linux/200_partition_layout.sh
|
||||
@@ -395,6 +395,10 @@ Log "Saving disk partitions."
|
||||
elif [[ ! ($blockd = *rpmb || $blockd = *[0-9]boot[0-9]) ]]; then # Silently skip Replay Protected Memory Blocks and others
|
||||
devname=$(get_device_name $disk)
|
||||
devsize=$(get_disk_size ${disk#/sys/block/})
|
||||
+ if ! validation_error=$(is_disk_valid $devname) ; then
|
||||
+ LogPrintError "Ignoring $blockd: $validation_error"
|
||||
+ continue
|
||||
+ fi
|
||||
disktype=$(parted -s $devname print | grep -E "Partition Table|Disk label" | cut -d ":" -f "2" | tr -d " ")
|
||||
if [ "$disktype" != "dasd" ]; then
|
||||
echo "# Disk $devname"
|
||||
diff --git a/usr/share/rear/lib/layout-functions.sh b/usr/share/rear/lib/layout-functions.sh
|
||||
index f5fc7538e..90b16cb20 100644
|
||||
--- a/usr/share/rear/lib/layout-functions.sh
|
||||
+++ b/usr/share/rear/lib/layout-functions.sh
|
||||
@@ -834,6 +834,40 @@ is_disk_a_pv() {
|
||||
return 1
|
||||
}
|
||||
|
||||
+# Check whether disk is suitable for being added to layout
|
||||
+# Can be used to skip obviously unsuitable/broken devices
|
||||
+# (missing device node, zero size, device can't be opened).
|
||||
+# Should not be used to skip potential mapping targets before layout restoration
|
||||
+# - an invalid disk may become valid later, for example if it is a DASD that needs
|
||||
+# low-level formatting (see 090_include_dasd_code.sh and 360_generate_dasd_format_code.sh),
|
||||
+# unformatted DASDs show zero size.
|
||||
+# Returns 0 if the device is ok
|
||||
+# Returns nonzero code if it should be skipped, and a text describing the error
|
||||
+# (without the device name) on stdout
|
||||
+# usage example:
|
||||
+# local err
|
||||
+# if ! err=$(is_disk_valid /dev/sda); then
|
||||
+
|
||||
+function is_disk_valid {
|
||||
+ local disk="$1"
|
||||
+ local size
|
||||
+
|
||||
+ if ! test -b "$disk" ; then
|
||||
+ echo "$disk is not a block device"
|
||||
+ return 1
|
||||
+ fi
|
||||
+ # capture stdout in a variable and redirect stderr to stdout - the error message
|
||||
+ # will be our output
|
||||
+ if { size=$(blockdev --getsize64 "$disk") ; } 2>&1 ; then
|
||||
+ if ! test "$size" -gt 0 2>/dev/null ; then
|
||||
+ echo "$disk has invalid size $size"
|
||||
+ return 1
|
||||
+ fi
|
||||
+ else
|
||||
+ return 1
|
||||
+ fi
|
||||
+}
|
||||
+
|
||||
function is_multipath_path {
|
||||
# Return 'false' if there is no device as argument:
|
||||
test "$1" || return 1
|
@ -66,6 +66,10 @@ Patch113: rear-restore-hybrid-bootloader-RHEL-16864.patch
|
||||
# https://github.com/rear/rear/commit/9f859c13f5ba285cd1d5983c9b595975c21888d3
|
||||
Patch114: rear-resolve-libraries-for-symlinks-in-COPY_AS_IS-RHEL-15108.patch
|
||||
|
||||
# Skip invalid disk drives (zero sized, no media) when saving layout
|
||||
# https://github.com/rear/rear/commit/808b15a677191aac62faadd1bc71885484091316
|
||||
Patch115: rear-skip-invalid-drives-RHEL-22863.patch
|
||||
|
||||
######################
|
||||
# downstream patches #
|
||||
######################
|
||||
|
Loading…
Reference in New Issue
Block a user