File kdump-root-parameter.patch of Package kdump.624

Date: Fri Oct 17 17:48:12 2014 +0200
From: Petr Tesarik <ptesarik@suse.cz>
Subject: Make sure system root is not mounted in kdump initrd
References: bsc#900134
Patch-mainline: v0.8.16
Git-commit: 11c20ad71226b703141006d77c5374bc552052ba

All required mounts are added under /kdump, including the root
filesystem (if needed at all). But initrd may try to mount the
system root filesystem nevertheless, which fails if it is also
mounted under /kdump.

This commit passes a special keyword for the root= parameter to
avoid the second mount. Originally, the root= parameter was omitted,
but that did not work on platforms with DeviceTree (e.g. ppc64),
because kexec-tools added this parameter automatically.

Note that the "root=" parameter may be interpreted by two different
pieces of software: either by the default systemd fstab-generator,
or by dracut's rootfs-generator. The root=kdump parameter takes
care of both, because:

1. anything that doesn't start with a slash ('/') is ignored by
   the systemd generator,
2. kdump-root.sh sets rootok=1, so dracut does not panic because
   of unknown root= parameter

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 init/CMakeLists.txt     |    1 +
 init/kdump-root.sh      |   11 +++++++++++
 init/module-setup.sh    |    1 +
 init/rc.kdump.functions |    1 +
 4 files changed, 14 insertions(+)

--- /dev/null
+++ b/init/kdump-root.sh
@@ -0,0 +1,11 @@
+#! /bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+# This script is sourced, so root should be set. But let's be paranoid
+[ -z "$root" ] && root=$(getarg root=)
+
+# kdump initrd uses a special directory structure
+if [ "$root" = "kdump" ]; then
+    rootok=1
+fi
--- a/init/module-setup.sh
+++ b/init/module-setup.sh
@@ -140,6 +140,7 @@ install() {
 
     kdump_setup_files "$initdir" "$kdump_mpath_wwids"
 
+    inst_hook cmdline 50 "$moddir/kdump-root.sh"
     if dracut_module_included "systemd" ; then
 	[ "$KDUMP_FADUMP" != yes ] && \
 	    rm -f "${initdir}/$systemdutildir"/system-generators/dracut-rootfs-generator
--- a/init/rc.kdump.functions
+++ b/init/rc.kdump.functions
@@ -113,6 +113,7 @@ function build_kdump_commandline()
         # Use deadline for saving the memory footprint
         commandline="$commandline elevator=deadline sysrq=yes reset_devices acpi_no_memhotplug cgroup_disable=memory"
         commandline="$commandline irqpoll ${nr_cpus}=${KDUMP_CPUS:-1}"
+        commandline="$commandline root=kdump"
         local arch=$(uname -i)
         case "$arch" in
         i?86|x86_64)
--- a/init/CMakeLists.txt
+++ b/init/CMakeLists.txt
@@ -69,6 +69,7 @@ INSTALL(
 
 INSTALL(
     FILES
+        ${CMAKE_CURRENT_SOURCE_DIR}/kdump-root.sh
         ${CMAKE_CURRENT_SOURCE_DIR}/module-setup.sh
         ${CMAKE_CURRENT_SOURCE_DIR}/mount-kdump.sh
     DESTINATION