diff --git a/kdump-lib.sh b/kdump-lib.sh index 1db55fd..ca086d7 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -31,6 +31,11 @@ is_squash_available() done } +is_zstd_command_available() +{ + [[ -x "$(command -v zstd)" ]] +} + perror_exit() { derror "$@" diff --git a/kexec-tools.spec b/kexec-tools.spec index dffcce0..7419723 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -70,7 +70,7 @@ Requires: dracut >= 050 Requires: dracut-network >= 050 Requires: dracut-squash >= 050 Requires: ethtool -Requires: zstd +Recommends: zstd Recommends: grubby BuildRequires: make BuildRequires: zlib-devel elfutils-devel glib2-devel bzip2-devel ncurses-devel bison flex lzo-devel snappy-devel libzstd-devel diff --git a/mkdumprd b/mkdumprd index 9c26ecc..593ec77 100644 --- a/mkdumprd +++ b/mkdumprd @@ -432,7 +432,12 @@ done <<< "$(kdump_read_conf)" handle_default_dump_target if ! have_compression_in_dracut_args; then - add_dracut_arg "--compress" "zstd" + # 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" + fi fi if [[ -n $extra_modules ]]; then diff --git a/mkfadumprd b/mkfadumprd index 16fdacc..86dfcee 100644 --- a/mkfadumprd +++ b/mkfadumprd @@ -62,8 +62,11 @@ if is_squash_available; then _dracut_isolate_args+=(--add squash) fi +# Same as setting zstd in mkdumprd if ! have_compression_in_dracut_args; then - _dracut_isolate_args+=(--compress zstd) + if is_squash_available || is_zstd_command_available; then + _dracut_isolate_args+=(--compress zstd) + fi fi if ! dracut --force --quiet "${_dracut_isolate_args[@]}" "$@" "$TARGET_INITRD"; then