From 033c781748364771bcb11f36b29da4310ac1271d Mon Sep 17 00:00:00 2001 From: "Guilherme G. Piccoli" Date: Sat, 23 Dec 2023 13:44:56 -0500 Subject: [PATCH] kdumpst-load: Don't unnecessarily recreate GRUB config on pstore load What happens here is that the way GRUB's cmdline _removal_ was implemented so far, it tries to remove "crashkernel=" from GRUB in pstore case, based on kdumpst configuration. BUT it generates the GRUB config no matter what, so if users added a crashkernel entry themselves, that doesn't match kdumpst config file, what happens now is: 1) The code will try to sed-out our crashkernel setting from GRUB's config, with no success (since our particular setting's not there); 2) GRUB config *will be* recreated by kdumpst (needlessly). Fix that by checking if our crashkernel tuning is there before the sed command is attempted (and the GRUB config, recreated). Signed-off-by: Guilherme G. Piccoli --- kdumpst-load.sh.in | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kdumpst-load.sh.in b/kdumpst-load.sh.in index c28b925..02552e5 100644 --- a/kdumpst-load.sh.in +++ b/kdumpst-load.sh.in @@ -26,6 +26,11 @@ grub_update() { fi if [ "$1" = "pstore" ] && [ "${CRASHK}" -ne 0 ]; then + # Let's be sure our cmdline is there... + if ! grep -q "${GRUB_CMDLINE}" "${GRUB_CFG_FILE}"; then + return 0 + fi + sed -i "s/\"${GRUB_CMDLINE}/\"/g" "${GRUB_CFG_FILE}" if ! grub-mkconfig -o "${GRUB_BOOT_FILE}" 1>/dev/null; then