import CS rear-2.6-20.el9_3

This commit is contained in:
eabdullin 2024-01-25 10:18:21 +00:00
parent 3b5eeb2f23
commit 38766d1ba3
10 changed files with 905 additions and 1 deletions

View File

@ -0,0 +1,440 @@
diff --git a/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh b/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh
new file mode 100644
index 00000000..f7423e0a
--- /dev/null
+++ b/usr/share/rear/rescue/NBU/default/460_prepare_netbackup_systemd.sh
@@ -0,0 +1,41 @@
+# 460_prepare_netbackup_systemd.sh
+# prepare systemd units for NBU (only if NBU version >=7.x)
+
+# set in 450_prepare_netbackup.sh
+[[ $NBU_version -lt 7 ]] && return # NBU is using xinetd when version <7.x
+
+# Skip if systemd is not used.
+has_binary systemctl || return 0
+
+# Local functions that are 'unset' at the end of this script:
+
+function get_unit_path () {
+ systemctl show -P FragmentPath $1
+}
+
+function get_unit_dropin_paths () {
+ systemctl show -P DropInPaths $1
+}
+
+local unit_file_path
+local i
+local unit
+
+for unit in vxpbx_exchanged.service netbackup.service ; do
+ unit_file_path="$( get_unit_path $unit )"
+ if [ -n "$unit_file_path" ]; then
+ cp $v "$unit_file_path" $ROOTFS_DIR/etc/systemd/system
+ ln -s ../$unit $ROOTFS_DIR/etc/systemd/system/default.target.wants || Error "Failed to enable Netbackup service $unit in the rescue system"
+ Log "Enabled Netbackup service $unit in the rescue system"
+ for i in $( get_unit_dropin_paths $unit ) ; do
+ mkdir -p $ROOTFS_DIR/etc/systemd/system/$unit.d
+ cp $v $i $ROOTFS_DIR/etc/systemd/system/$unit.d
+ done
+ fi
+done
+
+# Local functions must be 'unset' because bash does not support 'local function ...'
+# cf. https://unix.stackexchange.com/questions/104755/how-can-i-create-a-local-function-in-my-bashrc
+unset -f get_unit_path
+unset -f get_unit_dropin_paths
+unset -f unit_is_enabled
diff --git a/usr/share/rear/skel/default/etc/scripts/run-automatic-rear b/usr/share/rear/skel/default/etc/scripts/run-automatic-rear
new file mode 100755
index 00000000..6edc657a
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/scripts/run-automatic-rear
@@ -0,0 +1,82 @@
+#!/bin/bash
+
+source /etc/scripts/system-setup-functions.sh
+
+# In debug mode run the automated 'rear recover' also with debug options.
+# Because the kernel command line option 'debug' means 'set -x' for the system setup scripts
+# it also means '-D' (i.e. 'set -x') for the automated 'rear recover' run:
+if rear_debug ; then
+ rear_debug_options='-D'
+else
+ rear_debug_options=''
+fi
+
+# Launch rear recover automatically:
+if automatic_recovery ; then
+ choices=( "View Relax-and-Recover log file(s)"
+ "Go to Relax-and-Recover shell"
+ )
+ echo -e "\nLaunching 'rear recover' automatically\n"
+ if rear $rear_debug_options recover ; then
+ echo -e "\n'rear recover' finished successfully\n"
+ choices+=( "Reboot" )
+ else
+ echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
+ fi
+ PS3="Select what to do "
+ select choice in "${choices[@]}" ; do
+ case "$REPLY" in
+ (1)
+ # Do not assume the ReaR log file is named rear-$HOSTNAME.log
+ # the user can have specified any name as LOGFILE:
+ less /var/log/rear/*
+ ;;
+ (2)
+ echo "" > /etc/issue
+ echo "" > /etc/motd
+ break
+ ;;
+ (3)
+ reboot
+ ;;
+ esac
+ for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
+ echo "$i) ${choices[$i-1]}"
+ done
+ done 2>&1
+fi
+
+# Launch rear recover automatically in unattended mode
+# i.e. with automated reboot after successful 'rear recover':
+if unattended_recovery ; then
+ choices=( "View Relax-and-Recover log file(s)"
+ "Go to Relax-and-Recover shell"
+ )
+ echo -e "\nLaunching 'rear recover' automatically in unattended mode\n"
+ if rear $rear_debug_options recover ; then
+ echo -e "\n'rear recover' finished successfully\n"
+ echo -e "\nRebooting in 30 seconds (Ctrl-C to interrupt)\n"
+ sleep 30
+ reboot
+ else
+ echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
+ PS3="Select what to do "
+ select choice in "${choices[@]}" ; do
+ case "$REPLY" in
+ (1)
+ # Do not assume the ReaR log file is named rear-$HOSTNAME.log
+ # the user can have specified any name as LOGFILE:
+ less /var/log/rear/*
+ ;;
+ (2)
+ echo "" > /etc/issue
+ echo "" > /etc/motd
+ break
+ ;;
+ esac
+ for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
+ echo "$i) ${choices[$i-1]}"
+ done
+ done 2>&1
+ fi
+fi
diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup b/usr/share/rear/skel/default/etc/scripts/system-setup
index 1dc7f1e8..17487ac7 100755
--- a/usr/share/rear/skel/default/etc/scripts/system-setup
+++ b/usr/share/rear/skel/default/etc/scripts/system-setup
@@ -9,36 +9,7 @@
# (e.g. "ls foo*bar" becomes plain "ls" without "foo*bar: No such file or directory" error).
shopt -s nullglob
-# Use an artificial array to get the kernel command line parameters as array elements
-kernel_command_line=( $( cat /proc/cmdline ) )
-
-function rear_debug() {
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "debug" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
-
-function unattended_recovery() {
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "unattended" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
-
-function automatic_recovery() {
- # The unattended recovery mode implies automatic recovery (see the implementations below)
- # so that in unattended mode the automatic recovery code below must not be run
- # otherwise first the automatic recovery code and then the unattended recovery code
- # get run automatically one after the other where the unattended recovery fails
- # because for two subsequent 'rear recover' the second one fails:
- unattended_recovery && return 1
- for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
- test "auto_recover" = "$kernel_command_line_parameter" && return 0
- test "automatic" = "$kernel_command_line_parameter" && return 0
- done
- return 1
-}
+source /etc/scripts/system-setup-functions.sh
# The 'sleep 1' is used as workaround to avoid whatever inexplicable actual reason
# that at least on SLES12 some initial output lines of this script would get lost
@@ -135,84 +106,3 @@ echo -e "\nRelax-and-Recover rescue system is ready\n"
# Wait two seconds so that the user can read the 'Relax-and-Recover rescue system is ready' message
# on his screen before the screen gets cleared and replaced by the login screen:
sleep 2
-
-# In debug mode run the automated 'rear recover' also with debug options.
-# Because the kernel command line option 'debug' means 'set -x' for the system setup scripts
-# it also means '-D' (i.e. 'set -x') for the automated 'rear recover' run:
-if rear_debug ; then
- rear_debug_options='-D'
-else
- rear_debug_options=''
-fi
-
-# Launch rear recover automatically:
-if automatic_recovery ; then
- choices=( "View Relax-and-Recover log file(s)"
- "Go to Relax-and-Recover shell"
- )
- echo -e "\nLaunching 'rear recover' automatically\n"
- # The recover workflow is always verbose (see usr/sbin/rear):
- if rear $rear_debug_options recover ; then
- echo -e "\n'rear recover' finished successfully\n"
- choices+=( "Reboot" )
- else
- echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
- fi
- PS3="Select what to do "
- select choice in "${choices[@]}" ; do
- case "$REPLY" in
- (1)
- # Do not assume the ReaR log file is named rear-$HOSTNAME.log
- # the user can have specified any name as LOGFILE:
- less /var/log/rear/*
- ;;
- (2)
- echo "" > /etc/issue
- echo "" > /etc/motd
- break
- ;;
- (3)
- reboot
- ;;
- esac
- for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
- echo "$i) ${choices[$i-1]}"
- done
- done 2>&1
-fi
-
-# Launch rear recover automatically in unattended mode
-# i.e. with automated reboot after successful 'rear recover':
-if unattended_recovery ; then
- choices=( "View Relax-and-Recover log file(s)"
- "Go to Relax-and-Recover shell"
- )
- echo -e "\nLaunching 'rear recover' automatically in unattended mode\n"
- # The recover workflow is always verbose (see usr/sbin/rear):
- if rear $rear_debug_options recover ; then
- echo -e "\n'rear recover' finished successfully\n"
- echo -e "\nRebooting in 30 seconds (Ctrl-C to interrupt)\n"
- sleep 30
- reboot
- else
- echo -e "\n'rear recover' failed, check the Relax-and-Recover log file(s)\n"
- PS3="Select what to do "
- select choice in "${choices[@]}" ; do
- case "$REPLY" in
- (1)
- # Do not assume the ReaR log file is named rear-$HOSTNAME.log
- # the user can have specified any name as LOGFILE:
- less /var/log/rear/*
- ;;
- (2)
- echo "" > /etc/issue
- echo "" > /etc/motd
- break
- ;;
- esac
- for (( i=1 ; i <= ${#choices[@]} ; i++ )) ; do
- echo "$i) ${choices[$i-1]}"
- done
- done 2>&1
- fi
-fi
diff --git a/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh b/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh
new file mode 100644
index 00000000..c320cf88
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/scripts/system-setup-functions.sh
@@ -0,0 +1,30 @@
+# Use an artificial array to get the kernel command line parameters as array elements
+kernel_command_line=( $( cat /proc/cmdline ) )
+
+function rear_debug() {
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "debug" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
+
+function unattended_recovery() {
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "unattended" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
+
+function automatic_recovery() {
+ # The unattended recovery mode implies automatic recovery (see the implementations below)
+ # so that in unattended mode the automatic recovery code below must not be run
+ # otherwise first the automatic recovery code and then the unattended recovery code
+ # get run automatically one after the other where the unattended recovery fails
+ # because for two subsequent 'rear recover' the second one fails:
+ unattended_recovery && return 1
+ for kernel_command_line_parameter in "${kernel_command_line[@]}" ; do
+ test "auto_recover" = "$kernel_command_line_parameter" && return 0
+ test "automatic" = "$kernel_command_line_parameter" && return 0
+ done
+ return 1
+}
diff --git a/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore b/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore
new file mode 100644
index 00000000..d6b7ef32
--- /dev/null
+++ b/usr/share/rear/skel/default/etc/systemd/system/default.target.wants/.gitignore
@@ -0,0 +1,2 @@
+*
+!.gitignore
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service b/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service
new file mode 100644
index 00000000..ee3187a8
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/automatic-rear.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Run Relax-and-Recover recovery automatically if requested
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Type=oneshot
+ExecStart=/etc/scripts/run-automatic-rear
+StandardInput=tty
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service b/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
index bf858ca8..abafd8b5 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/getty@.service
@@ -6,6 +6,8 @@ Description=Getty on %I
Documentation=man:agetty(8)
After=systemd-user-sessions.service plymouth-quit-wait.service
After=sysinit.service
+# Automatic ReaR uses the system console
+After=automatic-rear.service
# If additional gettys are spawned during boot then we should make
# sure that this is synchronized before getty.target, even though
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
index c5ea1cca..a88e219f 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target
@@ -4,7 +4,7 @@
[Unit]
Description=Multi-User
-Requires=sysinit.target
+Requires=sysinit.target basic.target
AllowIsolate=yes
[Install]
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service
new file mode 120000
index 00000000..3e8a4161
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/multi-user.target.wants/automatic-rear.service
@@ -0,0 +1 @@
+../automatic-rear.service
\ No newline at end of file
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target
new file mode 100644
index 00000000..c3edfeb4
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+#
+# This file is part of systemd.
+#
+# systemd is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation; either version 2.1 of the License, or
+# (at your option) any later version.
+
+[Unit]
+Description=Network is Online
+Documentation=man:systemd.special(7)
+Documentation=https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget
+After=network.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service
new file mode 120000
index 00000000..ed660a10
--- /dev/null
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/network-online.target.wants/sysinit.service
@@ -0,0 +1 @@
+../sysinit.service
\ No newline at end of file
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service b/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
index ac171e0f..18fa17b5 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/rsyslog.service
@@ -1,6 +1,5 @@
[Unit]
Description=Relax-and-Recover run-syslog script
-DefaultDependencies=no
[Service]
Type=simple
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
index ee22fafc..b34b2fe8 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.service
@@ -1,9 +1,14 @@
[Unit]
Description=Initialize Rescue System
-After=systemd-udevd.service
+DefaultDependencies=no
+After=systemd-udevd.service rear-boot-helper.service
+Before=network-online.target
[Service]
Type=oneshot
ExecStart=/etc/scripts/system-setup
StandardInput=tty
RemainAfterExit=yes
+
+[Install]
+WantedBy=network-online.target
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
index 4187ef67..2a16369b 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/sysinit.target
@@ -4,3 +4,5 @@
[Unit]
Description=System Initialization
+Wants=sysinit.service rear-boot-helper.service
+After=sysinit.service rear-boot-helper.service
diff --git a/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket b/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
index 9a0064c0..3fb02344 100644
--- a/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
+++ b/usr/share/rear/skel/default/usr/lib/systemd/system/syslog.socket
@@ -4,7 +4,6 @@
[Unit]
Description=Syslog Socket
-DefaultDependencies=no
Before=sockets.target syslog.target
[Socket]

View File

@ -0,0 +1,32 @@
commit 4f03a10d4866efc9b6920a3878e6397d170742f9
Author: Johannes Meixner <jsmeix@suse.com>
Date: Thu Jul 20 15:11:52 2023 +0200
Merge pull request #3027 from rmetrich/shrinking_file
In build/GNU/Linux/100_copy_as_is.sh
ensure to really get all COPY_AS_IS files copied by using
'tar ... -i' when extracting to avoid a false regular exit of 'tar'
in particular when padding zeroes get added when a file being read shrinks
because for 'tar' (without '-i') two consecutive 512-blocks of zeroes mean EOF,
cf. https://github.com/rear/rear/pull/3027
diff --git a/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh b/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
index ec55f331..0e402b01 100644
--- a/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
+++ b/usr/share/rear/build/GNU/Linux/100_copy_as_is.sh
@@ -92,9 +92,13 @@ done >$copy_as_is_exclude_file
# COPY_AS_IS+=( /path/to/directory/* )
# which are used in our scripts and by users in their etc/rear/local.conf
# cf. https://github.com/rear/rear/pull/2405#issuecomment-633512932
+# Using '-i' when extracting is necessary to avoid a false regular exit of 'tar'
+# in particular when padding zeroes get added when a file being read shrinks
+# because for 'tar' (without '-i') two consecutive 512-blocks of zeroes mean EOF,
+# cf. https://github.com/rear/rear/pull/3027
# FIXME: The following code fails if file names contain characters from IFS (e.g. blanks),
# cf. https://github.com/rear/rear/issues/1372
-if ! tar -v -X $copy_as_is_exclude_file -P -C / -c ${COPY_AS_IS[*]} 2>$copy_as_is_filelist_file | tar $v -C $ROOTFS_DIR/ -x 1>/dev/null ; then
+if ! tar -v -X $copy_as_is_exclude_file -P -C / -c ${COPY_AS_IS[*]} 2>$copy_as_is_filelist_file | tar $v -C $ROOTFS_DIR/ -x -i 1>/dev/null ; then
Error "Failed to copy files and directories in COPY_AS_IS minus COPY_AS_IS_EXCLUDE"
fi
Log "Finished copying files and directories in COPY_AS_IS minus COPY_AS_IS_EXCLUDE"

View File

@ -0,0 +1,25 @@
commit 2aa7b47354bdf5863071c8b479d29c99aad05ecb
Author: Johannes Meixner <jsmeix@suse.com>
Date: Fri Jul 24 13:02:45 2020 +0200
Update 240_reassign_luks_keyfiles.sh
Use ReaR specific TMP_DIR (not TMPDIR or hardcoded /tmp)
diff --git a/usr/share/rear/finalize/GNU/Linux/240_reassign_luks_keyfiles.sh b/usr/share/rear/finalize/GNU/Linux/240_reassign_luks_keyfiles.sh
index d989c3fb..358f3950 100644
--- a/usr/share/rear/finalize/GNU/Linux/240_reassign_luks_keyfiles.sh
+++ b/usr/share/rear/finalize/GNU/Linux/240_reassign_luks_keyfiles.sh
@@ -24,9 +24,9 @@ awk '
while read target_name source_device original_keyfile; do
Log "Re-assigning keyfile $original_keyfile to LUKS device $target_name ($source_device)"
- # The scheme for generating a temporary keyfile path must be the same here and in the 'layout/prepare' stage.
- temp_keyfile="${TMPDIR:-/tmp}/LUKS-keyfile-$target_name"
- [ -f "$temp_keyfile" ] || BugError "temporary keyfile $temp_keyfile not found"
+ # The scheme for generating a temporary keyfile path must be the same here and in the 'layout/prepare' stage:
+ temp_keyfile="$TMP_DIR/LUKS-keyfile-$target_name"
+ test -f "$temp_keyfile" || BugError "temporary LUKS keyfile $temp_keyfile not found"
target_keyfile="$TARGET_FS_ROOT/$original_keyfile"

View File

@ -0,0 +1,46 @@
commit ad720ad788be1d653da31be36fca5e886e314ddb
Author: Pavel Cahyna <pcahyna@redhat.com>
Date: Thu Aug 24 11:41:25 2023 +0200
Remove the lvmdevices file at the end of recovery
The file /etc/lvm/devices/system.devices restricts LVM to disks with
given (hardware) IDs (serial numbers, WWNs). See lvmdevices(8).
Unfortunately, when restoring to different disks than in the original
system, it will mean that LVM is broken in the recovered system (it
won't find any disks). Therefore it is safer to remove the file to
force the old behavior where LVM scans all disks. This used to be the
LVM default (use_devicesfile=0).
diff --git a/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh
new file mode 100644
index 00000000..a51e6bca
--- /dev/null
+++ b/usr/share/rear/finalize/GNU/Linux/230_remove_lvmdevices.sh
@@ -0,0 +1,25 @@
+# Adapted from 260_rename_diskbyid.sh
+
+# Remove /etc/lvm/devices/system.devices
+# The file restricts LVM to disks with given (hardware) IDs (serial
+# numbers, WWNs). See lvmdevices(8).
+# Unfortunately, when restoring to different disks than in the original
+# system, it will mean that LVM is broken in the recovered system (it
+# won't find any disks). Therefore it is safer to remove the file to
+# force the old behavior where LVM scans all disks. This used to be the
+# LVM default (use_devicesfile=0).
+
+# There may be other files under /etc/lvm/devices, but they are not used
+# by default
+
+local file=/etc/lvm/devices/system.devices
+local realfile
+
+realfile="$TARGET_FS_ROOT/$file"
+# OK if file not found
+test -f "$realfile" || return 0
+mv $v "$realfile" "${realfile}.rearbak"
+LogPrint "Renamed LVM devices file $realfile to ${realfile}.rearbak
+to prevent LVM problems in the recovered system, verify that the file
+is correct after booting the recovered system and move it back, or
+regenerate it using vgimportdevices."

View File

@ -0,0 +1,102 @@
From e7b84271536782fbc8673ef4573e155e1dfa850e Mon Sep 17 00:00:00 2001
From: pcahyna <pcahyna@users.noreply.github.com>
Date: Wed, 1 Nov 2023 12:53:33 +0100
Subject: [PATCH] Merge pull request #3061 from
pcahyna/save-lvm-poolmetadatasize
Save LVM pool metadata volume size in disk layout
---
.../layout/save/GNU/Linux/220_lvm_layout.sh | 39 ++++++++++++-------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh b/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh
index f21845df9..42f0e4126 100644
--- a/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh
+++ b/usr/share/rear/layout/save/GNU/Linux/220_lvm_layout.sh
@@ -18,7 +18,7 @@ local already_processed_lvs=()
local lv_layout_supported lvs_fields
local origin lv vg
local layout modules
-local thinpool chunksize stripes stripesize segmentsize
+local thinpool chunksize stripes stripesize segmentsize poolmetadatasize
local kval infokval
local lvs_exit_code
@@ -130,7 +130,7 @@ local lvs_exit_code
echo "# Skipping PV $pdev that is not part of a valid VG (VG '$vgrp' empty or more than one word):"
contains_visible_char "$vgrp" || vgrp='<missing_VG>'
echo "# lvmdev /dev/$vgrp $pdev $uuid $size"
- # Continue with the next line in the output of "lvm pvdisplay -c"
+ # Continue with the next line in the output of "lvm pvdisplay -C"
continue
fi
# With the above example the output is:
@@ -138,10 +138,10 @@ local lvs_exit_code
echo "lvmdev /dev/$vgrp $pdev $uuid $size"
done
- # Check the exit code of "lvm pvdisplay -c"
- # in the "lvm pvdisplay -c | while read line ; do ... done" pipe:
+ # Check the exit code of "lvm pvdisplay -C"
+ # in the "lvm pvdisplay -C ... | while read line ; do ... done" pipe:
pvdisplay_exit_code=${PIPESTATUS[0]}
- test $pvdisplay_exit_code -eq 0 || Error "LVM command 'lvm pvdisplay -c' failed with exit code $pvdisplay_exit_code"
+ test $pvdisplay_exit_code -eq 0 || Error "LVM command 'lvm pvdisplay -C ... -o pv_name,vg_name,pv_size,pv_uuid' failed with exit code $pvdisplay_exit_code"
# Get the volume group configuration:
# Format: lvmgrp <volume_group> <extentsize> [<size(extents)>] [<size(bytes)>]
@@ -200,17 +200,17 @@ local lvs_exit_code
# Specify the fields for the lvs command depending on whether or not the 'lv_layout' field is supported:
if is_true $lv_layout_supported ; then
- lvs_fields="origin,lv_name,vg_name,lv_size,lv_layout,pool_lv,chunk_size,stripes,stripe_size,seg_size"
+ lvs_fields="origin,lv_name,vg_name,lv_size,lv_layout,pool_lv,chunk_size,stripes,stripe_size,seg_size,lv_metadata_size"
else
# Use the 'modules' field as fallback replacement when the 'lv_layout' field is not supported:
- lvs_fields="origin,lv_name,vg_name,lv_size,modules,pool_lv,chunk_size,stripes,stripe_size,seg_size"
+ lvs_fields="origin,lv_name,vg_name,lv_size,modules,pool_lv,chunk_size,stripes,stripe_size,seg_size,lv_metadata_size"
fi
# Example output of "lvs --separator=':' --noheadings --units b --nosuffix -o $lvs_fields"
- # with lvs_fields="origin,lv_name,vg_name,lv_size,lv_layout,pool_lv,chunk_size,stripes,stripe_size,seg_size"
+ # with lvs_fields="origin,lv_name,vg_name,lv_size,lv_layout,pool_lv,chunk_size,stripes,stripe_size,seg_size,lv_metadata_size"
# i.e. when the 'lv_layout' field is supported:
- # :root:system:19927138304:linear::0:1:0:19927138304
- # :swap:system:1535115264:linear::0:1:0:1535115264
+ # :root:system:19927138304:linear::0:1:0:19927138304:
+ # :swap:system:1535115264:linear::0:1:0:1535115264:
# There are two leading blanks in the output (at least on SLES12-SP4 with LVM 2.02.180).
lvm lvs --separator=':' --noheadings --units b --nosuffix -o $lvs_fields | while read line ; do
@@ -261,14 +261,23 @@ local lvs_exit_code
# With the above example segmentsize=19927138304 and segmentsize=1535115264
segmentsize="$( echo "$line" | awk -F ':' '{ print $10 }' )"
- # TODO: Explain what that code is meant to do.
- # In particular a more explanatory variable name than 'kval' might help.
- # In 110_include_lvm_code.sh there is a comment what 'kval' means there
- # # kval: "key:value" pairs, separated by spaces
- # so probably 'kval' means the same here, but what is 'infokval'?
+ # With the above example poolmetadatasize=""
+ poolmetadatasize="$( echo "$line" | awk -F ':' '{ print $11 }' )"
+
+ # kval is a string of space-separated key:value pairs. Key names are chosen to represent
+ # long options to lvcreate, and value will be the parameter for each long option.
+ # e.g. "chunksize:${chunksize}b" will eventually become a --chunksize=${chunksize}b
+ # argument to lvcreate.
+ # This way 110_include_lvm_code.sh which constructs the arguments to lvcreate
+ # can be kept generic and does not need to be updated every time an argument is added,
+ # as long as the argument can follow this generic scheme.
+ # infokval are key:value pairs that are not used when restoring the layout
+ # and are kept in disklayout.conf only as comments for information
+ # (because the setting is not easy or desirable to preserve).
kval=""
infokval=""
[ -z "$thinpool" ] || kval="${kval:+$kval }thinpool:$thinpool"
+ [ -z "$poolmetadatasize" ] || kval="${kval:+$kval }poolmetadatasize:${poolmetadatasize}b"
[ $chunksize -eq 0 ] || kval="${kval:+$kval }chunksize:${chunksize}b"
[ $stripesize -eq 0 ] || kval="${kval:+$kval }stripesize:${stripesize}b"
[ $segmentsize -eq $size ] || infokval="${infokval:+$infokval }segmentsize:${segmentsize}b"
--
2.43.0

View File

@ -0,0 +1,85 @@
diff --git a/usr/share/rear/layout/prepare/GNU/Linux/133_include_mount_filesystem_code.sh b/usr/share/rear/layout/prepare/GNU/Linux/133_include_mount_filesystem_code.sh
index d57077791..87ab5d691 100644
--- a/usr/share/rear/layout/prepare/GNU/Linux/133_include_mount_filesystem_code.sh
+++ b/usr/share/rear/layout/prepare/GNU/Linux/133_include_mount_filesystem_code.sh
@@ -29,6 +29,7 @@ mount_fs() {
case $name in
(options)
# Do not mount nodev, as chrooting later on would fail:
+ # FIXME: naive approach, will replace any "nodev" inside longer options/values
value=${value//nodev/dev}
# btrfs mount options like subvolid=259 or subvol=/@/.snapshots/1/snapshot
# from the old system cannot work here for recovery because btrfs subvolumes
@@ -147,6 +148,27 @@ mount_fs() {
echo "mount $mountopts,remount,user_xattr $device $TARGET_FS_ROOT$mountpoint"
) >> "$LAYOUT_CODE"
;;
+ (xfs)
+ # remove logbsize=... mount option. It is a purely performance/memory usage optimization option,
+ # which can lead to mount failures, because it must be an integer multiple of the log stripe unit
+ # and the log stripe unit can be different in the recreated filesystem from the original filesystem
+ # (for example when using MKFS_XFS_OPTIONS, or in some exotic situations involving an old filesystem,
+ # see GitHub issue #2777 ).
+ # If logbsize is not an integer multiple of the log stripe unit, mount fails with the warning
+ # "XFS (...): logbuf size must be greater than or equal to log stripe size"
+ # in the kernel log
+ # (and a confusing error message
+ # "mount: ...: wrong fs type, bad option, bad superblock on ..., missing codepage or helper program, or other error."
+ # from the mount command), causing the layout restoration in the recovery process to fail.
+ # Wrong sunit/swidth can cause mount to fail as well, with this in the kernel log:
+ # "kernel: XFS (...): alignment check failed: sunit/swidth vs. agsize",
+ # so remove the sunit=.../swidth=... mount options as well.
+ mountopts="$( remove_mount_options_values "$mountopts" logbsize sunit swidth )"
+ (
+ echo "mkdir -p $TARGET_FS_ROOT$mountpoint"
+ echo "mount $mountopts $device $TARGET_FS_ROOT$mountpoint"
+ ) >> "$LAYOUT_CODE"
+ ;;
(*)
(
echo "mkdir -p $TARGET_FS_ROOT$mountpoint"
diff --git a/usr/share/rear/lib/filesystems-functions.sh b/usr/share/rear/lib/filesystems-functions.sh
index afdd3f24c..658d757f4 100644
--- a/usr/share/rear/lib/filesystems-functions.sh
+++ b/usr/share/rear/lib/filesystems-functions.sh
@@ -239,3 +239,40 @@ function xfs_parse
# Output xfs options for further use
echo "$xfs_opts"
}
+
+
+# $1 is a mount command argument (string containing comma-separated
+# mount options). The remaining arguments to the function ($2 ... )
+# specify the mount options to remove from $1, together with a trailing "="
+# and any value that follows each option.
+# For example, the call
+# "remove_mount_options_values nodev,uid=1,rw,gid=1 uid gid"
+# returns "nodev,rw".
+# There is no support for removing a mount option without a value and "=",
+# so "remove_mount_options_values nodev,uid=1,rw,gid=1 rw" will not work.
+# The function will return the modified string on stdout.
+
+function remove_mount_options_values () {
+ local str="$1"
+
+ shift
+ # First add a comma at the end so that it is easier to remove a mount option at the end:
+ str="${str/%/,}"
+ for i in "$@" ; do
+ # FIXME this also removes trailing strings at the end of longer words
+ # For example if one wants to remove any id=... option,
+ # the function will also replace "uid=1" by "u" by removing
+ # the trailing "id=1", which is not intended.
+ # Not easy to fix because $str can contain prefixes which are not
+ # mount options but arguments to the mount command itself
+ # (in particluar, "-o ").
+ # FIXME this simple approach would fail in case of mount options
+ # containing commas, for example the "context" option values,
+ # see mount(8)
+
+ # the extglob shell option is enabled in rear
+ str="${str//$i=*([^,]),/}"
+ done
+ # Remove all commas at the end:
+ echo "${str/%,/}"
+}

View File

@ -0,0 +1,82 @@
commit 4af486794d45adbda7567361d8dcc658599dcd2c
Author: Johannes Meixner <jsmeix@suse.com>
Date: Tue Aug 8 14:44:16 2023 +0200
Merge pull request #3031 from rear/jsmeix-USB-Secure-Boot
Secure Boot support for OUTPUT=USB:
In output/USB/Linux-i386/100_create_efiboot.sh
added SECURE_BOOT_BOOTLOADER related code that is based
on the code in output/ISO/Linux-i386/250_populate_efibootimg.sh
with some adaptions to make it work within the existing USB code.
The basic idea for Secure Boot booting of the ReaR recovery system
is to "just copy" the (signed) EFI binaries of the Linux distribution
(shim*.efi and grub*.efi as first and second stage UEFI bootloaders)
instead of let ReaR make its own EFI binary via build_bootx86_efi()
see https://github.com/rear/rear/pull/3031
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 f4659306..fd631c44 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
@@ -29,6 +29,44 @@ mount $EFI_PART $EFI_MPT || Error "Failed to mount EFI partition '$EFI_PART' at
mkdir -p $EFI_DST || Error "Failed to create directory '$EFI_DST'"
# Copy boot loader
+# The SECURE_BOOT_BOOTLOADER related code below is based on the code in output/ISO/Linux-i386/250_populate_efibootimg.sh
+# because I <jsmeix@suse.de> noticed that Secure Boot works with ISO at least for me, cf.
+# https://github.com/rear/rear/pull/3025#issuecomment-1635876186
+# but not with USB, cf.
+# https://github.com/rear/rear/pull/3025#issuecomment-1643774477
+# so I tried to re-use the ISO Secure Boot code for USB
+# which made Secure Boot "just work" for me with USB
+# but I had to do some (minor) adaptions to make it work
+# within the existing USB code, cf.
+# https://github.com/rear/rear/pull/3031#issuecomment-1653443454
+# Copy UEFI bootloader:
+if test -f "$SECURE_BOOT_BOOTLOADER" ; then
+ # For a technical description of Shim see https://mjg59.dreamwidth.org/19448.html
+ # Shim is a signed EFI binary that is a first stage bootloader
+ # that loads and executes another (signed) EFI binary
+ # which normally is a second stage bootloader
+ # which normally is a GRUB EFI binary
+ # which normally is available as a file named grub*.efi
+ # so when SECURE_BOOT_BOOTLOADER is used as UEFI_BOOTLOADER
+ # (cf. rescue/default/850_save_sysfs_uefi_vars.sh)
+ # then Shim (usually shim.efi) must be copied as EFI/BOOT/BOOTX64.efi
+ # and Shim's second stage bootloader must be also copied where Shim already is.
+ DebugPrint "Using '$SECURE_BOOT_BOOTLOADER' as first stage Secure Boot bootloader BOOTX64.efi"
+ cp -L $v "$SECURE_BOOT_BOOTLOADER" "$EFI_DST/BOOTX64.efi" || Error "Failed to copy SECURE_BOOT_BOOTLOADER '$SECURE_BOOT_BOOTLOADER' to $EFI_DST/BOOTX64.efi"
+ # When Shim is used, its second stage bootloader can be actually anything
+ # named grub*.efi (second stage bootloader is Shim compile time option), see
+ # http://www.rodsbooks.com/efi-bootloaders/secureboot.html#initial_shim
+ local uefi_bootloader_dirname="$( dirname $SECURE_BOOT_BOOTLOADER )"
+ local second_stage_UEFI_bootloader_files="$( echo $uefi_bootloader_dirname/grub*.efi )"
+ # Avoid 'nullglob' pitfall when nothing matches .../grub*.efi which would result
+ # an invalid "cp -v /var/tmp/.../EFI/BOOT/" command that fails
+ # cf. https://github.com/rear/rear/issues/1921
+ test "$second_stage_UEFI_bootloader_files" || Error "Could not find second stage Secure Boot bootloader $uefi_bootloader_dirname/grub*.efi"
+ DebugPrint "Using second stage Secure Boot bootloader files: $second_stage_UEFI_bootloader_files"
+ cp -L $v $second_stage_UEFI_bootloader_files $EFI_DST/ || Error "Failed to copy second stage Secure Boot bootloader files"
+else
+ cp -L $v "$UEFI_BOOTLOADER" "$EFI_DST/BOOTX64.efi" || Error "Failed to copy UEFI_BOOTLOADER '$UEFI_BOOTLOADER' to $EFI_DST/BOOTX64.efi"
+fi
cp $v $UEFI_BOOTLOADER "$EFI_DST/BOOTX64.efi" || Error "Failed to copy UEFI_BOOTLOADER '$UEFI_BOOTLOADER' to $EFI_DST/BOOTX64.efi"
# Copy kernel
@@ -93,7 +131,14 @@ EOF
create_grub2_cfg ${EFI_DIR}/kernel ${EFI_DIR}/$REAR_INITRD_FILENAME > ${EFI_DST}/grub.cfg
# Create bootloader, this overwrite BOOTX64.efi copied in previous step ...
- build_bootx86_efi ${EFI_DST}/BOOTX64.efi ${EFI_DST}/grub.cfg "/boot" "$UEFI_BOOTLOADER"
+ # Create BOOTX86.efi but only if we are NOT secure booting.
+ # We are not able to create signed boot loader
+ # so we need to reuse existing one.
+ # See issue #1374
+ # build_bootx86_efi () can be safely used for other scenarios.
+ if ! test -f "$SECURE_BOOT_BOOTLOADER" ; then
+ build_bootx86_efi ${EFI_DST}/BOOTX64.efi ${EFI_DST}/grub.cfg "/boot" "$UEFI_BOOTLOADER"
+ fi
;;
*)
BugError "Neither grub 0.97 nor 2.0"

View File

@ -0,0 +1,41 @@
commit 1cd41052f7a7cd42ea14ea53b7280c73624aba3f
Author: Johannes Meixner <jsmeix@suse.com>
Date: Mon Mar 21 12:14:21 2022 +0100
Merge pull request #2774 from rear/jsmeix-1024-USB_UEFI_PART_SIZE
In default.conf increase USB_UEFI_PART_SIZE to 1024 MiB,
cf. https://github.com/rear/rear/pull/1205
in particular to also make things work by default when additional
third-party kernel modules and firmware (e.g. from Nvidia) are used,
cf. https://github.com/rear/rear/issues/2770#issuecomment-1068935688
diff --git a/usr/share/rear/conf/default.conf b/usr/share/rear/conf/default.conf
index 8faa56aa..17a764cb 100644
--- a/usr/share/rear/conf/default.conf
+++ b/usr/share/rear/conf/default.conf
@@ -872,13 +872,20 @@ USB_PARTITION_ALIGN_BLOCK_SIZE="8"
# in MiB when formatting a medium by the format workflow.
# If USB_UEFI_PART_SIZE is empty or invalid (i.e. not an unsigned integer larger than 0)
# the user must interactively enter a valid value while running the format workflow.
-# The default value of 400 MiB should be sufficiently big and it is in compliance
-# with the 8 MiB partition alignment default value ( 400 = 8 * 50 )
-# and even with a 16 MiB partition alignment value ( 400 = 16 * 25 )
+# The default value of 1024 MiB should be sufficiently big
# cf. https://github.com/rear/rear/pull/1205
+# in particular when third-party kernel modules and firmware (e.g. from Nvidia) are used
+# cf. https://github.com/rear/rear/issues/2770#issuecomment-1068935688
+# and 1024 MiB is in compliance with the 8 MiB partition alignment value ( 1024 = 8 * 128 )
+# and also with higher 2^n MiB partition alignment values.
+# Furthermore the default value of 1024 MiB results that the FAT filesystem of the ESP
+# will be in compliance with that the ESP should officially use a FAT32 filesystem
+# because mkfs.vfat automatically makes a FAT32 filesystem starting at 512 MiB
+# (a FAT16 ESP works in most cases but causes issues with certain UEFI firmware)
+# cf. https://github.com/rear/rear/issues/2575
# The value of USB_UEFI_PART_SIZE will be rounded to the nearest
# USB_PARTITION_ALIGN_BLOCK_SIZE chunk:
-USB_UEFI_PART_SIZE="400"
+USB_UEFI_PART_SIZE="1024"
#
# Default boot option (i.e. what gets booted automatically after some timeout)
# when EXTLINUX boots the USB stick or USB disk or other disk device on BIOS systems.

View File

@ -0,0 +1,21 @@
commit ead05a460d3b219372f47be888ba6011c7fd3318
Author: Pavel Cahyna <pcahyna@redhat.com>
Date: Tue Aug 22 12:32:04 2023 +0200
Fix downstream only bug
\$IsInArray -> IsInArray - it is a shell function, not a variable.
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 d34ab335..a65a9c8e 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
@@ -246,7 +246,7 @@ create_lvmvol() {
local warnraidline
if [ $is_thin -eq 0 ] ; then
- ifline="if IsInArray $vg \"\${create_logical_volumes[@]}\" && ! \$IsInArray $vg \"\${create_thin_volumes_only[@]}\" ; then"
+ ifline="if IsInArray $vg \"\${create_logical_volumes[@]}\" && ! IsInArray $vg \"\${create_thin_volumes_only[@]}\" ; then"
else
ifline="if IsInArray $vg \"\${create_logical_volumes[@]}\" ; then"
fi

View File

@ -3,7 +3,7 @@
Name: rear
Version: 2.6
Release: 17%{?dist}
Release: 20%{?dist}
Summary: Relax-and-Recover is a Linux disaster recovery and system migration tool
URL: http://relax-and-recover.org/
License: GPLv3
@ -44,6 +44,15 @@ Patch53: rear-bz2091163.patch
Patch54: rear-bz2130945.patch
Patch55: rear-bz2131946.patch
Patch56: s390-no-clobber-disks.patch
Patch57: rear-bz2188593-nbu-systemd.patch
Patch58: rear-device-shrinking-bz2223895.patch
Patch59: rear-usb-uefi-part-size-bz2228402.patch
Patch60: rear-luks-key-bz2228779.patch
Patch61: rear-uefi-usb-secureboot-bz2196445.patch
Patch62: rear-vg-command-not-found-bz2121476.patch
Patch63: rear-remove-lvmdevices-bz2145014.patch
Patch64: rear-save-lvm-poolmetadatasize-RHEL-6984.patch
Patch65: rear-skip-useless-xfs-mount-options-RHEL-10478.patch
# rear contains only bash scripts plus documentation so that on first glance it could be "BuildArch: noarch"
# but actually it is not "noarch" because it only works on those architectures that are explicitly supported.
@ -169,6 +178,27 @@ install -m 0644 %{SOURCE3} %{buildroot}%{_docdir}/%{name}/
#-- CHANGELOG -----------------------------------------------------------------#
%changelog
* Fri Dec 1 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-20
- Backport PR 3061 to save LVM pool metadata volume size in disk layout
and restore it
- Backport PR 3058 to skip useless xfs mount options when mounting
during recovery, prevents mount errors like "logbuf size must be greater
than or equal to log stripe size"
* Fri Aug 25 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-19
- Add patch to force removal of lvmdevices, prevents LVM problems after
restoring to different disks/cloning. Upstream PR 3043
* Tue Aug 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-18
- Add patch to start rsyslog and include NBU systemd units
- Apply PR 3027 to ensure correct creation of the rescue environment
when a file is shrinking while being read
- Backport PR 2774 to increase USB_UEFI_PART_SIZE to 1024 MiB
- Apply upstream patch for temp dir usage with LUKS to ensure
that during recovery an encrypted disk can be unlocked using a keyfile
- Backport upstream PR 3031: Secure Boot support for OUTPUT=USB
- Correct a mistake done when backporting PR 2691
* Wed Feb 22 2023 Pavel Cahyna <pcahyna@redhat.com> - 2.6-17
- Backport PR2943 to fix s390x dasd formatting
- Require s390utils-{core,base} on s390x