Add early kdump support in initramfs.
Kdump service starts too late, so early crashes will have no chance to get kdump kernel booting, this will cause crash information to be lost. It is necessary to add a dracut module in order to load crash kernel and initramfs as early as possible. You can provide "rd.early kdump" in grub commandline to enable, then the early kdump will load those files like the normal kdump, which is disabled by default. For the normal kdump service, it can check whether the early kdump has loaded the crash kernel and initramfs. It has no conflict with the early kdump. If you rebuild the new initramfs for early kdump, the new initramfs size will become large, because it will put the vmlinuz and kdump initramfs into the new initramfs. In addition, early kdump doesn't support fadump. Signed-off-by: Lianbo Jiang <lijiang@redhat.com> Reviewed-by: Kazuhito Hagio <khagio@redhat.com> Acked-by: Dave Young <dyoung@redhat.com>
This commit is contained in:
parent
b1fbeebd08
commit
1704064885
44
dracut-early-kdump-module-setup.sh
Executable file
44
dracut-early-kdump-module-setup.sh
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
. /etc/sysconfig/kdump
|
||||||
|
. /lib/kdump/kdump-lib.sh
|
||||||
|
|
||||||
|
KDUMP_KERNEL=""
|
||||||
|
KDUMP_INITRD=""
|
||||||
|
|
||||||
|
check() {
|
||||||
|
if [ ! -f /etc/sysconfig/kdump ] || [ ! -f /lib/kdump/kdump-lib.sh ]\
|
||||||
|
|| [ -n "${IN_KDUMP}" ]
|
||||||
|
then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
return 255
|
||||||
|
}
|
||||||
|
|
||||||
|
depends() {
|
||||||
|
echo "base shutdown"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
}
|
||||||
|
|
||||||
|
install() {
|
||||||
|
inst_multiple tail find cut dirname hexdump
|
||||||
|
inst_simple "/etc/sysconfig/kdump"
|
||||||
|
inst_binary "/usr/sbin/kexec"
|
||||||
|
inst_binary "/usr/bin/gawk" "/usr/bin/awk"
|
||||||
|
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"
|
||||||
|
}
|
84
dracut-early-kdump.sh
Executable file
84
dracut-early-kdump.sh
Executable file
@ -0,0 +1,84 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
KEXEC=/sbin/kexec
|
||||||
|
standard_kexec_args="-p"
|
||||||
|
|
||||||
|
EARLY_KDUMP_INITRD=""
|
||||||
|
EARLY_KDUMP_KERNEL=""
|
||||||
|
EARLY_KDUMP_CMDLINE=""
|
||||||
|
EARLY_KDUMP_KERNELVER=""
|
||||||
|
EARLY_KEXEC_ARGS=""
|
||||||
|
|
||||||
|
. /etc/sysconfig/kdump
|
||||||
|
. /lib/dracut-lib.sh
|
||||||
|
. /lib/kdump-lib.sh
|
||||||
|
|
||||||
|
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_load()
|
||||||
|
{
|
||||||
|
check_kdump_feasibility
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if is_fadump_capable; then
|
||||||
|
echo "WARNING: early kdump doesn't support fadump."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_current_kdump_status
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
prepare_parameters
|
||||||
|
|
||||||
|
EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
|
||||||
|
|
||||||
|
if is_secure_boot_enforced; then
|
||||||
|
echo "Secure Boot is enabled. Using kexec file based syscall."
|
||||||
|
EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s"
|
||||||
|
fi
|
||||||
|
|
||||||
|
$KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
|
||||||
|
--command-line="$EARLY_KDUMP_CMDLINE" \
|
||||||
|
--initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL
|
||||||
|
if [ $? == 0 ]; then
|
||||||
|
echo "kexec: loaded early-kdump kernel"
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
echo "kexec: failed to load early-kdump kernel"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
set_early_kdump()
|
||||||
|
{
|
||||||
|
if getargbool 0 rd.earlykdump; then
|
||||||
|
echo "early-kdump is enabled."
|
||||||
|
early_kdump_load
|
||||||
|
else
|
||||||
|
echo "early-kdump is disabled."
|
||||||
|
fi
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
set_early_kdump
|
54
early-kdump-howto.txt
Normal file
54
early-kdump-howto.txt
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
Early Kdump HOWTO
|
||||||
|
|
||||||
|
Introduction
|
||||||
|
|
||||||
|
Kdump service starts too late, so early crashes will have no chance to get
|
||||||
|
kdump kernel booting, this will cause crash information to be lost. It is
|
||||||
|
necessary to add a dracut module in order to load crash kernel and initramfs
|
||||||
|
as early as possible. You can provide "rd.earlykdump" in grub commandline
|
||||||
|
to enable, then the early kdump will load those files like the normal kdump,
|
||||||
|
which is disabled by default.
|
||||||
|
|
||||||
|
For the normal kdump service, it can check whether the early kdump has loaded
|
||||||
|
the crash kernel and initramfs. It has no conflict with the early kdump.
|
||||||
|
|
||||||
|
How to configure early kdump:
|
||||||
|
|
||||||
|
We assume if you're reading this document, you should already have kexec-tools
|
||||||
|
installed.
|
||||||
|
|
||||||
|
You can rebuild the initramfs with earlykdump support with below steps:
|
||||||
|
1. start kdump service to make sure kdump initramfs is created.
|
||||||
|
# systemctl start kdump
|
||||||
|
|
||||||
|
2. rebuild system initramfs with earlykdump support.
|
||||||
|
# dracut --add earlykdump
|
||||||
|
|
||||||
|
3. add rd.earlykdump in grub kernel command line.
|
||||||
|
|
||||||
|
Note: earlykdump initramfs size will be large because it includes vmlinuz and
|
||||||
|
kdump initramfs. And for step 2 if you are sure to overwrite system initramfs
|
||||||
|
you can backup the original initramfs and use "--force" option.
|
||||||
|
|
||||||
|
After making said changes, reboot your system to take effect. Of course, if you
|
||||||
|
want to disable early kdump, you can simply remove "rd.earlykdump" from kernel
|
||||||
|
boot parameters in grub, and reboot system like above.
|
||||||
|
|
||||||
|
Once the boot is completed, you can check the status of the early kdump support
|
||||||
|
on the command prompt:
|
||||||
|
|
||||||
|
# journalctl -x|grep early-kdump
|
||||||
|
|
||||||
|
Then, you will see some useful logs, for exapmle:
|
||||||
|
|
||||||
|
1. if early kdump is successful.
|
||||||
|
Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: early-kdump is enabled.
|
||||||
|
Mar 09 09:57:56 localhost.localdomain dracut-cmdline[190]: kexec: loaded early-
|
||||||
|
kdump kernel
|
||||||
|
|
||||||
|
2. if early kdump is disabled.
|
||||||
|
Mar 09 10:02:47 localhost.localdomain dracut-cmdline[189]: early-kdump is disabled.
|
||||||
|
|
||||||
|
Limitation
|
||||||
|
|
||||||
|
At present, early kdump doesn't support fadump.
|
@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh
|
|||||||
Source25: kdump.sysconfig.ppc64le
|
Source25: kdump.sysconfig.ppc64le
|
||||||
Source26: kdumpctl.8
|
Source26: kdumpctl.8
|
||||||
Source27: live-image-kdump-howto.txt
|
Source27: live-image-kdump-howto.txt
|
||||||
|
Source28: early-kdump-howto.txt
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# These are sources for mkdumpramfs
|
# These are sources for mkdumpramfs
|
||||||
@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service
|
|||||||
Source105: dracut-kdump-error-handler.service
|
Source105: dracut-kdump-error-handler.service
|
||||||
Source106: dracut-kdump-capture.service
|
Source106: dracut-kdump-capture.service
|
||||||
Source107: dracut-kdump-emergency.target
|
Source107: dracut-kdump-emergency.target
|
||||||
|
Source108: dracut-early-kdump.sh
|
||||||
|
Source109: dracut-early-kdump-module-setup.sh
|
||||||
|
|
||||||
Requires(post): systemd-units
|
Requires(post): systemd-units
|
||||||
Requires(preun): systemd-units
|
Requires(preun): systemd-units
|
||||||
@ -132,6 +135,7 @@ rm -f kexec-tools.spec.in
|
|||||||
cp %{SOURCE10} .
|
cp %{SOURCE10} .
|
||||||
cp %{SOURCE21} .
|
cp %{SOURCE21} .
|
||||||
cp %{SOURCE27} .
|
cp %{SOURCE27} .
|
||||||
|
cp %{SOURCE28} .
|
||||||
|
|
||||||
make
|
make
|
||||||
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
|
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
|
||||||
@ -190,6 +194,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT
|
|||||||
%find_lang kdump-anaconda-addon
|
%find_lang kdump-anaconda-addon
|
||||||
|
|
||||||
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
|
%define remove_dracut_prefix() %(echo -n %1|sed 's/.*dracut-//g')
|
||||||
|
%define remove_dracut_early_kdump_prefix() %(echo -n %1|sed 's/.*dracut-early-kdump-//g')
|
||||||
|
|
||||||
# deal with dracut modules
|
# deal with dracut modules
|
||||||
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
|
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase
|
||||||
@ -203,6 +208,11 @@ cp %{SOURCE106} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpb
|
|||||||
cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}}
|
cp %{SOURCE107} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE107}}
|
||||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}}
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE100}}
|
||||||
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase/%{remove_dracut_prefix %{SOURCE101}}
|
||||||
|
mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump
|
||||||
|
cp %{SOURCE108} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
|
||||||
|
cp %{SOURCE109} $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
|
||||||
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_prefix %{SOURCE108}}
|
||||||
|
chmod 755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99earlykdump/%{remove_dracut_early_kdump_prefix %{SOURCE109}}
|
||||||
|
|
||||||
|
|
||||||
%define dracutlibdir %{_prefix}/lib/dracut
|
%define dracutlibdir %{_prefix}/lib/dracut
|
||||||
@ -301,6 +311,7 @@ done
|
|||||||
%license COPYING
|
%license COPYING
|
||||||
%doc TODO
|
%doc TODO
|
||||||
%doc kexec-kdump-howto.txt
|
%doc kexec-kdump-howto.txt
|
||||||
|
%doc early-kdump-howto.txt
|
||||||
%doc kdump-in-cluster-environment.txt
|
%doc kdump-in-cluster-environment.txt
|
||||||
%doc live-image-kdump-howto.txt
|
%doc live-image-kdump-howto.txt
|
||||||
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
|
%ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
|
||||||
|
Loading…
Reference in New Issue
Block a user