Skip to content

Commit

Permalink
mkdumprd: explicitly add dracut 99squash module
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
prudo1 committed Aug 22, 2024
1 parent e926465 commit e862017
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 20 deletions.
6 changes: 0 additions & 6 deletions dracut/99kdumpbase/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions kdump-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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") ]]
Expand Down
7 changes: 3 additions & 4 deletions mkdumprd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit e862017

Please sign in to comment.