From 0ffce0ef4ef3414e9b44614de3281fa0fb42ca05 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Fri, 13 Oct 2023 17:49:56 +0800 Subject: [PATCH] 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 Cc: Philipp Rudo Cc: Adam Williamson Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index b6d5994..01433e2 100755 --- a/kdumpctl +++ b/kdumpctl @@ -1649,6 +1649,10 @@ reset_crashkernel_for_installed_kernel() _update_crashkernel "$_installed_kernel" } +_should_reset_crashkernel() { + [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]] && systemctl is-enabled kdump &> /dev/null +} + main() { # Determine if the dump mode is kdump or fadump @@ -1715,12 +1719,12 @@ main() reset_crashkernel "$@" ;; _reset-crashkernel-after-update) - if [[ $(kdump_get_conf_val auto_reset_crashkernel) != no ]]; then + if _should_reset_crashkernel; then reset_crashkernel_after_update fi ;; _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" fi ;;