kdump-utils/0015-mkdumprd-explicitly-add-dracut-99squash-module.patch

112 lines
4.0 KiB
Diff
Raw Normal View History

From 70212dd7796cfe0df6a9fe9e3cb9c7b62231ba33 Mon Sep 17 00:00:00 2001
From: Philipp Rudo <prudo@redhat.com>
Date: Tue, 13 Aug 2024 17:09:32 +0200
Subject: [PATCH 15/16] mkdumprd: explicitly add dracut 99squash module
The handling of compression in the initrd currently is a total mess.
There are multiple problems:
1) It is handled in two different locations, mkdumprd and
99kdumpbase, making the code unnecessarily complex.
2) While mkdumprd only adds the --squash-compressor option when there is
no compression requested in kdump.conf:dracut_args, 99kdumpbase
unconditionally adds the 99squash module. But once 99squash is added
dracut ignores all compression options passed on the command line and
produces an uncompressed initrd (assuming the compression is done in
the squashfs image). So adding a compression option to dracut_args
will neither compress the initrd nor the squashfs image.
3) To depend on 99squash, 99kdumpbase only checks whether the required
kernel modules are present but doesn't check whether the
squashfs-tools are installed. This can lead to failures when building
the initrd as 99squash fails to install. At the moment this only
works as the dracut-squash rpm depends on the squashfs-tools. But
once support for erofs is added this might no longer be the case.
4) In case 99squash cannot be used mkdumprd compresses the initrd with
zstd. But that doesn't really makes sense. For one compressing the
initrd only reduces the on-disk size but not the memory usage during
runtime of the initrd. Plus in case no compression is specified
dracut will automatically compress the initrd. For that it checks for
the 'best' available compression algorithm with zstd being the
default.
Clean this mess up be moving everything to mkdumprd, only addding
99squash when there is no compression given in the dracut_args, drop
setting the --compress option and, only include 99squash when the
squashfs-tools are installed.
Note: Only checking the squashfs-tools is sufficient as it doesn't make
sense to have them installed, when the kernel doesn't support squashfs.
There might be a use case to build images that then get used on an other
machine where the kernel supports it. But as the initrd is build with
--hostonly that is no use case we need to consider for kdump.
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
dracut/99kdumpbase/module-setup.sh | 6 ------
kdump-lib.sh | 10 ----------
mkdumprd | 7 +++----
3 files changed, 3 insertions(+), 20 deletions(-)
diff --git a/dracut/99kdumpbase/module-setup.sh b/dracut/99kdumpbase/module-setup.sh
index 7508851..34593e4 100755
--- a/dracut/99kdumpbase/module-setup.sh
+++ b/dracut/99kdumpbase/module-setup.sh
@@ -44,12 +44,6 @@ depends() {
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
}
- if is_squash_available; then
- add_opt_module squash
- else
- dwarning "Required modules to build a squashed kdump image is missing!"
- fi
-
if is_wdt_active; then
add_opt_module watchdog
fi
diff --git a/kdump-lib.sh b/kdump-lib.sh
index ba853d9..c14e75e 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -43,16 +43,6 @@ is_sme_or_sev_active()
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" >/dev/null 2>&1
}
-is_squash_available()
-{
- local _version kmodule
-
- _version=$(_get_kdump_kernel_version)
- for kmodule in squashfs overlay loop; do
- modprobe -S "$_version" --dry-run $kmodule &> /dev/null || return 1
- done
-}
-
has_command()
{
[[ -x $(command -v "$1") ]]
diff --git a/mkdumprd b/mkdumprd
index 517ce19..366bcdb 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -379,10 +379,9 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target
if ! have_compression_in_dracut_args; then
- if is_squash_available; then
- dracut_args+=("--squash-compressor" "zstd")
- elif has_command zstd; then
- dracut_args+=("--compress" "zstd")
+ if has_command mksquashfs; then
+ dracut_args+=(--add squash)
+ dracut_args+=(--squash-compressor zstd)
fi
fi
--
2.46.1