Only try to reset crashkernel when kdump.service is enabled

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2243068

Currently, when kexec-tools is installed, the kernel will automatically
have the crashkernel parameter set up. In the case where users only want
the kexec reboot feature, this is not what users want as a 1G-RAM system
will lose 192M memory. Considering Fedora's systemd preset policy has
kdump.service disabled and RHEL' has kdump.service enabled, this patch
makes kexec-tools only reset crashkernel when kdump.service is enabled.

Reported-by: Chris Murphy <bugzilla@colorremedies.com>
Cc: Philipp Rudo <prudo@redhat.com>
Cc: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Reviewed-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
Coiby Xu 2023-10-13 17:49:56 +08:00
parent 5058cef90c
commit 0ffce0ef4e

View File

@ -1649,6 +1649,10 @@ reset_crashkernel_for_installed_kernel()
_update_crashkernel "$_installed_kernel" _update_crashkernel "$_installed_kernel"
} }
_should_reset_crashkernel() {
[[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]] && systemctl is-enabled kdump &> /dev/null
}
main() main()
{ {
# Determine if the dump mode is kdump or fadump # Determine if the dump mode is kdump or fadump
@ -1715,12 +1719,12 @@ main()
reset_crashkernel "$@" reset_crashkernel "$@"
;; ;;
_reset-crashkernel-after-update) _reset-crashkernel-after-update)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then if _should_reset_crashkernel; then
reset_crashkernel_after_update reset_crashkernel_after_update
fi fi
;; ;;
_reset-crashkernel-for-installed_kernel) _reset-crashkernel-for-installed_kernel)
if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then if _should_reset_crashkernel; then
reset_crashkernel_for_installed_kernel "$2" reset_crashkernel_for_installed_kernel "$2"
fi fi
;; ;;