This patch introduces a new configuration file layout structure for the kdump configuration files.
Currently we have two types of the kdump configuration files: 1. One in /etc/kdump.conf (for which initrd rebuild is required), and 2. Another in /etc/syconfig/kdump (for which initrd rebuild is not required).
In this patch, we create a single directory /etc/kdump/ and put both the config files in there.
Currently we also don't have a mechanism to deliver new config options in kdump.conf and kdump files, i.e.: - During an upgrade we cannot upgrade /etc/kdump.conf or /etc/sysconfig/kdump as the user might have modified it locally and new options will never be visible or take affect.
So this patch proposes to ship default kdump configs in /lib/kdump directory and these configuration files can be selectively overridden by the user provided config files in /etc/kdump. So we now have config files available in the following locations: /lib/kdump/ and /etc/kdump/
This allows us to upgrade the configuration files inside /lib/kdump during a package upgrade and also ship new default options without breaking existing user configuration.
Commands and comments available in /lib/kdump/kdump.conf and /etc/kdump/kdump.conf (or /lib/kdump/kdump and /etc/kdump/kdump) are now handled using the following logic: 1. If a unknown/deprecated command was found in user .conf, ignore it. 2. If a non-commented command was found both in user .conf and distro .conf, preserve the value specified in user.conf 3. If a new comment or command is found in distro .conf, preserve it.
The modified configuration files are automatically generated during an upgrade and later on the user is free to invoke the script /lib/kdump/kdump-create-config.sh to recreate the modified configuration files (the user is expected to be hands-on with the kdump configuration file layout structure in such a case).
In this patch the man page documentation source for kdump.conf has also been updated to reflect the new layout structure.
Signed-off-by: Bhupesh Sharma bhsharma@redhat.com --- fadump-howto.txt | 8 +- kdump-create-config.sh | 373 +++++++++++++++++++++++++++++++++++++++++++++ kdump-lib.sh | 2 +- kdump.conf.5 | 43 +++++- kdumpctl | 21 +-- kexec-kdump-howto.txt | 18 +-- kexec-tools.spec | 30 ++-- live-image-kdump-howto.txt | 2 +- mkdumprd.8 | 4 +- 9 files changed, 455 insertions(+), 46 deletions(-) create mode 100755 kdump-create-config.sh
diff --git a/fadump-howto.txt b/fadump-howto.txt index be17da3ce2c9..023eddbf3d4d 100644 --- a/fadump-howto.txt +++ b/fadump-howto.txt @@ -54,7 +54,7 @@ after crash. Hence, for fadump, we rebuild the new kdump initrd and replace it with default initrd. Before replacing existing default initrd we take a backup of original default initrd for user's reference. The dracut package has been enhanced to rebuild the default initrd with vmcore capture steps. The initrd -image is rebuilt as per the configuration in /etc/kdump.conf file. +image is rebuilt as per the configuration in /etc/kdump/kdump.conf file.
The control flow of fadump works as follows: 01. System panics. @@ -69,9 +69,9 @@ The control flow of fadump works as follows: steps to capture vmcore. (This check will help to bypass the vmcore capture steps during normal boot process.) -09. Captures dump according to /etc/kdump.conf +09. Captures dump according to /etc/kdump/kdump.conf 10. Is dump capture successful (yes goto 12, no goto 11) -11. Perfom the default action specified in /etc/kdump.conf (Default action +11. Perfom the default action specified in /etc/kdump/kdump.conf (Default action is reboot, if unspecified) 12. Reboot
@@ -245,7 +245,7 @@ Dracut is designed to mount rootfs by default. If rootfs mounting fails it will refuse to go on. So fadump leaves rootfs mounting to dracut currently. We make the assumtion that proper root= cmdline is being passed to dracut initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in -/etc/sysconfig/kdump, you will need to make sure that appropriate root= +/etc/kdump/kdump, you will need to make sure that appropriate root= options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely. diff --git a/kdump-create-config.sh b/kdump-create-config.sh new file mode 100755 index 000000000000..6576caf2857d --- /dev/null +++ b/kdump-create-config.sh @@ -0,0 +1,373 @@ +#!/bin/bash + +# Normally we can have two variants of the kdump.conf and kdump files: +# 1. The distribution specific one, which is usually located +# inside /lib/kdump/ +# 2. And the user specific one, which is usually located inside +# /etc/kdump +# +# So, here we need to create the final kdump.conf or kdump file by +# looking at both the distribution provided .conf and the user's copy +# of the .conf file and picking up the various directives such that +# the ones specified in the user's copy always take a precedence on +# those specified in the distribution provided .config + +USER_KDUMP_CONFIG_DIR="/etc/kdump" +TMP_KDUMP_CONFIG_DIR= +USER_KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf" +BACKUP_USER_KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf.usrorig" +TMP_KDUMP_CONFIG_FILE="/etc/kdump/tmp-kdump.conf" +DISTRO_KDUMP_CONFIG_FILE="/lib/kdump/kdump.conf" + +USER_KDUMP_FILE="/etc/kdump/kdump" +BACKUP_USER_KDUMP_FILE="/etc/kdump/kdump.usrorig" +TMP_KDUMP_FILE="/etc/kdump/tmp-kdump" +DISTRO_KDUMP_FILE="/lib/kdump/kdump" + +DEPRECATED_KDUMP_CONFIG_FILE="/etc/kdump.conf" +DEPRECATED_KDUMP_FILE="/etc/sysconfig/kdump" + +use_distribution_config_file() +{ + local DISTRO_FILE=$1 + local USER_FILE=$2 + + # Check if $USER_KDUMP_CONFIG_DIR exists, if not create it + [ ! -d $USER_KDUMP_CONFIG_DIR ] && mkdir -p $USER_KDUMP_CONFIG_DIR + + # Check if $USER_KDUMP_CONFIG_FILE exists, if not + # copy the $DISTRO_KDUMP_CONFIG_FILE over + [ ! -f $USER_FILE ] && cp -f $DISTRO_FILE $USER_FILE +} + +use_deprecated_config_file() +{ + local DEPRECATED_FILE=$1 + local USER_FILE=$2 + + # Check if $USER_KDUMP_CONFIG_DIR exists, if not create it + [ ! -d $USER_KDUMP_CONFIG_DIR ] && mkdir -p $USER_KDUMP_CONFIG_DIR + + # Copy the $DEPRECATED_FILE as $USER_FILE + cp -f $DEPRECATED_FILE $USER_FILE +} + +create_backup_of_user_config_file() +{ + local USER_FILE=$1 + local BACKUP_FILE=$2 + + cp -f $USER_FILE $BACKUP_FILE + echo "$USER_FILE saved as $BACKUP_FILE" +} + +is_user_config_file_present() +{ + local USER_FILE=$1 + local DEPRECATED_FILE=$2 + + if [ -f $USER_FILE ]; then + return 1 + else + # If deprecated config file is present, copy it as the + # user config file since it does not exist originally. + if [ -f $DEPRECATED_FILE ]; then + use_deprecated_config_file $DEPRECATED_FILE $USER_FILE + return 1 + else + return 0 + fi + fi +} + +is_distribution_specific_config_file_present() +{ + local DISTRO_FILE=$1 + + if [ -f $DISTRO_FILE ]; then + return 1 + fi + + return 0 +} + +create_final_config_file_initrd_rebuild_reqd() +{ + local DISTRO_FILE=$1 + local USER_FILE=$2 + local TMP_FILE=$3 + local BACKUP_FILE=$4 + + # Logic below requires the comments and commands in a .conf + # file to be seperated via a blank line. If we don't see the + # same, bail out with a error + if [ $(grep -c "^$" $DISTRO_FILE) -eq 0 ]; then + echo "Error! Invalid $DISTRO_FILE format" >&2 + exit 1 + fi + + if [ $(grep -c "^$" $USER_FILE) -eq 0 ]; then + echo "Error! Invalid $USER_FILE format" >&2 + exit 1 + fi + + # Setup a cleanup in case we trap a signal which is going to + # kill this script + trap 'rm -rf $TMP_KDUMP_CONFIG_DIR $TMP_FILE' EXIT + + # Create TMP directory to hold temporary files + TMP_KDUMP_CONFIG_DIR=$(mktemp -d) + + # Remove leftover tmp files (if any) + if [ -f $TMP_FILE ]; then + rm -f $TMP_FILE + fi + + # Now setup the temporary files + local USER_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/USER_CMD.$$.tmp + local DISTRO_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/DISTRO_CMD.$$.tmp + local CMD_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/CMD_TMP.$$.tmp + + # Final .conf file creation rules: + # 1. If a unknown/deprecated command was found in user .conf, + # ignore it. + # 2. If a commented command was found in user .conf, preserve it. + # 3. If a non-commented command was found both in user .conf + # and distro .conf, preserve the value specified in user.conf + # 4. If a new comment or command is found in distro .conf, + # preserve it. + + # First copy the comment section (which is seperated by a + # blankline from the commands) into the new .conf file + sed -e '/./!Q' $DISTRO_FILE > $TMP_FILE 2>&1 + + # Add a blank line + echo "" >> $TMP_FILE 2>&1 + + sed '1,/^$/d' $DISTRO_FILE > $DISTRO_CMD_FILE 2>&1 + sed '1,/^$/d' $USER_FILE > $USER_CMD_FILE 2>&1 + + # Check if the rest of the distro and user conf files are exact + # replicas. If yes, do nothing more and copy the rest of the + # distro conf file as the new conf file + cmp -s $DISTRO_CMD_FILE $USER_CMD_FILE + if [ $? -eq 0 ]; then + cat $DISTRO_CMD_FILE >> $TMP_FILE + else + # Copy common comments and commands specified in both + # distro and user .conf into the new .conf file + awk 'NR==FNR{A[$1];next} $1 in A' $USER_CMD_FILE $DISTRO_CMD_FILE >> $TMP_FILE 2>&1 + + # Now, copy new comments and commands specified in + # distro .conf into the new .conf file + grep -vxFf $USER_CMD_FILE $DISTRO_CMD_FILE >> $TMP_FILE 2>&1 + + # If there are any duplicates exisiting, deal with them + # (prefer those mentioned in user .conf): + grep -vxFf $DISTRO_CMD_FILE $USER_CMD_FILE > $CMD_TMP_FILE 2>&1 + if [ -s $CMD_TMP_FILE ]; then + sed --in-place "/^#$(awk '{print $1}' $CMD_TMP_FILE)/d" $TMP_FILE 2>&1 + sed --in-place "/^$(awk '{print $1}' $CMD_TMP_FILE)/d" $TMP_FILE 2>&1 + fi + + # Finally, copy whats changed in user .conf + grep -vxFf $DISTRO_CMD_FILE $USER_CMD_FILE >> $TMP_FILE 2>&1 + fi + + # If the newly generated .conf file is the same as the backup + # copy, do nothing + cmp -s $TMP_FILE $BACKUP_FILE + if [ $? -ne 0 ]; then + # Now finally move this .conf file as the default .conf + # file + mv -f $TMP_FILE $USER_FILE + fi + + # Remove leftover tmp files (if any) + if [ -f $TMP_FILE ]; then + rm -f $TMP_FILE + fi + + rm -rf $TMP_KDUMP_CONFIG_DIR +} + +create_final_config_file_initrd_rebuild_not_reqd() +{ + local DISTRO_FILE=$1 + local USER_FILE=$2 + local TMP_FILE=$3 + local BACKUP_FILE=$4 + + # Setup a cleanup in case we trap a signal which is going to + # kill this script + trap 'rm -rf $TMP_KDUMP_CONFIG_DIR $TMP_FILE' EXIT + + # Create TMP directory to hold temporary files + TMP_KDUMP_CONFIG_DIR=$(mktemp -d) + + # Remove existing tmp files (if any) + if [ -f $TMP_FILE ]; then + rm -f $TMP_FILE + fi + + # Now setup the temporary files + local USER_CMD_FILE=$TMP_KDUMP_CONFIG_DIR/USER.$$.tmp + local CMD_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/CMD_TMP.$$.tmp + local FINAL_TMP_FILE=$TMP_KDUMP_CONFIG_DIR/TMP.$$.tmp + + # Copy the distro .conf file to new .conf file + cp -f $DISTRO_FILE $TMP_FILE + + # Now, handle deprecated or modified commands in user.conf. + # Remove the deprecated commands and keep the modified commands + # in the new .conf file + grep -vxFf $DISTRO_FILE $USER_FILE > $USER_CMD_FILE 2>&1 + + # There can be some commands which have been redefined or added + # in the user .conf and hence do not match the respective distro + # .conf. + # + # Ignore any deprecated command mentioned in the user .conf and + # return the value of a command (assuming a command is defined + # as: + # COMMAND=This is my command [i.e. using the '=' separator] + # so that it can be retained in the new .conf + # + # Finally move this new .conf file as the user .conf file + awk -F '=' '{A[$1];print $1}' $USER_CMD_FILE >> $CMD_TMP_FILE 2>&1 + + sed -e "s/$(grep "^$(awk -F '=' 'NR==FNR{A[$1];next} $1 in A' $TMP_FILE $CMD_TMP_FILE)" $TMP_FILE)/$(grep "^$(awk -F '=' 'NR==FNR{A[$1];next} $1 in A' $TMP_FILE $CMD_TMP_FILE)" $USER_CMD_FILE)/" $TMP_FILE > $FINAL_TMP_FILE + + # If the newly generated .conf file is the same as the backup + # copy, do nothing + cmp -s $FINAL_TMP_FILE $BACKUP_FILE + if [ $? -ne 0 ]; then + # Now finally move this .conf file as the default .conf + # file + mv -f $FINAL_TMP_FILE $USER_FILE + fi + + # Remove leftover tmp files (if any) + if [ -f $TMP_FILE ]; then + rm -f $TMP_FILE + fi + + rm -rf $TMP_KDUMP_CONFIG_DIR +} + +create_final_config_file() +{ + local INITRD_REBUILD_REQD=$1 + local DISTRO_FILE=$2 + local USER_FILE=$3 + local TMP_FILE=$4 + local BACKUP_FILE=$5 + + if [ $INITRD_REBUILD_REQD -eq 1 ]; then + create_final_config_file_initrd_rebuild_reqd \ + $DISTRO_FILE $USER_FILE $TMP_FILE $BACKUP_FILE + else + create_final_config_file_initrd_rebuild_not_reqd \ + $DISTRO_FILE $USER_FILE $TMP_FILE $BACKUP_FILE + fi +} + +handle_config_files() +{ + local INITRD_REBUILD_REQD=$1 + local DISTRO_FILE=$2 + local USER_FILE=$3 + local TMP_FILE=$4 + local BACKUP_FILE=$5 + local DEPRECATED_FILE=$6 + + # Check if the user specified .conf file exists + is_user_config_file_present $USER_FILE $DEPRECATED_FILE + if [ $? -eq 1 ]; then + # Check if the distro specified .conf file exists + is_distribution_specific_config_file_present $DISTRO_FILE + if [ $? -eq 1 ]; then + # Check if the distro and user conf files are + # exact replicas. If yes, do nothing and copy + # distro conf file as the user conf file + cmp -s $DISTRO_FILE $USER_FILE + if [ $? -eq 0 ]; then + use_distribution_config_file \ + $DISTRO_FILE $USER_FILE + else + # Create a backup copy of the user + # specified .conf file, so that the + # user can track changes (if required) + # later-on + create_backup_of_user_config_file \ + $USER_FILE $BACKUP_FILE + + # Traverse the user's copy of kdump.conf + # file and the distro specific version + # and create a final kdump.conf file + # which gives precedence to the user + # specific settings + create_final_config_file \ + $INITRD_REBUILD_REQD \ + $DISTRO_FILE $USER_FILE \ + $TMP_FILE $BACKUP_FILE + fi + fi + else + # Check if the distro specified .conf file exists + # and use the same as the default + is_distribution_specific_config_file_present $DISTRO_FILE + if [ $? -eq 1 ]; then + use_distribution_config_file $DISTRO_FILE \ + $USER_FILE + else + echo "Error! No valid config file found" >&2 + exit 1 + fi + fi +} + +remove_deprecated_config_files() +{ + local DEPRECATED_CONFIG_FILE=$1 + local USER_KDUMP_FILE=$2 + + # If everything went ok and the conf files are properly + # generated, remove the deprecated config files + if [[ -f $DEPRECATED_CONFIG_FILE && -f $USER_KDUMP_FILE && -s $USER_KDUMP_FILE ]]; then + rm -f $DEPRECATED_CONFIG_FILE + fi +} + +handle_config_files_initrd_rebuild_required() +{ + local INITRD_REBUILD_REQD=1 + handle_config_files $INITRD_REBUILD_REQD \ + $DISTRO_KDUMP_CONFIG_FILE $USER_KDUMP_CONFIG_FILE \ + $TMP_KDUMP_CONFIG_FILE $BACKUP_USER_KDUMP_CONFIG_FILE \ + $DEPRECATED_KDUMP_CONFIG_FILE + remove_deprecated_config_files $DEPRECATED_KDUMP_CONFIG_FILE \ + $USER_KDUMP_CONFIG_FILE +} + +handle_config_files_initrd_rebuild_not_required() +{ + local INITRD_REBUILD_REQD=0 + handle_config_files $INITRD_REBUILD_REQD $DISTRO_KDUMP_FILE \ + $USER_KDUMP_FILE $TMP_KDUMP_FILE \ + $BACKUP_USER_KDUMP_FILE $DEPRECATED_KDUMP_FILE + remove_deprecated_config_files $DEPRECATED_KDUMP_FILE \ + $USER_KDUMP_FILE +} + +handle_dump_config_files() +{ + handle_config_files_initrd_rebuild_required + handle_config_files_initrd_rebuild_not_required +} + +# Gracefully handle all possible combinations of kdump +# configuration files and generate the final version of the same +# which can be used further + +handle_dump_config_files diff --git a/kdump-lib.sh b/kdump-lib.sh index f8b040977384..2849110c8063 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -6,7 +6,7 @@ DEFAULT_PATH="/var/crash/" FENCE_KDUMP_CONFIG_FILE="/etc/sysconfig/fence_kdump" FENCE_KDUMP_SEND="/usr/libexec/fence_kdump_send" -KDUMP_CONFIG_FILE="/etc/kdump.conf" +KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
perror_exit() { echo $@ >&2 diff --git a/kdump.conf.5 b/kdump.conf.5 index b581964b906e..76c001738c8f 100644 --- a/kdump.conf.5 +++ b/kdump.conf.5 @@ -14,7 +14,7 @@ this file and do not want to reboot in order for the changes to take effect, restart the kdump service to rebuild the initrd.
For most configurations, you can simply review the examples provided -in the stock /etc/kdump.conf. +in the stock /lib/kdump/kdump.conf.
.B NOTE: For filesystem dumps the dump target must be mounted before building @@ -215,7 +215,7 @@ directly.
.B options <module> <option list> .RS -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump to add module options as +Use KDUMP_COMMANDLINE_APPEND in /etc/kdump/kdump to add module options as kernel command line parameters. For example, specify 'loop.max_loop=1' to limit maximum loop devices to 1. .RE @@ -236,7 +236,7 @@ Similar to link_delay, dracut ensures disks are ready before kdump uses them. Turn on verbose debug output of kdump scripts regarding free/used memory at various points of execution. This feature has been moved to dracut now. -Use KDUMP_COMMANDLINE_APPEND in /etc/sysconfig/kdump and +Use KDUMP_COMMANDLINE_APPEND in /etc/kdump/kdump and append dracut cmdline param rd.memdebug=[0-3] to enable the debug output.
Higher level means more debugging output. @@ -259,7 +259,7 @@ retaining blacklist option creates more confusing behavior. It has been deprecated. .PP Instead, use rd.driver.blacklist option on second kernel to blacklist -a certain module. One can edit /etc/sysconfig/kdump.conf and edit +a certain module. One can edit /etc/kdump/kdump and edit KDUMP_COMMANDLINE_APPEND to pass kernel command line options. Refer to dracut.cmdline man page for more details on module blacklist option. .RE @@ -336,8 +336,39 @@ Above will effectively be translated to. scp /proc/vmcore user@host:path/vmcore
.PP -examples for other options please see -.I /etc/kdump.conf +for examples of other options please see +.I /lib/kdump/kdump.conf + +.SH FILES +.B /lib/kdump/kdump.conf +.RS +Distribution kdump configuration file which may be updated during +package upgrade. +.RE + +.B /etc/kdump.conf +.RS +Deprecated user configuration file. New distributions now support +/etc/kdump/kdump.conf as the default user kdump configuration file. +.RE + +.B /etc/kdump/kdump.conf +.RS +User kdump configuration file which takes precedence over the +distribution kdump configuration file. Any variables specified in +/etc/kdump/kdump.conf will override the defaults specified in +/lib/kdump/kdump.conf. +.RE + +.B /etc/kdump/kdump.conf.usrorig +.RS +If the user kdump configuration file (/etc/kdump.conf or +/etc/kdump/kdump.conf) already exists, it is saved as +/etc/kdump/kdump.conf.usrorig before a new user kdump configuration file +is generated (by merging contents of the distribution and user +configuration files), so that the user can refer to the same later +(if required). +.RE
.SH SEE ALSO
diff --git a/kdumpctl b/kdumpctl index a133e986e019..d79b0be2d806 100755 --- a/kdumpctl +++ b/kdumpctl @@ -4,6 +4,7 @@ KEXEC=/sbin/kexec KDUMP_KERNELVER="" KDUMP_COMMANDLINE="" KEXEC_ARGS="" +KDUMP_FILE="/etc/kdump/kdump" MKDUMPRD="/sbin/mkdumprd -f" SAVE_PATH=/var/crash SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa" @@ -24,12 +25,15 @@ image_time=0
standard_kexec_args="-p"
-# Some default values in case /etc/sysconfig/kdump doesn't include +# Some default values in case /etc/kdump/kdump doesn't include KDUMP_COMMANDLINE_REMOVE="hugepages hugepagesz slub_debug"
-if [ -f /etc/sysconfig/kdump ]; then - . /etc/sysconfig/kdump -fi +source_dump_file() +{ + if [ -f $KDUMP_FILE ]; then + . $KDUMP_FILE + fi +}
single_instance_lock() { @@ -745,7 +749,7 @@ need_64bit_headers() print (strtonum("0x" r[2]) > strtonum("0xffffffff")); }'` }
-# Load the kdump kernel specified in /etc/sysconfig/kdump +# Load the kdump kernel specified in /etc/kdump/kdump # If none is specified, try to load a kdump kernel with the same version # as the currently running kernel. load_kdump() @@ -1267,11 +1271,6 @@ stop() return 0 }
-if [ ! -f "$KDUMP_CONFIG_FILE" ]; then - echo "Error: No kdump config file found!" >&2 - exit 1 -fi - main () { # Determine if the dump mode is kdump or fadump @@ -1322,6 +1321,8 @@ main () # Other kdumpctl instances will block in queue, until this one exits single_instance_lock
+source_dump_file + # To avoid fd 9 leaking, we invoke a subshell, close fd 9 and call main. # So that fd isn't leaking when main is invoking a subshell. (exec 9<&-; main $1) diff --git a/kexec-kdump-howto.txt b/kexec-kdump-howto.txt index f46563f2f527..aca84c246094 100644 --- a/kexec-kdump-howto.txt +++ b/kexec-kdump-howto.txt @@ -267,9 +267,9 @@ as allowing for the centralization of vmcore files, should you have several systems from which you'd like to obtain vmcore files. Of course, note that these configurations could present problems if your network is unreliable.
-Advanced setups are configured via modifications to /etc/kdump.conf, +Advanced setups are configured via modifications to /etc/kdump/kdump.conf, which out of the box, is fairly well documented itself. Any alterations to -/etc/kdump.conf should be followed by a restart of the kdump service, so +/etc/kdump/kdump.conf should be followed by a restart of the kdump service, so the changes can be incorporated in the kdump initrd. Restarting the kdump service is as simple as '/sbin/systemctl restart kdump.service'.
@@ -278,7 +278,7 @@ Note that kdump.conf is used as a configuration mechanism for capturing dump files from the initramfs (in the interests of safety), the root file system is mounted, and the init process is started, only as a last resort if the initramfs fails to capture the vmcore. As such, configuration made in -/etc/kdump.conf is only applicable to capture recorded in the initramfs. If +/etc/kdump/kdump.conf is only applicable to capture recorded in the initramfs. If for any reason the init process is started on the root file system, only a simple copying of the vmcore from /proc/vmcore to /var/crash/$DATE/vmcore will be preformed. @@ -352,7 +352,7 @@ about the format of "--mount" for details. If there is any "--mount" specified via "dracut_args", kdump will build it as the mount target without doing any validation (mounting or checking like mount options, fs size, save path, etc), so you must test it to ensure all the correctness. You cannot use other targets -in /etc/kdump.conf if you use "--mount" in "dracut_args". You also cannot specify +in /etc/kdump/kdump.conf if you use "--mount" in "dracut_args". You also cannot specify mutliple "--mount" targets via "dracut_args".
One use case of "--mount" in "dracut_args" is you do not want to mount dump target @@ -430,7 +430,7 @@ command and get an output: cat /proc/cmdline BOOT_IMAGE=/xxx/vmlinuz-3.yyy.zzz root=xxxx ..... Then kdump kernel will be /boot/xxx/vmlinuz-3.yyy.zzz. -However a variable KDUMP_BOOTDIR in /etc/sysconfig/kdump is provided to +However a variable KDUMP_BOOTDIR in /etc/kdump/kdump is provided to user if kdump kernel is put in a different directory.
Kdump Post-Capture Executable @@ -616,12 +616,12 @@ operating and capturing a vmcore image, but a casual observer will see the system as hung until the dump completes and a true reboot is executed.
There are two possiblilties to work around this issue. One is by adding ---reset-vga to the kexec command line options in /etc/sysconfig/kdump. This +--reset-vga to the kexec command line options in /etc/kdump/kdump. This tells kdump to write some reasonable default values to the video card register file, in the hopes of returning it to a text mode such that boot messages are visible on the screen. It does not work with all video cards however. Secondly, it may be worth trying to add vga15fb.ko to the extra_modules list in -/etc/kdump.conf. This will attempt to use the video card in framebuffer mode, +/etc/kdump/kdump.conf. This will attempt to use the video card in framebuffer mode, which can blank the screen prior to the start of a dump capture.
Notes on rootfs mount: @@ -629,7 +629,7 @@ Dracut is designed to mount rootfs by default. If rootfs mounting fails it will refuse to go on. So kdump leaves rootfs mounting to dracut currently. We make the assumtion that proper root= cmdline is being passed to dracut initramfs for the time being. If you need modify "KDUMP_COMMANDLINE=" in -/etc/sysconfig/kdump, you will need to make sure that appropriate root= +/etc/kdump/kdump, you will need to make sure that appropriate root= options are copied from /proc/cmdline. In general it is best to append command line options using "KDUMP_COMMANDLINE_APPEND=" instead of replacing the original command line completely. @@ -668,7 +668,7 @@ hardware issue (*). The disable_cpu_apicid kernel option is automatically appended by kdumpctl script and is ignored if the kernel doesn't support it.
You need to specify how many cpus to be used in a capture kernel by specifying -the number of cpus in nr_cpus kernel option in /etc/sysconfig/kdump. nr_cpus +the number of cpus in nr_cpus kernel option in /etc/kdump/kdump. nr_cpus is 1 at default.
You should use necessary and sufficient number of cpus on a capture kernel. diff --git a/kexec-tools.spec b/kexec-tools.spec index 59ce32fe0045..8638bb0af136 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -1,3 +1,5 @@ +%define kdumplibdir %{_prefix}/lib/kdump + Name: kexec-tools Version: 2.0.14 Release: 12%{?dist} @@ -29,6 +31,7 @@ Source24: kdump-lib-initramfs.sh Source25: kdump.sysconfig.ppc64le Source26: kdumpctl.8 Source27: live-image-kdump-howto.txt +Source28: kdump-create-config.sh
####################################### # These are sources for mkdumpramfs @@ -160,7 +163,7 @@ make -C kdump-anaconda-addon/po
%install make install DESTDIR=$RPM_BUILD_ROOT -mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig +mkdir -p -m755 $RPM_BUILD_ROOT%{_sysconfdir}/kdump mkdir -p -m755 $RPM_BUILD_ROOT%{_localstatedir}/crash mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man8/ mkdir -p -m755 $RPM_BUILD_ROOT%{_mandir}/man5/ @@ -176,15 +179,16 @@ install -m 755 %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/kdumpctl SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_target_cpu} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig.%{_arch} [ -f $SYSCONFIG ] || SYSCONFIG=$RPM_SOURCE_DIR/kdump.sysconfig -install -m 644 $SYSCONFIG $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/kdump +install -m 644 $SYSCONFIG $RPM_BUILD_ROOT/%{kdumplibdir}/kdump
install -m 755 %{SOURCE7} $RPM_BUILD_ROOT/sbin/mkdumprd -install -m 644 %{SOURCE8} $RPM_BUILD_ROOT%{_sysconfdir}/kdump.conf +install -m 644 %{SOURCE8} $RPM_BUILD_ROOT/%{kdumplibdir}/kdump.conf install -m 644 kexec/kexec.8 $RPM_BUILD_ROOT%{_mandir}/man8/kexec.8 install -m 644 %{SOURCE12} $RPM_BUILD_ROOT%{_mandir}/man8/mkdumprd.8 install -m 644 %{SOURCE26} $RPM_BUILD_ROOT%{_mandir}/man8/kdumpctl.8 install -m 755 %{SOURCE20} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib.sh install -m 755 %{SOURCE24} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-lib-initramfs.sh +install -m 755 %{SOURCE28} $RPM_BUILD_ROOT%{_prefix}/lib/kdump/kdump-create-config.sh %ifnarch s390x # For s390x the ELF header is created in the kdump kernel and therefore kexec # udev rules are not required @@ -228,13 +232,16 @@ mkdir -p $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/ mv $RPM_BUILD_ROOT/etc/kdump-adv-conf/kdump_dracut_modules/* $RPM_BUILD_ROOT/%{dracutlibdir}/modules.d/
%post +# .conf file handling +sh %{kdumplibdir}/kdump-create-config.sh + # Initial installation %systemd_post kdump.service
-touch /etc/kdump.conf +touch %{kdumplibdir}/kdump.conf # This portion of the script is temporary. Its only here # to fix up broken boxes that require special settings -# in /etc/sysconfig/kdump. It will be removed when +# in /etc/kdump/kdump. It will be removed when # These systems are fixed.
if [ -d /proc/bus/mckinley ] @@ -242,16 +249,16 @@ then # This is for HP zx1 machines # They require machvec=dig on the kernel command line sed -e's/(^KDUMP_COMMANDLINE_APPEND.*)("$)/\1 machvec=dig"/' \ - /etc/sysconfig/kdump > /etc/sysconfig/kdump.new - mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump + /etc/kdump/kdump > /etc/kdump/kdump.new + mv /etc/kdump/kdump.new /etc/kdump/kdump elif [ -d /proc/sgi_sn ] then # This is for SGI SN boxes # They require the --noio option to kexec # since they don't support legacy io sed -e's/(^KEXEC_ARGS.*)("$)/\1 --noio"/' \ - /etc/sysconfig/kdump > /etc/sysconfig/kdump.new - mv /etc/sysconfig/kdump.new /etc/sysconfig/kdump + /etc/kdump/kdump > /etc/kdump/kdump.new + mv /etc/kdump/kdump.new /etc/kdump/kdump fi
@@ -274,8 +281,7 @@ fi
%triggerin -- kernel-kdump -touch %{_sysconfdir}/kdump.conf - +touch %{kdumplibdir}/kdump.conf
%triggerpostun -- kernel kernel-xen kernel-debug kernel-PAE kernel-kdump # List out the initrds here, strip out version nubmers @@ -303,8 +309,6 @@ done %ifarch %{ix86} x86_64 ppc64 s390x ppc64le %{_sysconfdir}/makedumpfile.conf.sample %endif -%config(noreplace,missingok) %{_sysconfdir}/sysconfig/kdump -%config(noreplace,missingok) %{_sysconfdir}/kdump.conf %ifnarch s390x %config %{_udevrulesdir} %endif diff --git a/live-image-kdump-howto.txt b/live-image-kdump-howto.txt index 1695a1cd0931..31a0889267ab 100644 --- a/live-image-kdump-howto.txt +++ b/live-image-kdump-howto.txt @@ -7,7 +7,7 @@ Since there isn't any config file that can be used to configure kernel parameters for live images before booting them, we have to append 'crashkernel' argument in boot menu every time we boot a live image.
-2. Change dump target in /etc/kdump.conf +2. Change dump target in /etc/kdump/kdump.conf
When kdump kernel boots in a live environment, the default target /var/crash is in RAM so you need to change the dump target to an external disk or a network diff --git a/mkdumprd.8 b/mkdumprd.8 index 7faae57ef128..c708f993819f 100644 --- a/mkdumprd.8 +++ b/mkdumprd.8 @@ -8,11 +8,11 @@ mkdumprd - creates initial ramdisk images for kdump crash recovery \fBmkdumprd\fR creates an initial ram file system for use in conjunction with the booting of a kernel within the kdump framework for crash recovery. \fBmkdumprds\fR purpose is to create an initial ram filesystem capable of copying -the crashed systems vmcore image to a location specified in \fI/etc/kdump.conf +the crashed systems vmcore image to a location specified in \fI/etc/kdump/kdump.conf
\fBmkdumprd\fR interrogates the running system to understand what modules need to be loaded in the initramfs (based on configuration retrieved from -\fI/etc/kdump.conf)\fR +\fI/etc/kdump/kdump.conf)\fR
\fBmkdumprd\fR add a new \fBdracut\fR module 99kdumpbase and use \fBdracut\fR utility to generate the initramfs.