Set zstd as recommented for kexec-tools

This patch will make zstd as recommended instead of required for
kexec-tools. If zstd command/package is unavaliable, it can failback to invoke
gzip when making kdump initramfs.

Fixes: 0311f6e ("Set zstd as the default compression method for kdump initrd")

Signed-off-by: Tao Liu <ltao@redhat.com>
Acked-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Tao Liu 2022-01-10 21:51:16 +08:00 committed by Coiby Xu
parent ae0cbdf34a
commit 7de4a0d6c8
4 changed files with 16 additions and 3 deletions

View File

@ -31,6 +31,11 @@ is_squash_available()
done done
} }
is_zstd_command_available()
{
[[ -x "$(command -v zstd)" ]]
}
perror_exit() perror_exit()
{ {
derror "$@" derror "$@"

View File

@ -70,7 +70,7 @@ Requires: dracut >= 050
Requires: dracut-network >= 050 Requires: dracut-network >= 050
Requires: dracut-squash >= 050 Requires: dracut-squash >= 050
Requires: ethtool Requires: ethtool
Requires: zstd Recommends: zstd
Recommends: grubby Recommends: grubby
BuildRequires: make BuildRequires: make
BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel

View File

@ -432,7 +432,12 @@ done <<< "$(kdump_read_conf)"
handle_default_dump_target handle_default_dump_target
if ! have_compression_in_dracut_args; then if ! have_compression_in_dracut_args; then
# Here zstd is set as the default compression method. If squash module
# is available for dracut, libzstd will be used by mksquashfs. If
# squash module is unavailable, command zstd will be used instead.
if is_squash_available || is_zstd_command_available; then
add_dracut_arg "--compress" "zstd" add_dracut_arg "--compress" "zstd"
fi
fi fi
if [[ -n $extra_modules ]]; then if [[ -n $extra_modules ]]; then

View File

@ -62,8 +62,11 @@ if is_squash_available; then
_dracut_isolate_args+=(--add squash) _dracut_isolate_args+=(--add squash)
fi fi
# Same as setting zstd in mkdumprd
if ! have_compression_in_dracut_args; then if ! have_compression_in_dracut_args; then
if is_squash_available || is_zstd_command_available; then
_dracut_isolate_args+=(--compress zstd) _dracut_isolate_args+=(--compress zstd)
fi
fi fi
if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then