sync commits from branch 22.03

This commit is contained in:
panxiaohe 2022-04-11 17:17:48 +08:00
parent 55a33c94d9
commit 14497f3bfa
12 changed files with 843 additions and 5 deletions

View File

@ -0,0 +1,91 @@
From 819ea3865161d440353b2f961f3dfeaabeed333d Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Thu, 26 Jul 2018 12:49:45 +0200
Subject: [PATCH] Bring back 51-dracut-rescue-postinst.sh
can only be obsoleted after F30
Reference:https://github.com/dracutdevs/dracut/commit/819ea3865161d440353b2f961f3dfeaabeed333d
Conflict:delete contents of dracut.spec
---
51-dracut-rescue-postinst.sh | 68 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
create mode 100755 51-dracut-rescue-postinst.sh
diff --git a/51-dracut-rescue-postinst.sh b/51-dracut-rescue-postinst.sh
new file mode 100755
index 0000000..67f5b71
--- /dev/null
+++ b/51-dracut-rescue-postinst.sh
@@ -0,0 +1,68 @@
+#!/bin/bash
+
+export LANG=C
+
+KERNEL_VERSION="$1"
+KERNEL_IMAGE="$2"
+
+[[ -f /etc/os-release ]] && . /etc/os-release
+
+if [[ ! -f /etc/machine-id ]] || [[ ! -s /etc/machine-id ]]; then
+ systemd-machine-id-setup
+fi
+
+[[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
+
+[[ $MACHINE_ID ]] || exit 1
+[[ -f $KERNEL_IMAGE ]] || exit 1
+
+INITRDFILE="/boot/initramfs-0-rescue-${MACHINE_ID}.img"
+NEW_KERNEL_IMAGE="${KERNEL_IMAGE%/*}/vmlinuz-0-rescue-${MACHINE_ID}"
+
+[[ -f $INITRDFILE ]] && [[ -f $NEW_KERNEL_IMAGE ]] && exit 0
+
+dropindirs_sort()
+{
+ suffix=$1; shift
+ args=("$@")
+ files=$(
+ while (( $# > 0 )); do
+ for i in ${1}/*${suffix}; do
+ [[ -f $i ]] && echo ${i##*/}
+ done
+ shift
+ done | sort -Vu
+ )
+
+ for f in $files; do
+ for d in "${args[@]}"; do
+ if [[ -f "$d/$f" ]]; then
+ echo "$d/$f"
+ continue 2
+ fi
+ done
+ done
+}
+
+# source our config dir
+for f in $(dropindirs_sort ".conf" "/etc/dracut.conf.d" "/usr/lib/dracut/dracut.conf.d"); do
+ [[ -e $f ]] && . "$f"
+done
+
+[[ $dracut_rescue_image != "yes" ]] && exit 0
+
+if [[ ! -f $INITRDFILE ]]; then
+ dracut --no-hostonly -a "rescue" "$INITRDFILE" "$KERNEL_VERSION"
+ ((ret+=$?))
+fi
+
+if [[ ! -f $NEW_KERNEL_IMAGE ]]; then
+ cp --reflink=auto "$KERNEL_IMAGE" "$NEW_KERNEL_IMAGE"
+ ((ret+=$?))
+fi
+
+new-kernel-pkg --install "$KERNEL_VERSION" --kernel-image "$NEW_KERNEL_IMAGE" --initrdfile "$INITRDFILE" --banner "$NAME $VERSION_ID Rescue $MACHINE_ID"
+
+((ret+=$?))
+
+exit $ret
--
1.8.3.1

View File

@ -0,0 +1,54 @@
From 1af46743195422aaebcde5c508a5dd479eff51ea Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 10 Dec 2021 12:51:26 -0600
Subject: [PATCH] feat(lvm): only run lvchange for LV that is seen on devices
Change the command listing LVs from lvscan to lvs, and list
only the LV names that are being activated. Before attempting
to activate an LV, check that that LV name appears in the
lvs command output. This avoids wasting time running an
lvchange command that we know will fail.
---
modules.d/90lvm/lvm_scan.sh | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index bda265f..89f077a 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -119,7 +119,7 @@ sub=${sub%%\(*}
# ignores locking failures (--ignorelockingfailure)
# disables hints (--nohints)
#
-# For lvscan and vgscan:
+# For lvs and vgscan:
# disable locking (--nolocking)
# disable hints (--nohints)
@@ -136,10 +136,20 @@ check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
if [ -n "$LVS" ]; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
# shellcheck disable=SC2086
- lvm lvscan $scan_args 2>&1 | vinfo
+ LVSLIST=$(lvm lvs $scan_args --noheading -o lv_full_name,segtype $LVS)
+ info "$LVSLIST"
+
+ # Only attempt to activate an LV if it appears in the lvs output.
for LV in $LVS; do
- # shellcheck disable=SC2086
- lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
+ if strstr "$LVSLIST" "$LV"; then
+ # This lvchange is expected to fail if all PVs used by
+ # the LV are not yet present. Premature/failed lvchange
+ # could be avoided by reporting if an LV is complete
+ # from the lvs command above and skipping this lvchange
+ # if the LV is not lised as complete.
+ # shellcheck disable=SC2086
+ lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
+ fi
done
fi
--
1.8.3.1

View File

@ -0,0 +1,83 @@
From c0a54f2993b1d3c2101202c274a41f925445d54b Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:43:58 -0600
Subject: [PATCH] feat(lvm): update lvm command options
Drop checking for options that have been available for
at least ten years. This simplifies code maintenance.
Add the new --nohints option (when available) to disable
the use of hints which is not useful during startup.
---
modules.d/90lvm/lvm_scan.sh | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index 8038240..00143bf 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -59,39 +59,42 @@ min=$2
sub=${3%% *}
sub=${sub%%\(*}
-lvm_ignorelockingfailure="--ignorelockingfailure"
-lvm_quirk_args="--ignorelockingfailure --ignoremonitoring"
-
-check_lvm_ver 2 2 57 "$maj" "$min" "$sub" \
- && lvm_quirk_args="$lvm_quirk_args --poll n"
-
-if check_lvm_ver 2 2 65 "$maj" "$min" "$sub"; then
- lvm_quirk_args=" --sysinit $extraargs"
-fi
-
-if check_lvm_ver 2 2 221 "$maj" "$min" "$sub"; then
- lvm_quirk_args=" $extraargs"
- unset lvm_ignorelockingfailure
-fi
-
+# For lvchange and vgchange use --sysinit which:
+# disables polling (--poll n)
+# ignores monitoring (--ignoremonitoring)
+# ignores locking failures (--ignorelockingfailure)
+# disables hints (--nohints)
+#
+# For lvscan and vgscan:
+# disable locking (--nolocking)
+# disable hints (--nohints)
+
+activate_args="--sysinit $extraargs"
unset extraargs
export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
+scan_args="--nolocking"
+
+check_lvm_ver 2 3 14 "$maj" "$min" "$sub" \
+ && scan_args="$scan_args --nohints"
+
if [ -n "$LVS" ]; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
- lvm lvscan $lvm_ignorelockingfailure 2>&1 | vinfo
+ # shellcheck disable=SC2086
+ lvm lvscan $scan_args 2>&1 | vinfo
for LV in $LVS; do
# shellcheck disable=SC2086
- lvm lvchange --yes -K -ay $lvm_quirk_args "$LV" 2>&1 | vinfo
+ lvm lvchange --yes -K -ay $activate_args "$LV" 2>&1 | vinfo
done
fi
if [ -z "$LVS" ] || [ -n "$VGS" ]; then
info "Scanning devices $lvmdevs for LVM volume groups $VGS"
- lvm vgscan $lvm_ignorelockingfailure 2>&1 | vinfo
# shellcheck disable=SC2086
- lvm vgchange -ay $lvm_quirk_args $VGS 2>&1 | vinfo
+ lvm vgscan $scan_args 2>&1 | vinfo
+ # shellcheck disable=SC2086
+ lvm vgchange -ay $activate_args $VGS 2>&1 | vinfo
fi
if [ "$lvmwritten" ]; then
--
1.8.3.1

View File

@ -0,0 +1,141 @@
From 7ffc5e388bcce20785803825bdd260c3c854b34f Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 15:16:03 -0600
Subject: [PATCH] feat(lvm): use generated filter when none is set
Previously, the lvm device filter generated by dracut
would not be used if any lvm.conf file existed in the
initrd. Change this so that the generated filter will
be used when the included lvm.conf has no filter set.
---
modules.d/90lvm/lvm_scan.sh | 91 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 75 insertions(+), 16 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index 00143bf..bda265f 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -10,6 +10,7 @@ LVS=$(getargs rd.lvm.lv -d rd_LVM_LV=)
# shellcheck disable=SC2174
[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm
+[ -d /run/lvm ] || mkdir -m 0755 -p /run/lvm
# build a list of devices to scan
lvmdevs=$(
for f in /tmp/.lvm_scan-*; do
@@ -18,22 +19,6 @@ lvmdevs=$(
done
)
-if [ ! -e /etc/lvm/lvm.conf ]; then
- {
- echo 'devices {'
- printf ' filter = [ '
- for dev in $lvmdevs; do
- printf '"a|^/dev/%s$|", ' "$dev"
- done
- echo '"r/.*/" ]'
- echo '}'
-
- echo 'global {'
- echo '}'
- } > /etc/lvm/lvm.conf
- lvmwritten=1
-fi
-
check_lvm_ver() {
maj=$1
min=$2
@@ -47,6 +32,75 @@ check_lvm_ver() {
return 1
}
+no_lvm_conf_filter() {
+ if [ ! -e /etc/lvm/lvm.conf ]; then
+ return 0
+ fi
+
+ if [ -e /run/lvm/initrd_no_filter ]; then
+ return 0
+ fi
+
+ if [ -e /run/lvm/initrd_filter ]; then
+ return 1
+ fi
+
+ if [ -e /run/lvm/initrd_global_filter ]; then
+ return 1
+ fi
+
+ # Save lvm config results in /run to avoid running
+ # lvm config commands for every PV that's scanned.
+
+ filter=$(lvm config devices/filter | grep "$filter=")
+ if [ -n "$filter" ]; then
+ printf '%s\n' "$filter" > /run/lvm/initrd_filter
+ return 1
+ fi
+
+ global_filter=$(lvm config devices/global_filter | grep "$global_filter=")
+ if [ -n "$global_filter" ]; then
+ printf '%s\n' "$global_filter" > /run/lvm/initrd_global_filter
+ return 1
+ fi
+
+ # /etc/lvm/lvm.conf exists with no filter setting
+ true > /run/lvm/initrd_no_filter
+ return 0
+}
+
+# If no lvm.conf exists, create a basic one with a global section.
+if [ ! -e /etc/lvm/lvm.conf ]; then
+ {
+ echo 'global {'
+ echo '}'
+ } > /etc/lvm/lvm.conf
+ lvmwritten=1
+fi
+
+# Save the original lvm.conf before appending a filter setting.
+if [ ! -e /etc/lvm/lvm.conf.orig ]; then
+ cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.orig
+fi
+
+# If the original lvm.conf does not contain a filter setting,
+# then generate a filter and append it to the original lvm.conf.
+# The filter is generated from the list PVs that have been seen
+# so far (each has been processed by the lvm udev rule.)
+if no_lvm_conf_filter; then
+ {
+ echo 'devices {'
+ printf ' filter = [ '
+ for dev in $lvmdevs; do
+ printf '"a|^/dev/%s$|", ' "$dev"
+ done
+ echo '"r/.*/" ]'
+ echo '}'
+ } > /etc/lvm/lvm.conf.filter
+ lvmfilter=1
+ cat /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf.filter > /etc/lvm/lvm.conf
+fi
+
# hopefully this output format will never change, e.g.:
# LVM version: 2.02.53(1) (2009-09-25)
OLDIFS=$IFS
@@ -99,8 +153,13 @@ fi
if [ "$lvmwritten" ]; then
rm -f -- /etc/lvm/lvm.conf
+elif [ "$lvmfilter" ]; then
+ # revert filter that was appended to existing lvm.conf
+ cp /etc/lvm/lvm.conf.orig /etc/lvm/lvm.conf
+ rm -f -- /etc/lvm/lvm.conf.filter
fi
unset lvmwritten
+unset lvmfilter
udevadm settle
--
1.8.3.1

View File

@ -0,0 +1,30 @@
From 97543cca48dfde849396f11c83f9c320e1b91c46 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:14:27 -0600
Subject: [PATCH] fix(lvm): replace --partial option
The --partial option will activate a linear (or other) LV
without segments for missing devices, which is unlikely to
be useful. The intention was to activate raid LVs in a useful
form while missing devices, which is specified with the option
--activationmode degraded.
---
modules.d/90lvm/64-lvm.rules | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules.d/90lvm/64-lvm.rules b/modules.d/90lvm/64-lvm.rules
index 65f6524..ca718ce 100644
--- a/modules.d/90lvm/64-lvm.rules
+++ b/modules.d/90lvm/64-lvm.rules
@@ -15,7 +15,7 @@ PROGRAM=="/bin/sh -c 'for i in $sys/$devpath/holders/dm-[0-9]*; do [ -e $$i ] &&
GOTO="lvm_end"
RUN+="/sbin/initqueue --settled --onetime --unique /sbin/lvm_scan"
-RUN+="/sbin/initqueue --timeout --name 51-lvm_scan --onetime --unique /sbin/lvm_scan --partial"
+RUN+="/sbin/initqueue --timeout --name 51-lvm_scan --onetime --unique /sbin/lvm_scan --activationmode degraded"
RUN+="/bin/sh -c '>/tmp/.lvm_scan-%k;'"
LABEL="lvm_end"
--
1.8.3.1

View File

@ -0,0 +1,38 @@
From 164e5ebb1199ea3e3d641ce402d8257f0055a529 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 17 Dec 2021 12:14:51 -0600
Subject: [PATCH] fix(lvm): restore setting LVM_MD_PV_ACTIVATED
The 69-dm-lvm-metad.rules udev rule has been removed from
the initrd, because it's been dropped by recent upstream
lvm versions, and it never performed any primary function
within the initrd. But, it did have the job of setting
LVM_MD_PV_ACTIVATED=1 for active md devices used by PVs.
That step needs to be restored, and is now included in
64-lvm.rules.
---
modules.d/90lvm/64-lvm.rules | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/modules.d/90lvm/64-lvm.rules b/modules.d/90lvm/64-lvm.rules
index ca718ce..1ad4911 100644
--- a/modules.d/90lvm/64-lvm.rules
+++ b/modules.d/90lvm/64-lvm.rules
@@ -6,6 +6,14 @@
SUBSYSTEM!="block", GOTO="lvm_end"
ACTION!="add|change", GOTO="lvm_end"
+
+# If the md device is active (indicated by array_state), then set the flag
+# LVM_MD_PV_ACTIVATED=1 indicating that the md device for the PV is ready
+# to be used. The lvm udev rule running in root will check that this flag
+# is set before it will process the md device (it wants to avoid
+# processing an md device that exists but is not yet ready to be used.)
+KERNEL=="md[0-9]*", ACTION=="change", ENV{ID_FS_TYPE}=="LVM2_member", ENV{LVM_MD_PV_ACTIVATED}!="1", TEST=="md/array_state", ENV{LVM_MD_PV_ACTIVATED}="1"
+
# Also don't process disks that are slated to be a multipath device
ENV{DM_MULTIPATH_DEVICE_PATH}=="1", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", ACTION=="add", GOTO="lvm_end"
--
1.8.3.1

View File

@ -0,0 +1,44 @@
From 50e74668434d935db649b5690dc2158b0f87d91c Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:11:13 -0600
Subject: [PATCH] revert(lvm): remove 69-dm-lvm-metad.rules
This udev rule runs pvscan to autoactivate VGs, which dracut
does not want to do, and previously disabled by editing the
rule file and commenting out lines.
This also stops /dev/disk/by-id/lvm-pv-uuid-* symlinks from
being created in the initrd.
---
modules.d/90lvm/module-setup.sh | 15 +--------------
1 file changed, 1 insertion(+), 14 deletions(-)
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
index 0bb491f..25be013 100755
--- a/modules.d/90lvm/module-setup.sh
+++ b/modules.d/90lvm/module-setup.sh
@@ -78,20 +78,7 @@ install() {
unset LVM_SUPPRESS_FD_WARNINGS
fi
- inst_rules 11-dm-lvm.rules 69-dm-lvm-metad.rules
-
- # Do not run lvmetad update via pvscan in udev rule - lvmetad is not running yet in dracut!
- if [[ -f ${initdir}/lib/udev/rules.d/69-dm-lvm-metad.rules ]]; then
- if grep -q SYSTEMD_WANTS "${initdir}"/lib/udev/rules.d/69-dm-lvm-metad.rules; then
- sed -i -e 's/^ENV{SYSTEMD_ALIAS}=.*/# No LVM pvscan in dracut - lvmetad is not running yet/' \
- "${initdir}"/lib/udev/rules.d/69-dm-lvm-metad.rules
- sed -i -e 's/^ENV{ID_MODEL}=.*//' "${initdir}"/lib/udev/rules.d/69-dm-lvm-metad.rules
- sed -i -e 's/^ENV{SYSTEMD_WANTS}+\?=.*//' "${initdir}"/lib/udev/rules.d/69-dm-lvm-metad.rules
- else
- sed -i -e 's/.*lvm pvscan.*/# No LVM pvscan for in dracut - lvmetad is not running yet/' \
- "${initdir}"/lib/udev/rules.d/69-dm-lvm-metad.rules
- fi
- fi
+ inst_rules 11-dm-lvm.rules
# Gentoo ebuild for LVM2 prior to 2.02.63-r1 doesn't install above rules
# files, but provides the one below:
--
1.8.3.1

View File

@ -0,0 +1,69 @@
From f6f393f550625e3e1c968ef32d6d7bdd90f51d73 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:07:42 -0600
Subject: [PATCH] revert(lvm): remove lvmetad config changes
Remove support for modifying use_lvmetad and locking_type
settings in lvm.conf for lvm versions 2.2.*. Recent lvm
versions (2.3.*) do not include lvmetad or locking_type.
This cleanup simplifies code maintenance.
To use the lvm module with older versions (2.2), a user
would need to ensure that lvmetad settings are disabled
in the initrd's lvm.conf rather than relying on the lvm
dracut mode to modify their lvm.conf.
---
modules.d/90lvm/lvm_scan.sh | 3 ---
modules.d/90lvm/module-setup.sh | 14 --------------
2 files changed, 17 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index 43601ad..8038240 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -28,10 +28,7 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
echo '"r/.*/" ]'
echo '}'
- # establish LVM locking
echo 'global {'
- echo ' locking_type = 4'
- echo ' use_lvmetad = 0'
echo '}'
} > /etc/lvm/lvm.conf
lvmwritten=1
diff --git a/modules.d/90lvm/module-setup.sh b/modules.d/90lvm/module-setup.sh
index e1e6c58..0bb491f 100755
--- a/modules.d/90lvm/module-setup.sh
+++ b/modules.d/90lvm/module-setup.sh
@@ -61,10 +61,6 @@ install() {
if [[ $hostonly ]] || [[ $lvmconf == "yes" ]]; then
if [[ -f $dracutsysrootdir/etc/lvm/lvm.conf ]]; then
inst_simple -H /etc/lvm/lvm.conf
- # FIXME: near-term hack to establish read-only locking;
- # use command-line lvm.conf editor once it is available
- sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 4/' "${initdir}/etc/lvm/lvm.conf"
- sed -i -e 's/\(^[[:space:]]*\)use_lvmetad[[:space:]]*=[[:space:]]*[[:digit:]]/\1use_lvmetad = 0/' "${initdir}/etc/lvm/lvm.conf"
fi
export LVM_SUPPRESS_FD_WARNINGS=1
@@ -82,16 +78,6 @@ install() {
unset LVM_SUPPRESS_FD_WARNINGS
fi
- if ! [[ -e ${initdir}/etc/lvm/lvm.conf ]]; then
- mkdir -p "${initdir}/etc/lvm"
- {
- echo 'global {'
- echo 'locking_type = 4'
- echo 'use_lvmetad = 0'
- echo '}'
- } > "${initdir}/etc/lvm/lvm.conf"
- fi
-
inst_rules 11-dm-lvm.rules 69-dm-lvm-metad.rules
# Do not run lvmetad update via pvscan in udev rule - lvmetad is not running yet in dracut!
--
1.8.3.1

View File

@ -0,0 +1,79 @@
From 1549d5e89818603e1aa6dd8a40981222f59f1548 Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Wed, 8 Dec 2021 14:04:25 -0600
Subject: [PATCH] revert(lvm): remove snapshot feature
The feature of managing lvm snapshots has no known
recent usage. It is unknown if it works. The lvm
developers do not wish to maintain or support it.
---
modules.d/90lvm/lvm_scan.sh | 39 ++++-----------------------------------
1 file changed, 4 insertions(+), 35 deletions(-)
diff --git a/modules.d/90lvm/lvm_scan.sh b/modules.d/90lvm/lvm_scan.sh
index c42f97d..43601ad 100755
--- a/modules.d/90lvm/lvm_scan.sh
+++ b/modules.d/90lvm/lvm_scan.sh
@@ -7,8 +7,6 @@ type getarg > /dev/null 2>&1 || . /lib/dracut-lib.sh
VGS=$(getargs rd.lvm.vg -d rd_LVM_VG=)
LVS=$(getargs rd.lvm.lv -d rd_LVM_LV=)
-SNAPSHOT=$(getargs rd.lvm.snapshot -d rd_LVM_SNAPSHOT=)
-SNAPSIZE=$(getargs rd.lvm.snapsize -d rd_LVM_SNAPSIZE=)
# shellcheck disable=SC2174
[ -d /etc/lvm ] || mkdir -m 0755 -p /etc/lvm
@@ -31,17 +29,10 @@ if [ ! -e /etc/lvm/lvm.conf ]; then
echo '}'
# establish LVM locking
- if [ -n "$SNAPSHOT" ]; then
- echo 'global {'
- echo ' locking_type = 1'
- echo ' use_lvmetad = 0'
- echo '}'
- else
- echo 'global {'
- echo ' locking_type = 4'
- echo ' use_lvmetad = 0'
- echo '}'
- fi
+ echo 'global {'
+ echo ' locking_type = 4'
+ echo ' use_lvmetad = 0'
+ echo '}'
} > /etc/lvm/lvm.conf
lvmwritten=1
fi
@@ -90,28 +81,6 @@ unset extraargs
export LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES=1
-if [ -n "$SNAPSHOT" ]; then
- # HACK - this should probably be done elsewhere or turned into a function
- # Enable read-write LVM locking
- sed -i -e 's/\(^[[:space:]]*\)locking_type[[:space:]]*=[[:space:]]*[[:digit:]]/\1locking_type = 1/' /etc/lvm/lvm.conf
-
- # Expected SNAPSHOT format "<orig lv name>:<snap lv name>"
- ORIG_LV=${SNAPSHOT%%:*}
- SNAP_LV=${SNAPSHOT##*:}
-
- info "Removing existing LVM snapshot $SNAP_LV"
- lvm lvremove --force "$SNAP_LV" 2>&1 | vinfo
-
- # Determine snapshot size
- if [ -z "$SNAPSIZE" ]; then
- SNAPSIZE=$(lvm lvs --noheadings --units m --options lv_size "$ORIG_LV")
- info "No LVM snapshot size provided, using size of $ORIG_LV ($SNAPSIZE)"
- fi
-
- info "Creating LVM snapshot $SNAP_LV ($SNAPSIZE)"
- lvm lvcreate -s -n "$SNAP_LV" -L "$SNAPSIZE" "$ORIG_LV" 2>&1 | vinfo
-fi
-
if [ -n "$LVS" ]; then
info "Scanning devices $lvmdevs for LVM logical volumes $LVS"
lvm lvscan $lvm_ignorelockingfailure 2>&1 | vinfo
--
1.8.3.1

View File

@ -9,7 +9,7 @@
Name: dracut
Version: 055
Release: 2
Release: 3
Summary: Initramfs generator using udev
@ -24,10 +24,21 @@ URL: https://dracut.wiki.kernel.org/
Source0: http://www.kernel.org/pub/linux/utils/boot/dracut/dracut-%{version}.tar.xz
#Source0: https://git.kernel.org/pub/scm/boot/dracut/dracut.git/snapshot/dracut-%{version}.tar.gz
Patch1: dracut-network-fixed-net-rules-issue-hence-systemd-r.patch
Patch2: skip-the-broken-sd-in-initqueue.patch
Patch3: use-sleep-replace-check-sys-block.patch
Patch4: add-option-to-include-file-metadata-in-initramfs.patch
Patch1: dracut-network-fixed-net-rules-issue-hence-systemd-r.patch
Patch2: skip-the-broken-sd-in-initqueue.patch
Patch3: use-sleep-replace-check-sys-block.patch
Patch4: add-option-to-include-file-metadata-in-initramfs.patch
Patch5: revert-fix-systemd-networkd-make-systemd-networkd.patch
Patch6: make-network-legacy-instead-of-network-manager-the-network.patch
Patch7: backport-revert-lvm-remove-snapshot-feature.patch
Patch8: backport-revert-lvm-remove-lvmetad-config-changes.patch
Patch9: backport-revert-lvm-remove-69-dm-lvm-metad.rules.patch
Patch10: backport-fix-lvm-replace-partial-option.patch
Patch11: backport-feat-lvm-update-lvm-command-options.patch
Patch12: backport-feat-lvm-use-generated-filter-when-none-is-set.patch
Patch13: backport-feat-lvm-only-run-lvchange-for-LV-that-is-seen-on-de.patch
Patch14: backport-fix-lvm-restore-setting-LVM_MD_PV_ACTIVATED.patch
Patch15: backport-Bring-back-51-dracut-rescue-postinst.sh.patch
Source1: https://www.gnu.org/licenses/lgpl-2.1.txt
Source2: openEuler.conf.example
@ -271,6 +282,9 @@ rm -f -- $RPM_BUILD_ROOT%{_bindir}/lsinitrd
%if 0%{?openEuler} || 0%{?fedora} || 0%{?rhel}
echo 'hostonly="no"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-generic-image.conf
echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/02-rescue.conf
mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d
install -m 0755 51-dracut-rescue-postinst.sh $RPM_BUILD_ROOT%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%files
@ -493,9 +507,18 @@ echo 'dracut_rescue_image="yes"' > $RPM_BUILD_ROOT%{dracutlibdir}/dracut.conf.d/
%{dracutlibdir}/dracut.conf.d/02-rescue.conf
%if 0%{?openEuler} || 0%{?fedora} || 0%{?rhel}
%{_prefix}/lib/kernel/install.d/51-dracut-rescue.install
%{_sysconfdir}/kernel/postinst.d/51-dracut-rescue-postinst.sh
%endif
%changelog
* Mon Apr 11 2022 panxiaohe <panxh.life@foxmail.com> - 055-3
- bring back 51-dracut-rescue-postinst.sh for rescue mode
- backport patches from upstream: improve lvm module
- make network-legacy instead of network-manager
the network provider
- revert patch "make systemd networkd a proper network
provider" to use network-legacy.
* Wed Aug 11 2021 chenyanpanHW <chenyanpan@huawei.com> - 055-2
- DESC: delete -S git_am from %autosetup, and delete BuildRequires git

View File

@ -0,0 +1,26 @@
From 9c3c197ce47bc45d0ea97bd3d4e05860c778df1b Mon Sep 17 00:00:00 2001
From: panxiaohe <panxiaohe@huawei.com>
Date: Mon, 17 Jan 2022 19:53:41 +0800
Subject: [PATCH] make network-legacy instead of network-manager the network
provider
---
modules.d/40network/module-setup.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index cbb5b70..5396a49 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -19,8 +19,6 @@ depends() {
if [ -z "$network_handler" ]; then
if [[ -x $dracutsysrootdir$systemdsystemunitdir/wicked.service ]]; then
network_handler="network-wicked"
- elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
- network_handler="network-manager"
else
network_handler="network-legacy"
fi
--
1.8.3.1

View File

@ -0,0 +1,160 @@
From 03d8f6a99e9fbc73836982c84fda9fb74be8cda9 Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
Date: Wed, 25 Aug 2021 10:00:16 +0800
Subject: [PATCH] revert "fix(systemd-networkd): make systemd-networkd a
proper network provider"
This reverts commit ea779750c371102c04252b48f1b7d9c7ece7cf93 to make
network-legacy to be the network provider.
---
modules.d/01systemd-networkd/module-setup.sh | 91 ++++++++++++----------------
modules.d/40network/module-setup.sh | 4 +-
2 files changed, 39 insertions(+), 56 deletions(-)
diff --git a/modules.d/01systemd-networkd/module-setup.sh b/modules.d/01systemd-networkd/module-setup.sh
index 2f1ecb8..c0a970f 100755
--- a/modules.d/01systemd-networkd/module-setup.sh
+++ b/modules.d/01systemd-networkd/module-setup.sh
@@ -1,79 +1,64 @@
#!/bin/bash
-# This file is part of dracut.
-# SPDX-License-Identifier: GPL-2.0-or-later
-# Prerequisite check(s) for module.
+# called by dracut
check() {
[[ $mount_needs ]] && return 1
- # If the binary(s) requirements are not fulfilled the module can't be installed
- require_binaries ip networkctl \
- "$systemdutildir"/systemd-networkd \
- "$systemdutildir"/systemd-network-generator \
- "$systemdutildir"/systemd-networkd-wait-online \
- || return 1
-
- # Return 255 to only include the module, if another module requires it.
return 255
-
}
-# Module dependency requirements.
+# called by dracut
depends() {
+ echo "systemd kernel-network-modules"
+}
- # This module has external dependency on other module(s).
- echo dbus kernel-network-modules systemd-sysusers
- # Return 0 to include the dependent module(s) in the initramfs.
+installkernel() {
return 0
-
}
-# Install the required file(s) and directories for the module in the initramfs.
+# called by dracut
install() {
-
inst_multiple -o \
- "$dbussystem"/org.freedesktop.network1.conf \
- "$dbussystemservices"/org.freedesktop.network1.service \
- "$systemdutildir"/networkd.conf \
- "$systemdutildir/networkd.conf.d/*.conf" \
"$systemdutildir"/systemd-networkd \
- "$systemdutildir"/systemd-network-generator \
"$systemdutildir"/systemd-networkd-wait-online \
- "$systemdutildir"/network/80-container-host0.network \
- "$systemdutildir"/network/80-container-ve.network \
- "$systemdutildir"/network/80-container-vz.network \
- "$systemdutildir"/network/80-vm-vt.network \
- "$systemdutildir"/network/80-wifi-adhoc.network \
- "$systemdutildir"/network/99-default.link \
+ "$systemdsystemunitdir"/systemd-networkd-wait-online.service \
"$systemdsystemunitdir"/systemd-networkd.service \
"$systemdsystemunitdir"/systemd-networkd.socket \
- "$systemdsystemunitdir"/systemd-network-generator.service \
- "$systemdsystemunitdir"/systemd-networkd-wait-online.service \
- "$systemdsystemunitdir"/systemd-network-generator.service \
+ "$systemdutildir"/network/99-default.link \
networkctl ip
- # Enable systemd type units
+ #hostnamectl timedatectl
+ # $systemdutildir/systemd-timesyncd \
+ # $systemdutildir/systemd-timedated \
+ # $systemdutildir/systemd-hostnamed \
+ # $systemdutildir/systemd-resolvd \
+ # $systemdutildir/systemd-resolve-host \
+ # $systemdsystemunitdir/systemd-resolved.service \
+ # $systemdsystemunitdir/systemd-hostnamed.service \
+ # $systemdsystemunitdir/systemd-timesyncd.service \
+ # $systemdsystemunitdir/systemd-timedated.service \
+ # $systemdsystemunitdir/time-sync.target \
+ # /etc/systemd/resolved.conf \
+
+ # inst_dir /var/lib/systemd/clock
+
+ grep '^systemd-network:' "$dracutsysrootdir"/etc/passwd 2> /dev/null >> "$initdir/etc/passwd"
+ grep '^systemd-network:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
+ # grep '^systemd-timesync:' "$dracutsysrootdir"/etc/passwd 2>/dev/null >> "$initdir/etc/passwd"
+ # grep '^systemd-timesync:' "$dracutsysrootdir"/etc/group >> "$initdir/etc/group"
+
+ _arch=${DRACUT_ARCH:-$(uname -m)}
+ inst_libdir_file \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_dns.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_mdns4_minimal.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_myhostname.so.*" \
+ {"tls/$_arch/",tls/,"$_arch/",}"libnss_resolve.so.*"
+
+ # systemd-timesyncd.service
for i in \
+ systemd-networkd-wait-online.service \
systemd-networkd.service \
- systemd-networkd.socket \
- systemd-network-generator.service \
- systemd-networkd-wait-online.service; do
+ systemd-networkd.socket; do
$SYSTEMCTL -q --root "$initdir" enable "$i"
done
-
- # Install the hosts local user configurations if enabled.
- if [[ $hostonly ]]; then
- inst_multiple -H -o \
- "$systemdutilconfdir"/networkd.conf \
- "$systemdutilconfdir/networkd.conf.d/*.conf" \
- "$systemdutilconfdir/network/*" \
- "$systemdsystemconfdir"/systemd-networkd.service \
- "$systemdsystemconfdir/systemd-networkd.service/*.conf" \
- "$systemdsystemunitdir"/systemd-networkd.socket \
- "$systemdsystemunitdir/systemd-networkd.socket/*.conf" \
- "$systemdsystemconfdir"/systemd-network-generator.service \
- "$systemdsystemconfdir/systemd-network-generator.service/*.conf" \
- "$systemdsystemconfdir"/systemd-networkd-wait-online.service \
- "$systemdsystemconfdir/systemd-networkd-wait-online.service/*.conf"
- fi
}
diff --git a/modules.d/40network/module-setup.sh b/modules.d/40network/module-setup.sh
index 60824da..cbb5b70 100755
--- a/modules.d/40network/module-setup.sh
+++ b/modules.d/40network/module-setup.sh
@@ -9,7 +9,7 @@ check() {
depends() {
is_qemu_virtualized && echo -n "qemu-net "
- for module in network-wicked network-manager network-legacy systemd-networkd; do
+ for module in network-wicked network-manager network-legacy; do
if dracut_module_included "$module"; then
network_handler="$module"
break
@@ -21,8 +21,6 @@ depends() {
network_handler="network-wicked"
elif [[ -x $dracutsysrootdir/usr/libexec/nm-initrd-generator ]]; then
network_handler="network-manager"
- elif [[ -x $dracutsysrootdir$systemdutildir/systemd-networkd ]]; then
- network_handler="systemd-networkd"
else
network_handler="network-legacy"
fi
--
1.8.3.1