summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme G. Piccoli <gpiccoli@canonical.com>2020-07-07 18:58:26 +0000
committerGuilherme G. Piccoli <gpiccoli@canonical.com>2020-08-04 17:11:15 -0300
commit0d2fde57aff9ae1cb8d5c80b3b4fe03c3944d96c (patch)
treedf7c39bf56445231c31c5f4b20c9c686080220f3
parent189faca0c43b74f4b6c4dee4bcd4c5d6cee44aeb (diff)
kdump-tools: Cope with the lack of initramfs-tools OPTION=VAR feature in Debian
Currently, there's an interesting feature on Ubuntu's initramfs-tools that allows a fine-tuned control on the hooks/scripts that will be executed/included in the initrd image, depending on options set on initramfs-tools.conf and validated via OPTION=VAR in the hooks/scripts. Since this isn't included in Debian initramfs-tools (for some unknown reason), we need to amend the sysctl handling on Debian's kdump-tools by adding more checks in both the hook and script, in order to avoid them to run in regular boot. The idea of having an extra patch for that is (a) to keep better code sync with Ubuntu and commit organization, (b) expectation on including the OPTION=VAR feature in Debian's initramfs-tools, hence this patch might be reverted in the future. Required-by-commit: "kdump-tools: Add sysctl override mechanism" Signed-off-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
-rw-r--r--debian/initramfs.hook12
-rw-r--r--debian/initramfs.local-bottom18
-rwxr-xr-xdebian/kernel-postinst-generate-initrd6
3 files changed, 36 insertions, 0 deletions
diff --git a/debian/initramfs.hook b/debian/initramfs.hook
index fdbde24..5628331 100644
--- a/debian/initramfs.hook
+++ b/debian/initramfs.hook
@@ -2,6 +2,10 @@
#
# This kdump-tools hook includes kdump sysctl overrides to the
# kdump minimal initrd.
+#
+# OPTION=VAR is a control provided only by Ubuntu initramfs-tools,
+# so this is innocuous and harmless on Debian - kept here for
+# better code sync between Debian and Ubuntu.
OPTION=KDUMP
PREREQ=""
@@ -17,6 +21,14 @@ prereqs)
;;
esac
+# In Debian we don't have the fine-tuned control of what hooks to run
+# based on OPTION=VAR (like Ubuntu). So, we need the folowing check
+# in order to prevent this hook to run for regular initrds - it should
+# only be executed for kdump smaller initrd.
+if [ "${CONFDIR}" != "/var/lib/kdump/initramfs-tools" ]; then
+ exit 0
+fi
+
. /usr/share/initramfs-tools/hook-functions
KDUMP_SYSCTL_PATH="/etc/kdump/sysctl.conf"
diff --git a/debian/initramfs.local-bottom b/debian/initramfs.local-bottom
index 1bfb0a6..f099138 100644
--- a/debian/initramfs.local-bottom
+++ b/debian/initramfs.local-bottom
@@ -4,6 +4,15 @@
# the sysctl settings present on file /etc/kdump/sysctl.conf.
# Only kdump minimal initrd contains this script - regular initrds won't
# get this script included, since KDUMP variable is not set by default.
+#
+# Well....this is not entirely true in Debian. Due to initramfs-tools
+# on Debian lacking the OPTION=VAR feature (present in Ubuntu) to
+# control which scripts get included in initrd (based on the OPTION
+# value), this script *will* be included in regular initrd also.
+# But we have a check below to prevent it from doing the sysctls
+# overriding. We chose to kept the innocuous OPTION here to better
+# code sync with Ubuntu.
+
OPTION=KDUMP
set +e
@@ -13,6 +22,15 @@ case "${1}" in
;;
esac
+# In Debian we don't have the fine-tuned control of what scripts should
+# be included in the initrd based on OPTION=VAR (like Ubuntu). So, we
+# need the folowing check in order to prevent this script from running
+# on regular initrds - it should only be executed on kdump boot.
+VMCORE_FILE=/proc/vmcore
+if [ ! -e $VMCORE_FILE ]; then
+ exit 0
+fi
+
KDUMP_SYSCTL_PATH="/etc/kdump/sysctl.conf"
# Do not prevent the system boot on error, kdump may be the last resource!
if [ ! -d /run ]; then
diff --git a/debian/kernel-postinst-generate-initrd b/debian/kernel-postinst-generate-initrd
index bad88b4..548f50c 100755
--- a/debian/kernel-postinst-generate-initrd
+++ b/debian/kernel-postinst-generate-initrd
@@ -58,6 +58,12 @@ fi
# Mark our custom initramfs.conf to indicate that kdump-tools
# hooks/scripts should run/get included in our minimal initrd.
+#
+# Unfortunately, this is not true for Debian. OPTION=VAR is a
+# control provided only by Ubuntu initramfs-tools, so this is
+# innocuous /harmless on Debian - kept here for better code
+# sync between Debian and Ubuntu. We needed special checks on
+# hook/script in Debian to prevent them on regular initrd.
echo "KDUMP=y" >> $initramfsdir/initramfs.conf
# Cleaning up existing initramfs with same version