import CS rear-2.6-29.el9

This commit is contained in:
AlmaLinux RelEng Bot 2026-09-03 07:53:49 -04:00
parent 9caf3f1ade
commit 172b06ae0a
7 changed files with 1643 additions and 1 deletions

View File

@ -0,0 +1,134 @@
From aadf9b40a48f4bbdc9f1ac22165bb2ecfed92207 Mon Sep 17 00:00:00 2001
From: Johannes Meixner <jsmeix@suse.com>
Date: Tue, 4 Mar 2025 13:10:18 +0100
Subject: [PATCH] New umount_mountpoint_retry_lazy function (#3408)
In lib/global-functions.sh added
new umount_mountpoint_retry_lazy function
which is basically a copy of the code in
output/ISO/Linux-i386/700_create_efibootimg.sh
which had been added there via
https://github.com/rear/rear/pull/2909
Call the umount_mountpoint_retry_lazy function
in output/ISO/Linux-i386/700_create_efibootimg.sh
and also in output/USB/Linux-i386/100_create_efiboot.sh
see https://github.com/rear/rear/issues/3397
(cherry picked from commit aadf9b40a48f4bbdc9f1ac22165bb2ecfed92207)
---
usr/share/rear/lib/global-functions.sh | 56 +++++++++++++++++++
.../ISO/Linux-i386/700_create_efibootimg.sh | 46 ++-------------
.../USB/Linux-i386/100_create_efiboot.sh | 11 +++-
3 files changed, 70 insertions(+), 43 deletions(-)
diff --git a/usr/share/rear/lib/global-functions.sh b/usr/share/rear/lib/global-functions.sh
index 95c96e510d..ada71ca49d 100644
--- a/usr/share/rear/lib/global-functions.sh
+++ b/usr/share/rear/lib/global-functions.sh
@@ -863,6 +863,62 @@ function umount_mountpoint_lazy() {
umount $v -f -l "$mountpoint" >&2
}
+# Unmount mountpoint $1 first with sleep and retry then with lazy
+# cf. https://github.com/rear/rear/pull/2909
+# $2 is optional string to show the user what is mounted (fallback value for $2 is $1)
+# for example when $1 is a meaningless directory like /var/tmp/rear.XXXXXXXXXXXXXXX/tmp/somedir
+# then $2 should be a meaningful string to help the user to understand what it actually is
+# cf. https://github.com/rear/rear/wiki/Coding-Style#make-yourself-understood
+function umount_mountpoint_retry_lazy() {
+ local mountpoint="$1"
+ contains_visible_char "$mountpoint" || BugError "umount_mountpoint_retry_lazy() called with empty mountpoint argument '$mountpoint'"
+ test -d "$mountpoint" -o -b "$mountpoint" || Error "umount_mountpoint_retry_lazy mountpoint '$mountpoint' neither directory nor block device"
+ local what_is_mounted="$2"
+ contains_visible_char "$what_is_mounted" || what_is_mounted="$mountpoint"
+ # First attempt to umount:
+ umount $v "$mountpoint" && return 0
+ # First attempt to umount failed:
+ Log "Failed to umount $what_is_mounted (will retry after one second)"
+ # Normal umounting something directly after some I/O command (like 'cp' above)
+ # may sometimes fail with "target is busy" (cf. 'busy' and 'lazy' in "man umount")
+ # so we retry after one second to increase likelihood that it then succeeds
+ # cf. https://github.com/rear/rear/issues/2908#issuecomment-1382000811 ("sleep 1 works fine")
+ # and https://github.com/rear/rear/issues/3397#issuecomment-2656911018 (sleep also worked here)
+ # because normal umount is preferred over more sophisticated attempts
+ # like lazy umount or enforced umount which raise their own specific troubles
+ # and the -M option for fuser which is used below is not available on older
+ # Linux distributions like RHEL6 and SLES11 so 'sleep 1' and retry is best:
+ sleep 1
+ # Retry the same umount as in the first attempt:
+ umount $v "$mountpoint" && return 0
+ # Retry to umount also failed:
+ Log "Again failed to umount $what_is_mounted"
+ # Show in the log file what still uses the mountpoint:
+ Log "$what_is_mounted is still in use by ('kernel mount' is always there)"
+ # The -M option avoids that fuser may show all processes using the '/' filesystem
+ # e.g. for mountpoint $TMP_DIR/somedir ($TMP_DIR = $BUILD_DIR/tmp = /var/tmp/rear.XXXXXXXXXXXXXXX/tmp/)
+ # when $TMP_DIR/somedir got umounted just before fuser starts, see "man fuser":
+ # The mount -m option will match any file within the same device as the specified file,
+ # use the -M option as well if you mean to specify only the mount point.
+ # So when $TMP_DIR/somedir is umounted 'fuser -v -M -m $TMP_DIR/somedir' only shows
+ # "Specified filename /var/tmp/rear.XXXXXXXXXXXXXXX/tmp/somedir is not a mountpoint"
+ # instead of all processes using '/' (or /var/ or /var/tmp/ if one is a mountpoint)
+ # which would be misleading information that may even look scaring and cause false alarm.
+ # Older systems do not support -M but we must use it to avoid misleading information or false alarm.
+ # Since this code path is exceptional and the output is used only for information and only in the log file
+ # we do not care when fuser fails with "M: unknown signal; fuser -l lists signals":
+ fuser -v -M -m "$mountpoint" 1>&2 || Log "Presumably 'fuser' does not support the -M option"
+ DebugPrint "Trying 'umount --lazy $mountpoint' (normal umount failed)"
+ # Do only plain 'umount --lazy' without additional '--force'
+ # because enforced umount raises its own specific troubles
+ # so we cannot use the umount_mountpoint_lazy() function here:
+ umount $v --lazy "$mountpoint" && return 0
+ # Lazy umount also failed:
+ Log "Also failed to umount --lazy $what_is_mounted"
+ # It is the task of the caller what to do (e.g. Error or LogPrintError or ignore with only a Log message):
+ return 1
+}
+
# Change $1 to user input or leave default value on empty input
function change_default
{
diff --git a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
index b889df1bb7..f18f0e2add 100644
--- a/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
+++ b/usr/share/rear/output/ISO/Linux-i386/700_create_efibootimg.sh
@@ -45,7 +45,12 @@ mount $v -o loop -t vfat $TMP_DIR/efiboot.img $TMP_DIR/efi_virt || Error "Failed
# Copy files from staging directory into efiboot.img
cp $v -r $TMP_DIR/mnt/. $TMP_DIR/efi_virt
-umount $v $TMP_DIR/efiboot.img
+local what_is_mounted="EFI virtual image $TMP_DIR/efiboot.img on $TMP_DIR/efi_virt"
+# When umounting the EFI virtual image fails it is no hard error so only inform the user
+# so he can understand why later cleanup_build_area_and_end_program() may show
+# "Could not remove build area" (when lazy umount could not clean up things until then)
+# cf. https://github.com/rear/rear/issues/2908
+umount_mountpoint_retry_lazy "$TMP_DIR/efi_virt" "$what_is_mounted" || LogPrintError "Could not umount $what_is_mounted"
# Move efiboot.img into ISO directory:
mv $v -f $TMP_DIR/efiboot.img $TMP_DIR/isofs/boot/efiboot.img || Error "Failed to move efiboot.img to isofs/boot/efiboot.img"
diff --git a/usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh b/usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh
index 9e5242093c..ac58f11926 100644
--- a/usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh
+++ b/usr/share/rear/output/USB/Linux-i386/100_create_efiboot.sh
@@ -153,12 +153,15 @@ EOF
# Do cleanup of EFI temporary mount point
Log "Doing cleanup of ${EFI_MPT}"
-umount ${EFI_MPT}
-if [[ $? -eq 0 ]]; then
- rmdir ${EFI_MPT}
- LogIfError "Could not remove temporary directory ${EFI_MPT}, please check manually"
+local what_is_mounted="EFI partition '$EFI_PART' on '$EFI_MPT'"
+# When umounting the EFI partition fails it is no hard error so only inform the user
+# so he can understand why later cleanup_build_area_and_end_program() may show
+# "Could not remove build area" (when lazy umount could not clean up things until then)
+# cf. https://github.com/rear/rear/issues/3397
+if umount_mountpoint_retry_lazy "$EFI_MPT" "$what_is_mounted" ; then
+ rmdir "$EFI_MPT" || LogPrintError "Could not remove temporary directory '$EFI_MPT' (you should do it manually)"
else
- Log "Could not umount ${EFI_MPT}, please check manually"
+ LogPrintError "Could not umount $what_is_mounted' (you should do it manually)"
fi
Log "Created EFI configuration for USB"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,222 @@
From b6aa46ed25b83ec4965d98477f34acc7007143c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Fri, 18 Oct 2024 16:21:36 +0200
Subject: [PATCH] Use OS_MASTER_VERSION for major releases (#3331)
Use OS_MASTER_VERSION for major releases, see
https://github.com/rear/rear/pull/3331
Contrary to its name, the OS_MASTER_VERSION variable
was already used for this purpose for some versions, e.g. RHEL 7.
This fixes version comparison on RHEL 10 and newer.
Related: https://github.com/rear/rear/issues/3149#issuecomment-1966068640
Fixes commit: f4932c1cfe13d4a855bec93c1d3aa0b2b9128c6a
"Add OS version mappings for RHEL 8 and RHEL 9"
(cherry picked from commit b6aa46ed25b83ec4965d98477f34acc7007143c2)
---
usr/share/rear/lib/config-functions.sh | 44 +++++++-------------------
1 file changed, 11 insertions(+), 33 deletions(-)
diff --git a/usr/share/rear/lib/config-functions.sh b/usr/share/rear/lib/config-functions.sh
index 1838313e33..ff9d8fe8a4 100644
--- a/usr/share/rear/lib/config-functions.sh
+++ b/usr/share/rear/lib/config-functions.sh
@@ -110,32 +110,12 @@ See '$SHARE_DIR/lib/config-functions.sh' for more details."
case "$( echo $OS_VENDOR_VERSION | tr '[A-Z]' '[a-z]' )" in
(*oracle*|*centos*|*fedora*|*redhat*|*scientific*)
OS_MASTER_VENDOR="Fedora"
- case "$OS_VERSION" in
- (5.*)
- # map all RHEL 5.x and clones to Fedora/5
- # this is safe because FedoraCore 5 never existed
- OS_MASTER_VERSION="5"
- ;;
- (6.*)
- # map all RHEL 6.x and clones to Fedora/6
- OS_MASTER_VERSION="6"
- ;;
- (7.*)
- # map all RHEL 7.x and clones to Fedora/7
- OS_MASTER_VERSION="7"
- ;;
- (*)
- OS_MASTER_VERSION="$OS_VERSION"
- ;;
- esac
;;
(*ubuntu*|*linuxmint*)
OS_MASTER_VENDOR="Debian"
- OS_MASTER_VERSION="$OS_VERSION"
;;
(*archlinux*)
OS_MASTER_VENDOR="Arch"
- OS_MASTER_VERSION="$OS_VERSION"
;;
(*suse*)
# When OS_VENDOR_VERSION contains 'SUSE', set OS_MASTER_VENDOR to 'SUSE'
@@ -152,18 +124,24 @@ See '$SHARE_DIR/lib/config-functions.sh' for more details."
# because then scripts in a .../SUSE_LINUX/... sub-directoriy and conf/SUSE_LINUX.conf
# get sourced twice by the (buggy) SourceStage function in lib/framework-functions.sh
OS_MASTER_VENDOR="SUSE"
- # If OS_VERSION is of the form 12.34.56 OS_MASTER_VERSION is only the first part '12'.
- # Because openSUSE Tumbleweed has rolling releases OS_VERSION is a date of the form YYYYMMDD
- # so that there is no real OS_MASTER_VERSION which is then the the same as OS_VERSION:
- OS_MASTER_VERSION="${OS_VERSION%%.*}"
;;
(*)
# set fallback values to avoid error exit for 'set -eu' because of unbound variables:
OS_MASTER_VENDOR=""
- OS_MASTER_VERSION="$OS_VERSION"
;;
esac
+ # Set master version to the MAJOR release version. ReaR assumes that OS_MASTER_VERSION
+ # is just the major release number extracted from OS_VERSION and not the version of the derived OS.
+ # If OS_VERSION is of the form 12.34.56, OS_MASTER_VERSION is only the first part '12'.
+ #
+ # Because openSUSE Tumbleweed has rolling releases, OS_VERSION is a date of the form YYYYMMDD.
+ # Therefore, there is no real OS_MASTER_VERSION and this variable will be set to the same value
+ # as OS_VERSION.
+ #
+ # TODO: Rename the variable to be less confusing, e.g. to OS_VERSION_MAJOR.
+ OS_MASTER_VERSION="${OS_VERSION%%.*}"
+
# combined stuff for OS_MASTER_*
if [ "$OS_MASTER_VENDOR" ] ; then
OS_MASTER_VENDOR_VERSION="$OS_MASTER_VENDOR/$OS_MASTER_VERSION"
From ba835cd47f6abb97ff08814e24f6eb8fa016c1eb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
Date: Thu, 10 Oct 2024 14:22:18 +0200
Subject: [PATCH] Fix partition naming on RHEL when migrating devices
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
The previous code was appending a "p" to the device name
unconditionally, which ended up having partition names such as 'wwidp0'
instead of 'wwid1', when the device name (e.g. 'wwid') ended with a
letter and not a digit.
The new code applies the proper naming, which is 'wwid1' when device
doesn't end with a digit (e.g. 'wwid'), and 'wwid0000p1' when the device
(e.g. 'wwid0000') ends with a digit.
Code tested in the following cases.
With QEMU SCSI disk ID "0000a":
~~
rear> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part
|-sda2 8:2 0 19G 0 part
`-0QEMU_QEMU_HARDDISK_0000a 253:0 0 20G 0 mpath
|-0QEMU_QEMU_HARDDISK_0000a1 253:1 0 1G 0 part
`-0QEMU_QEMU_HARDDISK_0000a2 253:2 0 19G 0 part
sdb 8:16 0 20G 0 disk
|-sdb1 8:17 0 1G 0 part
|-sdb2 8:18 0 19G 0 part
`-0QEMU_QEMU_HARDDISK_0000a 253:0 0 20G 0 mpath
|-0QEMU_QEMU_HARDDISK_0000a1 253:1 0 1G 0 part
`-0QEMU_QEMU_HARDDISK_0000a2 253:2 0 19G 0 part
sr0 11:0 1 614.7M 0 rom
~~
With QEMU SCSI disk ID "0000":
~~
rear> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part
|-sda2 8:2 0 19G 0 part
`-0QEMU_QEMU_HARDDISK_0000 253:0 0 20G 0 mpath
|-0QEMU_QEMU_HARDDISK_0000p1 253:1 0 1G 0 part
`-0QEMU_QEMU_HARDDISK_0000p2 253:2 0 19G 0 part
sdb 8:16 0 20G 0 disk
|-sdb1 8:17 0 1G 0 part
|-sdb2 8:18 0 19G 0 part
`-0QEMU_QEMU_HARDDISK_0000 253:0 0 20G 0 mpath
|-0QEMU_QEMU_HARDDISK_0000p1 253:1 0 1G 0 part
`-0QEMU_QEMU_HARDDISK_0000p2 253:2 0 19G 0 part
sr0 11:0 1 614.7M 0 rom
~~
With default friendly name ("mpatha"):
~~
rear> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part
|-sda2 8:2 0 19G 0 part
`-mpatha 253:0 0 20G 0 mpath
|-mpatha1 253:1 0 1G 0 part
`-mpatha2 253:2 0 19G 0 part
sdb 8:16 0 20G 0 disk
|-sdb1 8:17 0 1G 0 part
|-sdb2 8:18 0 19G 0 part
`-mpatha 253:0 0 20G 0 mpath
|-mpatha1 253:1 0 1G 0 part
`-mpatha2 253:2 0 19G 0 part
sr0 11:0 1 614.7M 0 rom
~~
With friendly name ending with a digit ("disk0"):
~~
rear> lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part
|-sda2 8:2 0 19G 0 part
`-disk0 253:0 0 20G 0 mpath
|-disk0p1 253:1 0 1G 0 part
`-disk0p2 253:2 0 19G 0 part
sdb 8:16 0 20G 0 disk
|-sdb1 8:17 0 1G 0 part
|-sdb2 8:18 0 19G 0 part
`-disk0 253:0 0 20G 0 mpath
|-disk0p1 253:1 0 1G 0 part
`-disk0p2 253:2 0 19G 0 part
sr0 11:0 1 614.7M 0 rom
~~
Signed-off-by: Renaud Métrich <rmetrich@redhat.com>
(cherry picked from commit ba835cd47f6abb97ff08814e24f6eb8fa016c1eb)
---
usr/share/rear/lib/layout-functions.sh | 22 ++++------------------
1 file changed, 4 insertions(+), 18 deletions(-)
diff --git a/usr/share/rear/lib/layout-functions.sh b/usr/share/rear/lib/layout-functions.sh
index 191c60a438..e4ac1355b8 100644
--- a/usr/share/rear/lib/layout-functions.sh
+++ b/usr/share/rear/lib/layout-functions.sh
@@ -1044,24 +1044,10 @@ function get_part_device_name_format() {
;;
(Fedora)
- if is_false "$user_friendly_names" ; then
- # RHEL 7 and above seems to named partitions on multipathed devices with
- # [mpath device UUID/WWID] + p + [part number] when "user_friendly_names"
- # option is FALSE.
- # For example: /dev/mapper/3600507680c82004cf8000000000000d8p1
- part_name="${device_name}p" # append p between main device and partitions
- else
- # RHEL 7 and above seems to named partitions on multipathed devices with
- # [mpath device name] + [part number] like standard disk when "user_friendly_names"
- # option is used (default).
- # For example: /dev/mapper/mpatha1
- # But the scheme in RHEL 6 need a "p" between [mpath device name] and [part number].
- # For exemple: /dev/mapper/mpathap1
- if (( $OS_MASTER_VERSION < 7 )) ; then
- part_name="${device_name}p" # append p between main device and partitions
- else
- part_name="${device_name}"
- fi
+ # RHEL 7 and above add a "p" after the device name when the device name ends
+ # by a digit, see https://access.redhat.com/solutions/2354631.
+ if (( $OS_MASTER_VERSION < 7 )) || [[ ${device_name: -1} =~ [0-9] ]]; then
+ part_name="${device_name}p"
fi
;;

View File

@ -0,0 +1,57 @@
From e5a84fdeaed8169f0cec0fd8dbbea66aa275d50c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Mon, 31 Jan 2022 16:04:55 +0100
Subject: [PATCH] Include dmsetup and dmeventd unconditionally
Changes usr/share/rear/conf/GNU/Linux.conf
Older releases of os-prober (1.74 and below) use dmsetup as a fallback
solution for mounting when grub-mount is missing.
However, dmsetup was included in the rescue image if and only if LVM,
multipath or encryption were detected. Thus, BIOS machines that do
not use these but still have dmsetup present, would block indefinitely
on the "Installing GRUB2 boot loader..." step.
GRUB2 installation is performed in a chroot after the data have already
been recovered. ReaR would call grub-mkconfig which calls os-prober
which then executes dmsetup. However, it would never receive the expected
response in the form of releasing a System V semaphore by dmsetup executed
by udevd outside the chroot as rescue system would not have dmsetup present.
related https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853927
---
usr/share/rear/conf/GNU/Linux.conf | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/usr/share/rear/conf/GNU/Linux.conf b/usr/share/rear/conf/GNU/Linux.conf
index 6c3c346123..f39df4c83e 100644
--- a/usr/share/rear/conf/GNU/Linux.conf
+++ b/usr/share/rear/conf/GNU/Linux.conf
@@ -164,6 +164,25 @@ sysctl
blockdev
lsblk
clear
+
+# Older releases of os-prober (1.74 and below) use dmsetup as a fallback
+# solution for mounting when grub-mount is missing.
+#
+# However, dmsetup was included in the rescue image if and only if LVM,
+# multipath or encryption were detected. Thus, BIOS machines that do
+# not use these but still have dmsetup present, would block indefinitely
+# on the "Installing GRUB2 boot loader..." step.
+#
+# GRUB2 installation is performed in a chroot after the data have already
+# been recovered. ReaR would call grub-mkconfig which calls os-prober
+# which then executes dmsetup. However, it would never receive the expected
+# response in the form of releasing a System V semaphore by dmsetup executed
+# by udevd outside the chroot as rescue system would not have dmsetup present.
+#
+# see https://github.com/rear/rear/pull/2748
+# related https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=853927
+dmsetup
+dmeventd
)
# the lib* serves to cover both 32bit and 64bit libraries!

View File

@ -0,0 +1,67 @@
From cc5fdf86845923414ff44e6636ee261b6a495897 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Fri, 27 Mar 2026 20:23:34 +0100
Subject: [PATCH] ISO: mark ISO filesystem labels as write protected
The majority of these changes have been made using Claude.
Assisted-by: Cursor with Claude Opus 4.6
(cherry picked from commit cc5fdf86845923414ff44e6636ee261b6a495897)
---
usr/share/rear/conf/default.conf | 5 ++++-
.../480_initialize_write_protect_settings.sh | 19 +++++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 usr/share/rear/prep/ISO/default/480_initialize_write_protect_settings.sh
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index e170b21ea..a8e6990a6 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -717,7 +717,7 @@ AUTOINCREASE_DISK_SIZE_THRESHOLD_PERCENTAGE=10
##
# Write-protection during "rear recover"
-# for OUTPUT=USB and OUTPUT=RAWDISK
+# for OUTPUT=USB, OUTPUT=ISO and OUTPUT=RAWDISK
#
# Designate disks via disk specific IDs or file system labels as write-protected
# to avoid that those disks could get used as target disk during "rear recover"
@@ -755,6 +755,9 @@ WRITE_PROTECTED_IDS=()
# Example: WRITE_PROTECTED_FS_LABEL_PATTERNS+=( "Backup *" )
# For OUTPUT=USB the file system label of the ReaR data partition on the ReaR recovery system disk
# is automatically added to WRITE_PROTECTED_FS_LABEL_PATTERNS during "rear mkrescue/mkbackup".
+# For OUTPUT=ISO the ISO filesystem label (ISO_VOLID, default 'REAR-ISO') and patterns
+# for split ISOs (${ISO_VOLID}_*) are automatically added during "rear mkrescue/mkbackup"
+# so that a device from which the ISO was booted is protected from being overwritten.
WRITE_PROTECTED_FS_LABEL_PATTERNS=()
##
diff --git a/usr/share/rear/prep/ISO/default/480_initialize_write_protect_settings.sh b/usr/share/rear/prep/ISO/default/480_initialize_write_protect_settings.sh
new file mode 100644
index 000000000..7bd1bc600
--- /dev/null
+++ b/usr/share/rear/prep/ISO/default/480_initialize_write_protect_settings.sh
@@ -0,0 +1,19 @@
+# Generated by Cursor with Claude Opus 4.6
+#
+# ISO output may be written to a writable medium (e.g. USB stick) which
+# should be protected against overwriting by "rear recover"
+# cf. https://github.com/rear/rear/issues/1271
+# This code registers the ISO filesystem label as write-protected.
+# CD/DVD media (sr0, sr1, ...) are inherently protected by the removable device
+# check in layout/prepare/default/250_compare_disks.sh and 300_map_disks.sh
+# but ISOs booted from writable media (e.g. USB sticks or hard disks) need
+# explicit write protection, analogous to what OUTPUT=USB does.
+
+# The ISO_VOLID label (default 'REAR-ISO', see default.conf) is added
+# to WRITE_PROTECTED_FS_LABEL_PATTERNS.
+# When the backup is split on multiple ISOs (cf. ISO_MAX_SIZE)
+# the first ISO has the label $ISO_VOLID and subsequent ISOs get
+# the labels ${ISO_VOLID}_01 ${ISO_VOLID}_02 ... respectively
+# so the glob pattern '${ISO_VOLID}_*' is used to match all of them.
+WRITE_PROTECTED_FS_LABEL_PATTERNS+=( "${ISO_VOLID}" "${ISO_VOLID}_*" )
+DebugPrint "ISO filesystem label patterns '${ISO_VOLID}' and '${ISO_VOLID}_*' added to WRITE_PROTECTED_FS_LABEL_PATTERNS"
--
2.55.0

View File

@ -0,0 +1,114 @@
From 626701843a32070080856c960b9e4202102b81d1 Mon Sep 17 00:00:00 2001
From: Johannes Meixner <jsmeix@suse.com>
Date: Fri, 25 Apr 2025 13:27:41 +0200
Subject: [PATCH] EXCLUDE_COMPONENTS in 200_partition_layout.sh (#3455)
In layout/save/GNU/Linux/200_partition_layout.sh
do not Error() exit but only DebugPrint
when extract_partitions() is called for a disk
which is specified in EXCLUDE_COMPONENTS
see https://github.com/rear/rear/pull/3455#issuecomment-2821188937
In default.conf describe how EXCLUDE_COMPONENTS
could be used to exclude unneeded normal disks
and even unneeded problematic disks
when the disk or things on it cannot be recognized properly,
e.g. if 'parted' fails to recognize the partition table
as in https://github.com/rear/rear/issues/3433
and https://github.com/rear/rear/issues/2995
Also describe generically how to exclude a problematic disk
with higher level storage objects on it.
(cherry-picked from commit 626701843a32070080856c960b9e4202102b81d1)
---
usr/share/rear/conf/default.conf | 43 +++++++++++++------
.../save/GNU/Linux/200_partition_layout.sh | 30 +++++++++++--
2 files changed, 56 insertions(+), 17 deletions(-)
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index 8cddbb72a5..7f5a959984 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -3483,22 +3483,25 @@ DIRECTORY_ENTRIES_TO_RECOVER=()
##
# How to exclude something ----- EXCLUDES -------
#
-# You cannot exclude a device (e.g. /dev/sdg) directly. Instead you have to exclude everything
-# ON that device and then the dependency tracker will automatically exclude the device from the
-# recovery (because there won't be any recovery information for that "unnecessary" device).
-#
-# Furthermore, you have to exclude MD devices and LVM2 volume groups separately
+# Normally a whole device (e.g. a disk device /dev/sdX) is not excluded directly
+# (for exceptional cases see EXCLUDE_COMPONENTS below).
+# Instead specific things on a device are excluded.
+# When everything on a device is excluded then via the dependency tracker
+# the whole device gets automatically excluded from the recovery
+# because there is no recovery information left for that device.
+#
+# You have to exclude MD devices and LVM2 volume groups separately
# as there is no automatic detection of these dependencies.
-# Exclude filesystems by specifying their mountpoints. Will be automatically added to the
-# $BACKUP_PROG_EXCLUDE array during backup to prevent the excluded filesystems' data to
-# be backed up
-# examples: /tmp
+# Exclude filesystems by specifying their mountpoints.
+# Will be automatically added to the $BACKUP_PROG_EXCLUDE array during backup
+# to prevent the excluded filesystems' data to be backed up.
+# Examples: /tmp
# /media/bigdisk
EXCLUDE_MOUNTPOINTS=()
# Exclude MD devices
-# examples: /dev/md0
+# Examples: /dev/md0
# /dev/md/0
EXCLUDE_MD=()
@@ -3508,13 +3511,27 @@ EXCLUDE_MD=()
# otherwise "rear recover" would try to recreate the filesystems onto non-existing LVs.
EXCLUDE_VG=()
-# Exclude any component from the recovery image.
+# EXCLUDE_COMPONENTS: Exclude any component from the recovery.
# Some component types need a prefix:
# - filesystems: "fs:/var/cache"
# - physical volumes: "pv:/dev/sda2"
# - swap: "swap:/dev/mapper/system-swap"
# Volume groups look like: "/dev/system".
-# If in doubt about the correct syntax, consult /var/lib/rear/layout/disktodo.conf
+# See /var/lib/rear/layout/disktodo.conf for the correct syntax of a specific component.
+# Because EXCLUDE_COMPONENTS excludes any component from the recovery
+# it can be used in exceptional cases to exclude unwanted whole disks.
+# For example EXCLUDE_COMPONENTS+=( /dev/sdX ) excludes the disk /dev/sdX
+# and via the dependency tracker usually also partitions and filesystems on it
+# provided the diks behaves normally (i.e. the disk and things on it can be recognized properly).
+# To exclude an unneeded problematic disk when the disk or things on it cannot be recognized properly
+# EXCLUDE_COMPONENTS+=( /dev/sdX ) may work to exclude the disk with its partitions and filesystems.
+# To exclude a problematic disk with higher level storage objects on it
+# its matching components may have to be specified separately for example like
+# EXCLUDE_COMPONENTS+=( /dev/sdX fs:/mountpoint pv:/dev/sdXN ) or similar as needed.
+# Verify that all what belongs to /dev/sdX is marked as 'done' in /var/lib/rear/layout/disktodo.conf
+# and that all what belongs to /dev/sdX is commented out in /var/lib/rear/layout/disklayout.conf
+# to ensure there is no recovery information left as 'todo' or not commented out
+# for a disk which should be excluded from the recovery.
EXCLUDE_COMPONENTS=()
####
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 ec67541e6d..f6b7fdd914 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
@@ -122,7 +122,11 @@ extract_partitions() {
# Ensure $disk_label is valid to determine the partition name/type in the next step at 'declare type'
# cf. https://github.com/rear/rear/issues/2801#issuecomment-1122015129
if ! [[ "$disk_label" = "msdos" || "$disk_label" = "gpt" || "$disk_label" = "gpt_sync_mbr" || "$disk_label" = "dasd" ]] ; then
- Error "Unsupported partition table '$disk_label' (must be one of 'msdos' 'gpt' 'gpt_sync_mbr' 'dasd')"
+ if IsInArray "$device" "${EXCLUDE_COMPONENTS[@]}" ; then
+ DebugPrint "Unsupported partition table '$disk_label' on $device (must be one of 'msdos' 'gpt' 'gpt_sync_mbr' 'dasd')"
+ else
+ Error "Unsupported partition table '$disk_label' on $device (must be one of 'msdos' 'gpt' 'gpt_sync_mbr' 'dasd')"
+ fi
fi

View File

@ -3,7 +3,7 @@
Name: rear
Version: 2.6
Release: 28%{?dist}
Release: 29%{?dist}
Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool
URL: http://relax-and-recover.org/
License: GPLv3
@ -149,6 +149,35 @@ Patch135: rear-skip-unsupported-partition-tables-RHEL-78583.patch
# https://github.com/rear/rear/commit/a5edba7551884e9201a21fc1ea33de7ca7e6cb07
Patch136: rear-do-not-use-backup-disk-for-recovery-RHEL-111612.patch
# fix EXCLUDE_COMPONENTS being ignored for partition tables unsupported by ReaR
# https://github.com/rear/rear/commit/626701843a32070080856c960b9e4202102b81d1
Patch137: rear-respect-EXCLUDE_COMPONENTS-in-extract_partitions-RHEL-235767.patch
# mark ISO filesystem labels as write protected
# https://github.com/rear/rear/commit/014a7653b56f9ab8471af591ddf3698d08f0f290
Patch138: rear-mark-ISO-labels-write-protected-RHEL-143987.patch
# EL10-only
# Patch139:
# add REAR_INITRD_OVERLAY to split initramfs into core + SquashFS overlay
# https://github.com/rear/rear/commit/e95afd1c8580454451fb791991b30839be3141b7
Patch140: rear-add-squashfs-overlay-split-support-RHEL-192030.patch
# fix unsuccessful unmount of efiboot.img resulting in a corrupted ESP
# https://github.com/rear/rear/commit/aadf9b40a48f4bbdc9f1ac22165bb2ecfed92207
Patch141: rear-add-lazy-unmounting-with-retry-RHEL-146134.patch
# fix incorrect partition naming when migrating devices
# - also fix OS_MASTER_VERSION for RHEL 8+
# https://github.com/rear/rear/commit/b6aa46ed25b83ec4965d98477f34acc7007143c2
# https://github.com/rear/rear/commit/94b51e67640d22a4b63a06244d28060a6e130b8f
Patch142: rear-fix-partition-naming-when-migrating-devices-RHEL-137301.patch
# include dmsetup and dmeventd unconditionally
# https://github.com/rear/rear/commit/39c79b34ba884e4f674d17abb5c3e5423820dbe1
Patch143: rear-include-dmsetup-unconditionally-RHEL-242578.patch
######################
# downstream patches #
######################
@ -211,6 +240,8 @@ Requires: ethtool
Requires: gzip
Requires: iputils
Requires: parted
# For REAR_INITRD_OVERLAY
Requires: squashfs-tools
Requires: tar
Requires: openssl
Requires: gawk
@ -294,6 +325,15 @@ install -m 0644 %{SOURCE3} %{buildroot}%{_docdir}/%{name}/
#-- CHANGELOG -----------------------------------------------------------------#
%changelog
* Thu Aug 13 2026 Lukáš Zaoral <lzaoral@redhat.com> - 2.6-29
- fix EXCLUDE_COMPONENTS being ignored for partition tables unsupported by ReaR
- mark ISO filesystem labels as write protected
- add REAR_INITRD_OVERLAY to split initramfs into core + SquashFS overlay
- fix unsuccessful unmount of efiboot.img resulting in a corrupted ESP
- fix incorrect partition naming when migrating devices
- also fix OS_MASTER_VERSION for RHEL 8+
- include dmsetup and dmeventd unconditionally
* Thu Jan 29 2026 Lukáš Zaoral <lzaoral@redhat.com> - 2.6-28
- use git to apply downstream patches
- copy an sshd helper to the rescue ramdisk (RHEL-146037)