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. Once kdump (fadump) initrd is successfully rebuild from the
default initrd image, this patch replaces the default initrd image
with the newly built initrd.
check_config()
-> rebuild_initrd()
Rebuild default initrd with fadump support
-> handle_fadump_initrd()
Replace default with initrd built for fadump.
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 posted upstream,
awaiting approval. Link for reference:
http://www.spinics.net/lists/linux-initramfs/msg03495.html
Signed-off-by: Mahesh Salgaonkar <mahesh(a)linux.vnet.ibm.com>
Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
---
kdumpctl | 36 +++++++++++++++++++++++++++++-------
1 file changed, 29 insertions(+), 7 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index f4760b5..976dfe8 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -72,13 +72,25 @@ function save_core()
function rebuild_initrd()
{
if is_fadump_capable; then
+ if [ ! -s "$default_initrd" ]; then
+ echo "No default initrd found to rebuild for fadump support!"
+ return 1
+ fi
backup_default_initrd
- fi
-
- $MKDUMPRD $kdump_initrd $kdump_kver
- if [ $? != 0 ]; then
- echo "mkdumprd: failed to make kdump initrd" >&2
- return 1
+ 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
+ else
+ echo "Rebuilding $kdump_initrd"
+ $MKDUMPRD $kdump_initrd $kdump_kver
+ if [ $? != 0 ]; then
+ echo "mkdumprd: failed to make kdump initrd" >&2
+ return 1
+ fi
fi
}
@@ -138,6 +150,17 @@ function check_fadump()
fi
}
+function 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
+}
+
function find_initrd_image_time()
{
image_time=0
@@ -259,7 +282,6 @@ function check_rebuild()
return 0
fi
- echo "Rebuilding $kdump_initrd"
rebuild_initrd
return $?
}