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.
Finally, we move some common functions from kdumpctl to kdump-lib.sh, the functions could be used in other modules, such as early kdump. It has no bad effect.
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as tail, find, dirname, hexdump, cut. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.kdump-lib.sh -add comment for some functions. -modify check_boot_dir() function. -modify code style. (*) 4.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
Lianbo Jiang (2): move some common functions from kdumpctl to kdump-lib.sh Add early kdump support in initramfs.
dracut-early-kdump-module-setup.sh | 44 ++++++++ dracut-early-kdump.sh | 84 ++++++++++++++ early-kdump-howto.txt | 50 +++++++++ kdump-lib.sh | 217 +++++++++++++++++++++++++++++++++++++ kdumpctl | 206 +---------------------------------- kexec-tools.spec | 11 ++ 6 files changed, 409 insertions(+), 203 deletions(-) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
we move some common functions from kdumpctl to kdump-lib.sh, the functions could be used in other modules, such as early kdump. It has no bad effect.
Signed-off-by: Lianbo Jiang lijiang@redhat.com --- Some changes based the patch v3&v4&v5: -1.kdump-lib.sh -add comment for some functions. -modify check_boot_dir() function. -modify code style (*)
kdump-lib.sh | 217 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ kdumpctl | 206 +------------------------------------------------------- 2 files changed, 220 insertions(+), 203 deletions(-)
diff --git a/kdump-lib.sh b/kdump-lib.sh index d981c4f..39d44ca 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -485,3 +485,220 @@ get_dracut_args_target() { echo $1 | grep "--mount" | sed "s/.*--mount .(.*)/\1/" | cut -d' ' -f1 } + +check_crash_mem_reserved() +{ + local mem_reserved + + mem_reserved=$(cat /sys/kernel/kexec_crash_size) + if [ $mem_reserved -eq 0 ]; then + echo "No memory reserved for crash kernel" + return 1 + fi + + return 0 +} + +check_kdump_feasibility() +{ + if [ ! -e /sys/kernel/kexec_crash_loaded ]; then + echo "Kdump is not supported on this kernel" + return 1 + fi + check_crash_mem_reserved + return $? +} + +check_current_kdump_status() +{ + if [ ! -f /sys/kernel/kexec_crash_loaded ];then + echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" + return 1 + fi + + rc=`cat /sys/kernel/kexec_crash_loaded` + if [ $rc == 1 ]; then + return 0 + else + return 1 + fi +} + +# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] +# Remove a list of kernel parameters from a given kernel cmdline and print the result. +# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. +remove_cmdline_param() +{ + local cmdline=$1 + shift + + for arg in $@; do + cmdline=`echo $cmdline | \ + sed -e "s/\b$arg=[^ ]*//g" \ + -e "s/^$arg\b//g" \ + -e "s/[[:space:]]$arg\b//g" \ + -e "s/\s+/ /g"` + done + echo $cmdline +} + +# +# This function returns the "apicid" of the boot +# cpu (cpu 0) if present. +# +get_bootcpu_apicid() +{ + awk ' \ + BEGIN { CPU = "-1"; } \ + $1=="processor" && $2==":" { CPU = $NF; } \ + CPU=="0" && /^apicid/ { print $NF; } \ + ' \ + /proc/cpuinfo +} + +# +# append_cmdline <kernel cmdline> <parameter name> <parameter value> +# This function appends argument "$2=$3" to string ($1) if not already present. +# +append_cmdline() +{ + local cmdline=$1 + local newstr=${cmdline/$2/""} + + # unchanged str implies argument wasn't there + if [ "$cmdline" == "$newstr" ]; then + cmdline="${cmdline} ${2}=${3}" + fi + + echo $cmdline +} + +# This function check iomem and determines if we have more than +# 4GB of ram available. Returns 1 if we do, 0 if we dont +need_64bit_headers() +{ + return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ + print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` +} + +# Check if secure boot is being enforced. +# +# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and +# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four +# bytes are the attributes associated with the variable and can safely be +# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot +# is 1 and SetupMode is 0, then secure boot is being enforced. +# +# Assume efivars is mounted at /sys/firmware/efi/efivars. +is_secure_boot_enforced() +{ + local secure_boot_file setup_mode_file + local secure_boot_byte setup_mode_byte + + secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) + setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) + + if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then + secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) + setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) + + if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then + return 0 + fi + fi + + return 1 +} + +# +# prepare_kexec_args <kexec args> +# This function prepares kexec argument. +# +prepare_kexec_args() +{ + local kexec_args=$1 + local found_elf_args + + ARCH=`uname -m` + if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] + then + need_64bit_headers + if [ $? == 1 ] + then + found_elf_args=`echo $kexec_args | grep elf32-core-headers` + if [ -n "$found_elf_args" ] + then + echo -n "Warning: elf32-core-headers overrides correct elf64 setting" + echo + else + kexec_args="$kexec_args --elf64-core-headers" + fi + else + found_elf_args=`echo $kexec_args | grep elf64-core-headers` + if [ -z "$found_elf_args" ] + then + kexec_args="$kexec_args --elf32-core-headers" + fi + fi + fi + echo $kexec_args +} + +check_boot_dir() +{ + local kdump_bootdir=$1 + #If user specify a boot dir for kdump kernel, let's use it. Otherwise + #check whether it's a atomic host. If yes parse the subdirectory under + #/boot; If not just find it under /boot. + if [ -n "$kdump_bootdir" ]; then + echo "$kdump_bootdir" + return + fi + + if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then + kdump_bootdir="/boot" + else + eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) + kdump_bootdir="/boot"$(dirname $BOOT_IMAGE) + fi + echo $kdump_bootdir +} + +# +# prepare_cmdline <commandline> <commandline remove> <commandline append> +# This function performs a series of edits on the command line. +# Store the final result in global $KDUMP_COMMANDLINE. +prepare_cmdline() +{ + local cmdline id + + if [ -z "$1" ]; then + cmdline=$(cat /proc/cmdline) + else + cmdline="$1" + fi + + # These params should always be removed + cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) + # These params can be removed configurably + cmdline=$(remove_cmdline_param "$cmdline" "$2") + + # Always remove "root=X", as we now explicitly generate all kinds + # of dump target mount information including root fs. + # + # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares + # about it(e.g. for debug purpose), then can pass "root=X" using + # KDUMP_COMMANDLINE_APPEND. + cmdline=$(remove_cmdline_param "$cmdline" root) + + # With the help of "--hostonly-cmdline", we can avoid some interitage. + cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) + + cmdline="${cmdline} $3" + + id=$(get_bootcpu_apicid) + if [ ! -z ${id} ] ; then + cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) + fi + echo ${cmdline} +} diff --git a/kdumpctl b/kdumpctl index 4280e7e..afbe96e 100755 --- a/kdumpctl +++ b/kdumpctl @@ -62,93 +62,6 @@ determine_dump_mode() fi }
-# remove_cmdline_param <kernel cmdline> <param1> [<param2>] ... [<paramN>] -# Remove a list of kernel parameters from a given kernel cmdline and print the result. -# For each "arg" in the removing params list, "arg" and "arg=xxx" will be removed if exists. -remove_cmdline_param() -{ - local cmdline=$1 - shift - - for arg in $@; do - cmdline=`echo $cmdline | \ - sed -e "s/\b$arg=[^ ]*//g" \ - -e "s/^$arg\b//g" \ - -e "s/[[:space:]]$arg\b//g" \ - -e "s/\s+/ /g"` - done - echo $cmdline -} - -# -# This function returns the "apicid" of the boot -# cpu (cpu 0) if present. -# -get_bootcpu_apicid() -{ - awk ' \ - BEGIN { CPU = "-1"; } \ - $1=="processor" && $2==":" { CPU = $NF; } \ - CPU=="0" && /^apicid/ { print $NF; } \ - ' \ - /proc/cpuinfo -} - -# -# This function appends argument "$2=$3" to string ($1) if not already present. -# -append_cmdline() -{ - local cmdline=$1 - local newstr=${cmdline/$2/""} - - # unchanged str implies argument wasn't there - if [ "$cmdline" == "$newstr" ]; then - cmdline="${cmdline} ${2}=${3}" - fi - - echo $cmdline -} - -# This function performs a series of edits on the command line. -# Store the final result in global $KDUMP_COMMANDLINE. -prepare_cmdline() -{ - local cmdline id - - if [ -z "$KDUMP_COMMANDLINE" ]; then - cmdline=$(cat /proc/cmdline) - else - cmdline=${KDUMP_COMMANDLINE} - fi - - # These params should always be removed - cmdline=$(remove_cmdline_param "$cmdline" crashkernel panic_on_warn) - # These params can be removed configurably - cmdline=$(remove_cmdline_param "$cmdline" ${KDUMP_COMMANDLINE_REMOVE}) - - # Always remove "root=X", as we now explicitly generate all kinds - # of dump target mount information including root fs. - # - # We do this before KDUMP_COMMANDLINE_APPEND, if one really cares - # about it(e.g. for debug purpose), then can pass "root=X" using - # KDUMP_COMMANDLINE_APPEND. - cmdline=$(remove_cmdline_param "$cmdline" root) - - # With the help of "--hostonly-cmdline", we can avoid some interitage. - cmdline=$(remove_cmdline_param "$cmdline" rd.lvm.lv rd.luks.uuid rd.dm.uuid rd.md.uuid fcoe) - - cmdline="${cmdline} ${KDUMP_COMMANDLINE_APPEND}" - - id=$(get_bootcpu_apicid) - if [ ! -z ${id} ] ; then - cmdline=$(append_cmdline "${cmdline}" disable_cpu_apicid ${id}) - fi - - KDUMP_COMMANDLINE=$cmdline -} - - save_core() { coredir="/var/crash/`date +"%Y-%m-%d-%H:%M"`" @@ -361,21 +274,6 @@ get_pcs_cluster_modified_files() echo $modified_files }
-check_boot_dir() -{ - #If user specify a boot dir for kdump kernel, let's use it. Otherwise - #check whether it's a atomic host. If yes parse the subdirectory under - #/boot; If not just find it under /boot. - [ -n "$KDUMP_BOOTDIR" ] && return - - if ! is_atomic || [ "$(uname -m)" = "s390x" ]; then - KDUMP_BOOTDIR="/boot" - else - eval $(cat /proc/cmdline| grep "BOOT_IMAGE" | cut -d' ' -f1) - KDUMP_BOOTDIR="/boot"$(dirname $BOOT_IMAGE) - fi -} - setup_initrd() { DEFAULT_INITRD="${KDUMP_BOOTDIR}/initramfs-`uname -r`.img" @@ -596,7 +494,7 @@ check_rebuild() local _force_no_rebuild force_no_rebuild="0" local ret system_modified="0"
- check_boot_dir + KDUMP_BOOTDIR=$(check_boot_dir "${KDUMP_BOOTDIR}")
if [ -z "$KDUMP_KERNELVER" ]; then kdump_kver=`uname -r` @@ -686,44 +584,13 @@ check_rebuild() return $? }
-# This function check iomem and determines if we have more than -# 4GB of ram available. Returns 1 if we do, 0 if we dont -need_64bit_headers() -{ - return `tail -n 1 /proc/iomem | awk '{ split ($1, r, "-"); \ - print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` -} - # Load the kdump kernel specified in /etc/sysconfig/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. load_kdump() { - ARCH=`uname -m` - if [ "$ARCH" == "i686" -o "$ARCH" == "i386" ] - then - - need_64bit_headers - if [ $? == 1 ] - then - FOUND_ELF_ARGS=`echo $KEXEC_ARGS | grep elf32-core-headers` - if [ -n "$FOUND_ELF_ARGS" ] - then - echo -n "Warning: elf32-core-headers overrides correct elf64 setting" - echo - else - KEXEC_ARGS="$KEXEC_ARGS --elf64-core-headers" - fi - else - FOUND_ELF_ARGS=`echo $KEXEC_ARGS | grep elf64-core-headers` - if [ -z "$FOUND_ELF_ARGS" ] - then - KEXEC_ARGS="$KEXEC_ARGS --elf32-core-headers" - fi - fi - fi - - prepare_cmdline + KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}") + KDUMP_COMMANDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
# For secureboot enabled machines, use new kexec file based syscall. # Old syscall will always fail as it does not have capability to @@ -850,21 +717,6 @@ check_current_fadump_status() return 1 }
-check_current_kdump_status() -{ - if [ ! -f /sys/kernel/kexec_crash_loaded ];then - echo "Perhaps CONFIG_CRASH_DUMP is not enabled in kernel" - return 1 - fi - - rc=`cat /sys/kernel/kexec_crash_loaded` - if [ $rc == 1 ]; then - return 0 - else - return 1 - fi -} - check_current_status() { if [ $DEFAULT_DUMP_MODE == "fadump" ]; then @@ -974,58 +826,6 @@ selinux_relabel() done }
-# Check if secure boot is being enforced. -# -# Per Peter Jones, we need check efivar SecureBoot-$(the UUID) and -# SetupMode-$(the UUID), they are both 5 bytes binary data. The first four -# bytes are the attributes associated with the variable and can safely be -# ignored, the last bytes are one-byte true-or-false variables. If SecureBoot -# is 1 and SetupMode is 0, then secure boot is being enforced. -# -# Assume efivars is mounted at /sys/firmware/efi/efivars. -is_secure_boot_enforced() -{ - local secure_boot_file setup_mode_file - local secure_boot_byte setup_mode_byte - - secure_boot_file=$(find /sys/firmware/efi/efivars -name SecureBoot-* 2>/dev/null) - setup_mode_file=$(find /sys/firmware/efi/efivars -name SetupMode-* 2>/dev/null) - - if [ -f "$secure_boot_file" ] && [ -f "$setup_mode_file" ]; then - secure_boot_byte=$(hexdump -v -e '/1 "%d\ "' $secure_boot_file|cut -d' ' -f 5) - setup_mode_byte=$(hexdump -v -e '/1 "%d\ "' $setup_mode_file|cut -d' ' -f 5) - - if [ "$secure_boot_byte" = "1" ] && [ "$setup_mode_byte" = "0" ]; then - return 0 - fi - fi - - return 1 -} - -check_crash_mem_reserved() -{ - local mem_reserved - - mem_reserved=$(cat /sys/kernel/kexec_crash_size) - if [ $mem_reserved -eq 0 ]; then - echo "No memory reserved for crash kernel" - return 1 - fi - - return 0 -} - -check_kdump_feasibility() -{ - if [ ! -e /sys/kernel/kexec_crash_loaded ]; then - echo "Kdump is not supported on this kernel" - return 1 - fi - check_crash_mem_reserved - return $? -} - check_fence_kdump_config() { local hostname=`hostname`
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 --- Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as find, cut, dirname, hexdump, tail. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++++++++++ early-kdump-howto.txt | 50 +++++++++++++++++++++++ kexec-tools.spec | 11 +++++ 4 files changed, 189 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..ee8038f --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -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 split + 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" +} diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -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 diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..07da8eb --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,50 @@ +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. + +For early kdump, if you need to rebuild the initramfs, please manually execute +dracut command: + # dracut --add earlykdump --force + +By the way, 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. + +Next up, we need to add "rd.earlykdump" to enable early kdump in grub. 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. diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..303b971 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt
####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -136,6 +139,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} .
make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -194,6 +198,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon
%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 mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -207,6 +212,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}} 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}} +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 @@ -305,6 +315,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
Kazu, Bhupesh, do you have more comments?
On 05/07/18 at 09:28am, Lianbo Jiang wrote:
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
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as find, cut, dirname, hexdump, tail. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++++++++++ early-kdump-howto.txt | 50 +++++++++++++++++++++++ kexec-tools.spec | 11 +++++ 4 files changed, 189 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..ee8038f --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -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 split
- 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"
+} diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -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 diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..07da8eb --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,50 @@ +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.
+For early kdump, if you need to rebuild the initramfs, please manually execute +dracut command:
- # dracut --add earlykdump --force
+By the way, 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.
--force can be dropped, so if only one want to overwrite the default initramfs one can use --force. Looks better to mention it like:
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.
+Next up, we need to add "rd.earlykdump" to enable early kdump in grub. 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. diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..303b971 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt
####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -136,6 +139,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} .
make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -194,6 +198,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon
%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 mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -207,6 +212,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}} 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}} +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 @@ -305,6 +315,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -- 2.9.5 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org
在 2018年05月21日 16:37, Dave Young 写道:
Kazu, Bhupesh, do you have more comments?
On 05/07/18 at 09:28am, Lianbo Jiang wrote:
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
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as find, cut, dirname, hexdump, tail. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++++++++++ early-kdump-howto.txt | 50 +++++++++++++++++++++++ kexec-tools.spec | 11 +++++ 4 files changed, 189 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..ee8038f --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -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 split
- 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"
+} diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -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 diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..07da8eb --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,50 @@ +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.
+For early kdump, if you need to rebuild the initramfs, please manually execute +dracut command:
- # dracut --add earlykdump --force
+By the way, 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.
--force can be dropped, so if only one want to overwrite the default initramfs one can use --force. Looks better to mention it like:
You can rebuild the initramfs with earlykdump support with below steps:
start kdump service to make sure kdump initramfs is created. # systemctl start kdump
rebuild system initramfs with earlykdump support # dracut --add earlykdump
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.
Thank you, Dave. It looks like the description is more clear, the document will be updated.
Thanks. Lianbo
+Next up, we need to add "rd.earlykdump" to enable early kdump in grub. 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. diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..303b971 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt
####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -136,6 +139,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} .
make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -194,6 +198,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon
%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 mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -207,6 +212,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}} 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}} +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 @@ -305,6 +315,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 -- 2.9.5 _______________________________________________ kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org
Hi Lianbo,
Sorry for the long delay.
On 5/6/2018 9:28 PM, Lianbo Jiang wrote:
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
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as find, cut, dirname, hexdump, tail. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++++++++++ early-kdump-howto.txt | 50 +++++++++++++++++++++++ kexec-tools.spec | 11 +++++ 4 files changed, 189 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..ee8038f --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -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"
I overlooked this, but is the 'shutdown' module needed?
- 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 split
I can't find the 'split' command in the source code. Is it needed? (I can see a split() function of awk instead.)
Thanks, Kazu
- 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"> +}
diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -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 diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..07da8eb --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,50 @@ +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.
+For early kdump, if you need to rebuild the initramfs, please manually execute +dracut command:
- # dracut --add earlykdump --force
+By the way, 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.
+Next up, we need to add "rd.earlykdump" to enable early kdump in grub. 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. diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..303b971 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt
####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -136,6 +139,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} .
make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -194,6 +198,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon
%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 mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -207,6 +212,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}} 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}} +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 @@ -305,6 +315,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
在 2018年05月21日 23:40, Kazuhito Hagio 写道:
Hi Lianbo,
Sorry for the long delay.
Thank you, Kazu. It's ok, never mind.
Lianbo
On 5/6/2018 9:28 PM, Lianbo Jiang wrote:
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
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as find, cut, dirname, hexdump, tail. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
dracut-early-kdump-module-setup.sh | 44 ++++++++++++++++++++ dracut-early-kdump.sh | 84 ++++++++++++++++++++++++++++++++++++++ early-kdump-howto.txt | 50 +++++++++++++++++++++++ kexec-tools.spec | 11 +++++ 4 files changed, 189 insertions(+) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
diff --git a/dracut-early-kdump-module-setup.sh b/dracut-early-kdump-module-setup.sh new file mode 100755 index 0000000..ee8038f --- /dev/null +++ b/dracut-early-kdump-module-setup.sh @@ -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"
I overlooked this, but is the 'shutdown' module needed?
May be it really needs, because the 'shutdown' module will install some basic commands, such as 'reboot'...
Thanks. Lianbo
- 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 split
I can't find the 'split' command in the source code. Is it needed? (I can see a split() function of awk instead.)
Thank you, Kazu. The 'split' command does't need, it will be deleted.
Lianbo
Thanks, Kazu
- 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"> +}
diff --git a/dracut-early-kdump.sh b/dracut-early-kdump.sh new file mode 100755 index 0000000..34a9909 --- /dev/null +++ b/dracut-early-kdump.sh @@ -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 diff --git a/early-kdump-howto.txt b/early-kdump-howto.txt new file mode 100644 index 0000000..07da8eb --- /dev/null +++ b/early-kdump-howto.txt @@ -0,0 +1,50 @@ +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.
+For early kdump, if you need to rebuild the initramfs, please manually execute +dracut command:
- # dracut --add earlykdump --force
+By the way, 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.
+Next up, we need to add "rd.earlykdump" to enable early kdump in grub. 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. diff --git a/kexec-tools.spec b/kexec-tools.spec index f04527c..303b971 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -29,6 +29,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: early-kdump-howto.txt
####################################### # These are sources for mkdumpramfs @@ -42,6 +43,8 @@ Source104: dracut-kdump-emergency.service Source105: dracut-kdump-error-handler.service Source106: dracut-kdump-capture.service Source107: dracut-kdump-emergency.target +Source108: dracut-early-kdump.sh +Source109: dracut-early-kdump-module-setup.sh
Requires(post): systemd-units Requires(preun): systemd-units @@ -136,6 +139,7 @@ rm -f kexec-tools.spec.in cp %{SOURCE10} . cp %{SOURCE21} . cp %{SOURCE27} . +cp %{SOURCE28} .
make %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64 @@ -194,6 +198,7 @@ make -C kdump-anaconda-addon install DESTDIR=$RPM_BUILD_ROOT %find_lang kdump-anaconda-addon
%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 mkdir -p -m755 $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/99kdumpbase @@ -207,6 +212,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}} 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}} +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 @@ -305,6 +315,7 @@ done %license COPYING %doc TODO %doc kexec-kdump-howto.txt +%doc early-kdump-howto.txt %doc kdump-in-cluster-environment.txt %doc live-image-kdump-howto.txt %ifarch %{ix86} x86_64 ppc64 s390x ppc64le aarch64
kexec mailing list -- kexec@lists.fedoraproject.org To unsubscribe send an email to kexec-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org/...
cc Kazu & Dave & Bhupesh. Can you help to review this patch?
Thanks. Lianbo 在 2018年05月07日 09:28, Lianbo Jiang 写道:
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.
Finally, we move some common functions from kdumpctl to kdump-lib.sh, the functions could be used in other modules, such as early kdump. It has no bad effect.
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as tail, find, dirname, hexdump, cut. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.kdump-lib.sh -add comment for some functions. -modify check_boot_dir() function. -modify code style. (*) 4.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
Lianbo Jiang (2): move some common functions from kdumpctl to kdump-lib.sh Add early kdump support in initramfs.
dracut-early-kdump-module-setup.sh | 44 ++++++++ dracut-early-kdump.sh | 84 ++++++++++++++ early-kdump-howto.txt | 50 +++++++++ kdump-lib.sh | 217 +++++++++++++++++++++++++++++++++++++ kdumpctl | 206 +---------------------------------- kexec-tools.spec | 11 ++ 6 files changed, 409 insertions(+), 203 deletions(-) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt
Hello Lianbo,
On Wed, May 9, 2018 at 12:08 PM, lijiang lijiang@redhat.com wrote:
cc Kazu & Dave & Bhupesh. Can you help to review this patch?
Sorry for the delay. I will find some time today to review this patchset and come back with my review comments.
Thanks. Lianbo
Regards, Bhupesh
在 2018年05月07日 09:28, Lianbo Jiang 写道:
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.
Finally, we move some common functions from kdumpctl to kdump-lib.sh, the functions could be used in other modules, such as early kdump. It has no bad effect.
Some changes based the patch v3&v4&v5: 1.dracut-early-kdump-module-setup.sh -Introduce some variables to parse parameters for kernel commandline and initrd. -It will use "dracut --add earlykdump --force" to rebuild the new initramfs for the early kdump. -install some commands, such as tail, find, dirname, hexdump, cut. (*) -modify code style. (*) 2.early-kdump-howto.txt -update the usage about the early kdump. 3.kdump-lib.sh -add comment for some functions. -modify check_boot_dir() function. -modify code style. (*) 4.dracut-early-kdump.sh -modify prepare_parameters() function and handle the case with a "KDUMP_KERNELVER" setting.
Lianbo Jiang (2): move some common functions from kdumpctl to kdump-lib.sh Add early kdump support in initramfs.
dracut-early-kdump-module-setup.sh | 44 ++++++++ dracut-early-kdump.sh | 84 ++++++++++++++ early-kdump-howto.txt | 50 +++++++++ kdump-lib.sh | 217 +++++++++++++++++++++++++++++++++++++ kdumpctl | 206 +---------------------------------- kexec-tools.spec | 11 ++ 6 files changed, 409 insertions(+), 203 deletions(-) create mode 100755 dracut-early-kdump-module-setup.sh create mode 100755 dracut-early-kdump.sh create mode 100644 early-kdump-howto.txt