The current kdump infrastructure builds a separate initrd which then
gets loaded into memory by kexec-tools for use by kdump kernel. But
firmware assisted dump (FADUMP) does not use kexec-based approach.
After crash, firmware reboots the partition and loads grub loader
like the normal booting process does. Hence in the FADUMP approach,
the second kernel (after crash) will always use the default initrd
(OS built). So, to support FADUMP, change is required, as in to add
dump capturing steps, in default initrd.
The current kdumpctl script implementation already has the code to
build initrd using mkdumprd. This patch uses the new '--rebuild'
option introduced, in dracut, to incrementally build the initramfs
image. A backup of default initrd image is taken before rebuilding
default initrd image with fadump support. If this operation fails,
default initrd image is restored.
Kexec-tools package in rhel7 is now enhanced to insert a out-of-tree
kdump module for dracut, which is responsible for adding vmcore
capture steps into initrd, if dracut is invoked with "IN_KDUMP"
environment variable set to 1. mkdumprd script exports "IN_KDUMP=1"
environment variable before invoking dracut to build kdump initrd.
This patch relies on this current mechanism of kdump init script.
Dracut patch that introduces '--rebuild' option is accepted upstream
(commit id: 659dc319d950999f8d191a81fdc4d3114e9213de).
Signed-off-by: Mahesh Salgaonkar <mahesh(a)linux.vnet.ibm.com>
Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
---
kdumpctl | 47 +++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 2eb52a5..d58d64c 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -95,17 +95,46 @@ function save_core()
fi
}
-function rebuild_initrd()
+rebuild_fadump_initrd()
{
- if [ $dump_mode == "fadump" ]; then
- backup_default_initrd
+ if [ ! -s "$default_initrd" ]; then
+ echo "No default initrd found to rebuild for fadump support!"
+ return 1
+ fi
+ backup_default_initrd
+
+ echo "Rebuilding $default_initrd with fadump support"
+ $MKDUMPRD --rebuild $default_initrd --kver $kdump_kver
+ if [ $? != 0 ]; then
+ echo "mkdumprd: failed to make initrd with fadump support" >&2
+ restore_default_initrd
+ return 1
fi
+ return 0
+}
+
+rebuild_kdump_initrd()
+{
+ echo "Rebuilding $kdump_initrd"
$MKDUMPRD $kdump_initrd $kdump_kver
if [ $? != 0 ]; then
echo "mkdumprd: failed to make kdump initrd" >&2
return 1
fi
+
+ return 0
+}
+
+function rebuild_initrd()
+{
+ if [ $dump_mode == "fadump" ]; then
+ rebuild_fadump_initrd
+ else
+ rebuild_kdump_initrd
+ fi
+
+ return $?
}
#$1: the files to be checked with IFS=' '
@@ -163,6 +192,17 @@ handle_dump_mode_switch()
fi
}
+restore_default_initrd()
+{
+ # We have failed to rebuild initrd for fadump support.
+ # Restore the original default initrd.
+ if [ -f $default_initrd_bak ];then
+ echo "Restored default initrd"
+ mv $default_initrd_bak $default_initrd
+ sync
+ fi
+}
+
find_initrd_image_time()
{
image_time=0
@@ -300,7 +340,6 @@ function check_rebuild()
return 0
fi
- echo "Rebuilding $kdump_initrd"
rebuild_initrd
return $?
}