File kdump-systemd-support.patch of Package kdump.624

From: Petr Tesarik <>
Date: Thu Sep 18 15:40:37 2014 +0200
Subject: Dracut-systemd support
References: bnc#883883
Patch-mainline: v0.8.16
Git-commit: 9940475e501273ddac4a13fa2f4284b4121415de
Adjust the dracut module to work with the systemd module.

A new service is added to the initrd. I could not use a pre-pivot
hook, because dracut-pre-pivot.service does not send the output
to the terminal, so dump progress was not visible.

It is also necessary to avoid mounting the root filesystem. All
filesystems needed by kdump are mounted under /kdump and set up
with the --mount dracut option.

The system root mount can be generated in two ways:

a. by initrd-fstab-generator (if "root=" is passed on the kernel
   command line)

b. by dracut-rootfs-generator (if the root option is stored in

The root= parameter is already removed from the command line, but
it is always saved to /etc/cmdline.d/95root-dev.conf if dracut is
called with --hostonly-cmdline. This is the default in SLES (cf.
/etc/dracut.conf.d/01-dist.conf) and it is required to get correct
configuration for many setups.

So, the only way to avoid mounting /sysroot is to remove the
appropriate systemd generator from the initrd.

Signed-off-by: Petr Tesarik <>

diff --git a/init/CMakeLists.txt b/init/CMakeLists.txt
index 662197c..9cc8b71 100644
--- a/init/CMakeLists.txt
+++ b/init/CMakeLists.txt
@@ -79,4 +79,15 @@ INSTALL(
+    FILES
+        ${CMAKE_CURRENT_SOURCE_DIR}/kdump-save.service
+        /usr/lib/dracut/modules.d/99kdump
+        GROUP_READ
+        WORLD_READ
 # vim: set sw=4 ts=4 et:
diff --git a/init/kdump-save.service b/init/kdump-save.service
new file mode 100644
index 0000000..ac527f4
--- /dev/null
+++ b/init/kdump-save.service
@@ -0,0 +1,31 @@
+#  This file is part of systemd.
+#  systemd is free software; you can redistribute it and/or modify it
+#  under the terms of the GNU Lesser General Public License as published by
+#  the Free Software Foundation; either version 2.1 of the License, or
+#  (at your option) any later version.
+# See systemd.special(7) for details
+Description=save kernel crash dump
+Wants=dracut-mount.service dracut-pre-pivot.service
+After=dracut-mount.service dracut-pre-pivot.service
+# Bash ignores SIGTERM, so we send SIGHUP instead, to ensure that bash
+# terminates cleanly.
diff --git a/init/mkdumprd b/init/mkdumprd
index 334786f..bb818d2 100755
--- a/init/mkdumprd
+++ b/init/mkdumprd
@@ -122,7 +122,7 @@ function run_dracut()
     local modules="kdump"
-    DRACUT_ARGS="--force --hostonly --omit 'systemd plymouth resume usrmount'"
+    DRACUT_ARGS="--force --hostonly --omit 'plymouth resume usrmount'"
     DRACUT_ARGS="$DRACUT_ARGS --compress='xz -0 --check=crc32'"
     # add mount points
diff --git a/init/ b/init/
index 06f9775..690de38 100644
--- a/init/
+++ b/init/
@@ -18,8 +18,18 @@ install() {
     kdump_setup_files "$initdir" "${!host_fs_types[*]}"
-    inst_hook mount 30 "$moddir/"
-    inst_hook pre-pivot 90 /lib/kdump/
+    if dracut_module_included "systemd" ; then
+	rm -f "${initdir}/$systemdutildir"/system-generators/dracut-rootfs-generator
+	inst_simple /lib/kdump/
+	inst_simple "$moddir/kdump-save.service" \
+	    "$systemdsystemunitdir"/kdump-save.service
+	ln_r "$systemdsystemunitdir"/kdump-save.service \
+	    "$systemdsystemunitdir"/
+    else
+	inst_hook mount 30 "$moddir/"
+	inst_hook pre-pivot 90 /lib/kdump/
+    fi
     inst_multiple makedumpfile kdumptool \
     inst_simple /etc/resolv.conf