[PATCH] mkdumprd: force drop earlykdump module
by Kairui Song
earlykdump is not suppose to be loaded for a kdump initramfs, and user
may add it into dracut's config file so it will be included by default.
It will also make the image building always fail because earlykdump
actually detect if it's being used for kdump image and raise an error if
so.
In that case, we always force drop this module to avoid such problem.
Signed-off-by: Kairui Song <ryncsn(a)gmail.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index a6f7fe8..04668e4 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -37,7 +37,7 @@ is_wdt_addition_needed
[[ $? -eq 0 ]] && WDTCFG="-a watchdog"
extra_modules=""
-dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg" $WDTCFG)
+dracut_args=("--quiet" "--hostonly" "--hostonly-cmdline" "--hostonly-i18n" "--hostonly-mode" "strict" "-o" "plymouth dash resume ifcfg earlykdump" $WDTCFG)
OVERRIDE_RESETTABLE=0
add_dracut_arg() {
--
2.20.1
5 years, 3 months
[PATCH] earlykdump: fix kexec fails to load the early kdump kernel
by Lianbo Jiang
Early kdump always fails to load the vmlinuz-xxx after the 'binutils'
package has been installed, and outputs the following messages:
...
dracut-cmdline[309]: Cannot determine the file type of /boot/vmlinuz-4.18.0-51.el8.x86_64
dracut-cmdline[309]: kexec: failed to load early-kdump kernel
...
The reason is that the vmlinuz-xxx image is mistakenly stripped when
using dracut to generate the kdump initrd. Because dracut always find
all executable binary files to strip only if the 'binutils' package
is installed, otherwise it will skip the stripping.
Therefore, remove the executable permissions of the vmlinuz-xxx in
'${initrd}' in order to let dracut skip the mistakenly stripping.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
dracut-early-kdump-module-setup.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh
index 7613fbc..a004a49 100755
--- a/dracut-early-kdump-module-setup.sh
+++ b/dracut-early-kdump-module-setup.sh
@@ -41,4 +41,5 @@ install() {
prepare_kernel_initrd
inst_binary "$KDUMP_KERNEL"
inst_binary "$KDUMP_INITRD"
+ chmod -x "${initdir}/$KDUMP_KERNEL"
}
--
2.17.1
5 years, 3 months
[PATCH] earlykdump: Use kernel version specified by dracut if possible
by Kairui Song
There is currently a problem with earlykdump image building, when a user
is upgrading kernel, dracut will generate new initramfs for the new
kernel, and earlykdump will install currently running version of kernel
into the initramfs, and remain the version based kernel image naming
untouched. But after a reboot the new kernel is running, and it
will try to load the image corresponding to the new kernel version by
file naming.
This fix the problem by using unified installed kernel image and
initramfs name.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
dracut-early-kdump-module-setup.sh | 9 +++++++--
dracut-early-kdump.sh | 13 ++-----------
2 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh
index 7613fbc..cd84542 100755
--- a/dracut-early-kdump-module-setup.sh
+++ b/dracut-early-kdump-module-setup.sh
@@ -22,13 +22,18 @@ depends() {
prepare_kernel_initrd() {
KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
+
if [ -z "$KDUMP_KERNELVER" ]; then
kdump_kver=`uname -r`
else
kdump_kver=$KDUMP_KERNELVER
fi
+
KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${kdump_kver}${KDUMP_IMG_EXT}"
KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${kdump_kver}kdump.img"
+
+ KDUMP_KERNEL_INST_DEST="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
+ KDUMP_INITRD_INST_DEST="${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
}
install() {
@@ -39,6 +44,6 @@ install() {
inst_script "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
inst_hook cmdline 00 "$moddir/early-kdump.sh"
prepare_kernel_initrd
- inst_binary "$KDUMP_KERNEL"
- inst_binary "$KDUMP_INITRD"
+ inst_binary "$KDUMP_KERNEL" "$KDUMP_KERNEL_INST_DEST"
+ inst_binary "$KDUMP_INITRD" "$KDUMP_INITRD_INST_DEST"
}
diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh
index 34a9909..69a34eb 100755
--- a/dracut-early-kdump.sh
+++ b/dracut-early-kdump.sh
@@ -18,17 +18,8 @@ prepare_parameters()
EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
- #make early-kdump kernel string
- if [ -z "$KDUMP_KERNELVER" ]; then
- EARLY_KDUMP_KERNELVER=`uname -r`
- else
- EARLY_KDUMP_KERNELVER=$KDUMP_KERNELVER
- fi
-
- EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-${EARLY_KDUMP_KERNELVER}${KDUMP_IMG_EXT}"
-
- #make early-kdump initrd string
- EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-${EARLY_KDUMP_KERNELVER}kdump.img"
+ EARLY_KDUMP_KERNEL="${KDUMP_BOOTDIR}/${KDUMP_IMG}-earlykdump${KDUMP_IMG_EXT}"
+ EARLY_KDUMP_INITRD="${KDUMP_BOOTDIR}/initramfs-earlykdump.img"
}
early_kdump_load()
--
2.20.1
5 years, 3 months
[PATCH] Avoid falling into infinite loop restart when using a problematic system
by Lianbo Jiang
By default, early kdump reboots the system after capturing the vmcore.
If the problematic system is continuously crashing due to some issue
during early boot stage, the system may fall into infinite loop restart
like this:
boot -----> crash -----> early kdump (dump vmcore)
^ |
'.........(reboot).............'
But now, the system crash at early stage is only captured by early kdump,
and the rest is captured by normal kdump. That to say, when normal kdump
service starts, it will load it again and override early kdump. It is
helpful to control the logic of early kdump and normal kdump separately
in final action(it is called by kdump-capture.service). For example,
early kdump always passes the 'rd.earlykdump' to the second kernel when
early kdump is enabled, but normal kdump doesn't pass the 'rd.earlykdump'
to the second kernel at any time. So they can be distinguished in the
second kernel.
Signed-off-by: Lianbo Jiang <lijiang(a)redhat.com>
---
dracut-early-kdump.sh | 2 +-
dracut-kdump-error-handler.sh | 7 ++++++-
dracut-kdump.sh | 6 +++++-
kdump-lib-initramfs.sh | 16 +++++++++++++---
kdump.sysconfig | 2 +-
kdump.sysconfig.aarch64 | 2 +-
kdump.sysconfig.i386 | 2 +-
kdump.sysconfig.ppc64 | 2 +-
kdump.sysconfig.ppc64le | 2 +-
kdump.sysconfig.s390x | 2 +-
kdump.sysconfig.x86_64 | 2 +-
kdumpctl | 15 +++++++++++++--
12 files changed, 45 insertions(+), 15 deletions(-)
diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh
index 34a9909..a799dbf 100755
--- a/dracut-early-kdump.sh
+++ b/dracut-early-kdump.sh
@@ -58,7 +58,7 @@ early_kdump_load()
fi
$KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
- --command-line="$EARLY_KDUMP_CMDLINE" \
+ --command-line="$EARLY_KDUMP_CMDLINE rd.earlykdump" \
--initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL
if [ $? == 0 ]; then
echo "kexec: loaded early-kdump kernel"
diff --git a/dracut-kdump-error-handler.sh b/dracut-kdump-error-handler.sh
index 2f0f1d1..4f0e58c 100755
--- a/dracut-kdump-error-handler.sh
+++ b/dracut-kdump-error-handler.sh
@@ -1,5 +1,6 @@
#!/bin/sh
+. /lib/dracut-lib.sh
. /lib/kdump-lib-initramfs.sh
set -o pipefail
@@ -7,4 +8,8 @@ export PATH=$PATH:$KDUMP_SCRIPT_DIR
get_kdump_confs
do_default_action
-do_final_action
+if getargbool 0 rd.earlykdump; then
+ do_earlykdump_final_action
+else
+ do_final_action
+fi
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index b75c2a5..119b006 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -201,4 +201,8 @@ if [ $DUMP_RETVAL -ne 0 ]; then
exit 1
fi
-do_final_action
+if getargbool 0 rd.earlykdump; then
+ do_earlykdump_final_action
+else
+ do_final_action
+fi
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 7ba99b6..f95cbcf 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -6,7 +6,7 @@ KDUMP_PATH="/var/crash"
CORE_COLLECTOR=""
DEFAULT_CORE_COLLECTOR="makedumpfile -l --message-level 1 -d 31"
DMESG_COLLECTOR="/sbin/vmcore-dmesg"
-DEFAULT_ACTION="systemctl reboot -f"
+DEFAULT_ACTION=""
DATEDIR=`date +%Y-%m-%d-%T`
HOST_IP='127.0.0.1'
DUMP_INSTRUCTION=""
@@ -14,6 +14,7 @@ SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
KDUMP_SCRIPT_DIR="/kdumpscripts"
DD_BLKSIZE=512
FINAL_ACTION="systemctl reboot -f"
+EARLYKDUMP_FINAL_ACTION="systemctl poweroff"
KDUMP_CONF="/etc/kdump.conf"
KDUMP_PRE=""
KDUMP_POST=""
@@ -155,11 +156,20 @@ kdump_emergency_shell()
do_default_action()
{
- echo "Kdump: Executing default action $DEFAULT_ACTION"
- eval $DEFAULT_ACTION
+ if [ $DEFAULT_ACTION == "" ]; then
+ echo "Kdump: default action string is null."
+ else
+ echo "Kdump: Executing default action $DEFAULT_ACTION"
+ eval $DEFAULT_ACTION
+ fi
}
do_final_action()
{
eval $FINAL_ACTION
}
+
+do_earlykdump_final_action()
+{
+ eval $EARLYKDUMP_FINAL_ACTION
+}
diff --git a/kdump.sysconfig b/kdump.sysconfig
index ffe1df8..b011c1c 100644
--- a/kdump.sysconfig
+++ b/kdump.sysconfig
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.aarch64 b/kdump.sysconfig.aarch64
index 0a6b14c..b8b8865 100644
--- a/kdump.sysconfig.aarch64
+++ b/kdump.sysconfig.aarch64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.i386 b/kdump.sysconfig.i386
index 18c407e..b9a2835 100644
--- a/kdump.sysconfig.i386
+++ b/kdump.sysconfig.i386
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.ppc64 b/kdump.sysconfig.ppc64
index 55a01cc..e1ea9c6 100644
--- a/kdump.sysconfig.ppc64
+++ b/kdump.sysconfig.ppc64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.ppc64le b/kdump.sysconfig.ppc64le
index 55a01cc..e1ea9c6 100644
--- a/kdump.sysconfig.ppc64le
+++ b/kdump.sysconfig.ppc64le
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.s390x b/kdump.sysconfig.s390x
index b3aec3c..4c5fc00 100644
--- a/kdump.sysconfig.s390x
+++ b/kdump.sysconfig.s390x
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdump.sysconfig.x86_64 b/kdump.sysconfig.x86_64
index f269d02..3cccbfc 100644
--- a/kdump.sysconfig.x86_64
+++ b/kdump.sysconfig.x86_64
@@ -17,7 +17,7 @@ KDUMP_COMMANDLINE=""
# This variable lets us remove arguments from the current kdump commandline
# as taken from either KDUMP_COMMANDLINE above, or from /proc/cmdline
# NOTE: some arguments such as crashkernel will always be removed
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug quiet rd.earlykdump"
# This variable lets us append arguments to the current kdump commandline
# after processed by KDUMP_COMMANDLINE_REMOVE
diff --git a/kdumpctl b/kdumpctl
index fe6af22..a8fd53d 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -26,7 +26,7 @@ image_time=0
standard_kexec_args="-p"
# Some default values in case /etc/sysconfig/kdump doesn't include
-KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
+KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug rd.earlykdump"
if [ -f /etc/sysconfig/kdump ]; then
. /etc/sysconfig/kdump
@@ -942,6 +942,11 @@ check_default_config()
fi
}
+check_rd_earlykdump()
+{
+ egrep "rd.earlykdump" /proc/cmdline
+}
+
start()
{
check_dump_feasibility
@@ -969,7 +974,13 @@ start()
check_current_status
if [ $? == 0 ]; then
echo "Kdump already running: [WARNING]"
- return 0
+ check_rd_earlykdump
+ #if earlykdump loaded, it will stop and start.
+ if [ $? -eq 0 ]; then
+ stop
+ else
+ return 0
+ fi
fi
if check_ssh_config; then
--
2.17.1
5 years, 3 months
[PATCH] mkdumprd: allow spaces after 'path' config phrase with network dump setting
by Kazuhito Hagio
Without this patch, when there are two or more spaces after 'path'
configuration phrase with ssh or nfs setting, SAVE_PATH is set to
'/var/crash' in mkdumprd, and in most cases kdump service fails to
start by checking the /var/crash directory regardless of the path
value.
ssh kdump(a)192.168.122.1
path /kdump
^^
This behavior would be too sensitive and different from the other
configurations. With this patch, mkdumprd allows such spaces.
Signed-off-by: Kazuhito Hagio <k-hagio(a)ab.jp.nec.com>
---
mkdumprd | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mkdumprd b/mkdumprd
index a6f7fe8..aa0abfd 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -13,7 +13,7 @@ export IN_KDUMP=1
conf_file="/etc/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
-SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
+SAVE_PATH=$(awk '/^path/ {print $2}' $conf_file)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
# strip the duplicated "/"
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
--
2.18.0
5 years, 3 months