This patch addresses Fedora BZ1078311 and introduces a new configuration
file layout structure for the kdump files.
Currently we have two variants 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:
- During an upgrade we cannot upgrade /etc/kdump.conf or
/etc/sysconfig/kdump as the user might have modifed it locally and
new options will never be visible or take affect.
- So this patch proposes to ship default configs in /lib/kdump.
And this can be selectively overwritten by the user provided
config in /etc/kdump.
- So we now have config files available in
/lib/kdump/kdump.conf and /etc/kdump/kdump.conf (for example). This
allows us to upgrade /lib/kdump/kdump.conf during package upgrade and
ship new default options without breaking user configuration.
- Commands and comments available in
/lib/kdump/kdump.conf and /etc/kdump/kdump.conf are now handled using
the following logic:
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.
While at it, this patch also improves the kdump configuration file
description as its current wording - "this file contains a series of
commands to perform (in order)" is misleading.
As per the new configuration file layout, the man documentation source
for the kdump.conf has also been updated.
Here are some of the sample timings required after this change on Fedora
x86_64 machine:
1. When the kdump initrd is regenerated (when
there a new user kdump or kdump.conf file is generated)
kexec: unloaded kdump kernel
Stopping kdump: [OK]
Detected change(s) in the following file(s):
/etc/kdump/kdump.conf
Rebuilding /boot/initramfs-4.9.17-100.fc24.x86_64kdump.img
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m11.510s
user 0m14.480s
sys 0m2.464s
2. When the kdump initrd is not required to be generated
(as the user kdump and kdump.conf files remain unchanged):
kexec: unloaded kdump kernel
Stopping kdump: [OK]
kexec: loaded kdump kernel
Starting kdump: [OK]
real 0m3.713s
user 0m3.446s
sys 0m0.525s
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
dracut-module-setup.sh | 10 +-
fadump-howto.txt | 8 +-
kdump-create-config.sh | 365 +++++++++++++++++++++++++++++++++++++++++++++
kdump-lib-initramfs.sh | 2 +-
kdump-lib.sh | 21 +--
kdump.conf | 4 +-
kdump.conf.5 | 43 +++++-
kdumpctl | 38 +++--
kexec-kdump-howto.txt | 18 +--
kexec-tools.spec | 30 ++--
live-image-kdump-howto.txt | 2 +-
mkdumprd | 4 +-
mkdumprd.8 | 4 +-
13 files changed, 481 insertions(+), 68 deletions(-)
create mode 100755 kdump-create-config.sh
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
index bdf67cee2fd5..b6ad9fb5da3a 100755
--- a/dracut-module-setup.sh
+++ b/dracut-module-setup.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
+
. $dracutfunctions
. /lib/kdump/kdump-lib.sh
@@ -10,7 +12,7 @@ fi
check() {
[[ $debug ]] && set -x
#kdumpctl sets this explicitly
- if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
+ if [ -z "$IN_KDUMP" ] || [ ! -f $KDUMP_CONFIG_FILE ]
then
return 1
fi
@@ -439,7 +441,7 @@ adjust_bind_mount_path()
#install kdump.conf and what user specifies in kdump.conf
kdump_install_conf() {
local _opt _val _pdev
- sed -ne '/^#/!p' /etc/kdump.conf > ${initdir}/tmp/$$-kdump.conf
+ sed -ne '/^#/!p' $KDUMP_CONFIG_FILE > ${initdir}/tmp/$$-kdump.conf
while read _opt _val;
do
@@ -472,12 +474,12 @@ kdump_install_conf() {
dracut_install "${_val%%[[:blank:]]*}"
;;
esac
- done < /etc/kdump.conf
+ done < $KDUMP_CONFIG_FILE
default_dump_target_install_conf
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
- inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
+ inst "${initdir}/tmp/$$-kdump.conf" "$KDUMP_CONFIG_FILE"
rm -f ${initdir}/tmp/$$-kdump.conf
}
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..231391d5ff34
--- /dev/null
+++ b/kdump-create-config.sh
@@ -0,0 +1,365 @@
+#!/bin/sh
+
+# 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="/etc/kdump/tmp"
+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_not_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
+
+ # Create TMP directory to hold temporary files
+ TMP_KDUMP_CONFIG_DIR=$(mktemp -d)
+
+ # 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
+
+ # 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
+ 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
+
+ # 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_reqd()
+{
+ local DISTRO_FILE=$1
+ local USER_FILE=$2
+ local TMP_FILE=$3
+ local BACKUP_FILE=$4
+
+ # Create TMP directory to hold temporary files
+ TMP_KDUMP_CONFIG_DIR=$(mktemp -d)
+
+ # 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
+
+ # 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_not_required()
+{
+ local INITRD_REBUILD_REQD=0
+ 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_required()
+{
+ local INITRD_REBUILD_REQD=1
+ 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_not_required
+ handle_config_files_initrd_rebuild_required
+}
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 4c0e2e2837fd..ec36d00e6025 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -14,7 +14,7 @@ SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
KDUMP_SCRIPT_DIR="/kdumpscripts"
DD_BLKSIZE=512
FINAL_ACTION="systemctl reboot -f"
-KDUMP_CONF="/etc/kdump.conf"
+KDUMP_CONF="/etc/kdump/kdump.conf"
KDUMP_PRE=""
KDUMP_POST=""
NEWROOT="/sysroot"
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 8ebad70d8d92..2849110c8063 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -6,6 +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/kdump.conf"
perror_exit() {
echo $@ >&2
@@ -18,18 +19,18 @@ perror() {
is_ssh_dump_target()
{
- grep -q "^ssh[[:blank:]].*@" /etc/kdump.conf
+ grep -q "^ssh[[:blank:]].*@" $KDUMP_CONFIG_FILE
}
is_nfs_dump_target()
{
- grep -q "^nfs" /etc/kdump.conf || \
- [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" /etc/kdump.conf)") = nfs* ]]
+ grep -q "^nfs" $KDUMP_CONFIG_FILE || \
+ [[ $(get_dracut_args_fstype "$(grep "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE)") = nfs* ]]
}
is_raw_dump_target()
{
- grep -q "^raw" /etc/kdump.conf
+ grep -q "^raw" $KDUMP_CONFIG_FILE
}
is_fs_type_nfs()
@@ -41,7 +42,7 @@ is_fs_type_nfs()
is_fs_dump_target()
{
- egrep -q "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf
+ egrep -q "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE
}
is_user_configured_dump_target()
@@ -71,7 +72,7 @@ is_generic_fence_kdump()
{
[ -x $FENCE_KDUMP_SEND ] || return 1
- grep -q "^fence_kdump_nodes" /etc/kdump.conf
+ grep -q "^fence_kdump_nodes" $KDUMP_CONFIG_FILE
}
to_dev_name() {
@@ -96,7 +97,7 @@ get_user_configured_dump_disk()
return
fi
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" /etc/kdump.conf 2>/dev/null |awk '{print $2}')
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw" $KDUMP_CONFIG_FILE 2>/dev/null |awk '{print $2}')
[ -n "$_target" ] && echo $_target
return
@@ -194,7 +195,7 @@ get_mntpoint_from_target()
# get_option_value <option_name>
# retrieves value of option defined in kdump.conf
get_option_value() {
- echo $(strip_comments `grep "^$1[[:space:]]\+" /etc/kdump.conf | tail -1 | cut -d\ -f2-`)
+ echo $(strip_comments `grep "^$1[[:space:]]\+" $KDUMP_CONFIG_FILE | tail -1 | cut -d\ -f2-`)
}
#This function compose a absolute path with the mount
@@ -369,7 +370,7 @@ is_wdt_mod_omitted() {
local dracut_args
local ret=1
- dracut_args=$(grep "^dracut_args" /etc/kdump.conf)
+ dracut_args=$(grep "^dracut_args" $KDUMP_CONFIG_FILE)
[[ -z $dracut_args ]] && return $ret
eval set -- $dracut_args
@@ -392,7 +393,7 @@ is_wdt_mod_omitted() {
# its correctness).
is_mount_in_dracut_args()
{
- grep -q "^dracut_args .*\-\-mount" /etc/kdump.conf
+ grep -q "^dracut_args .*\-\-mount" $KDUMP_CONFIG_FILE
}
# If $1 contains dracut_args "--mount", return <filesystem type>
diff --git a/kdump.conf b/kdump.conf
index ebf9587a6522..c34a8e39d365 100644
--- a/kdump.conf
+++ b/kdump.conf
@@ -1,5 +1,5 @@
-# This file contains a series of commands to perform (in order) in the kdump
-# kernel after a kernel crash in the crash kernel(1st kernel) has happened.
+# This configuration file contains options which are used by the kdump kernel crash
+# collection service.
#
# Directives in this file are only applicable to the kdump initramfs, and have
# no effect once the root filesystem is mounted and the normal init scripts are
diff --git a/kdump.conf.5 b/kdump.conf.5
index ca427699be53..9e36a63a09d6 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
@@ -205,7 +205,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
@@ -226,7 +226,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.
@@ -249,7 +249,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
@@ -326,8 +326,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 4d68be0c292d..2746f20932d0 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -4,7 +4,8 @@ KEXEC=/sbin/kexec
KDUMP_KERNELVER=""
KDUMP_COMMANDLINE=""
KEXEC_ARGS=""
-KDUMP_CONFIG_FILE="/etc/kdump.conf"
+KDUMP_CONFIG_FILE="/etc/kdump/kdump.conf"
+KDUMP_FILE="/etc/kdump/kdump"
MKDUMPRD="/sbin/mkdumprd -f"
SAVE_PATH=/var/crash
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
@@ -23,14 +24,22 @@ image_time=0
. $dracutbasedir/dracut-functions.sh
. /lib/kdump/kdump-lib.sh
+# We need to create the final kdump .conf file by looking at both
+# the distribution provided .conf and the user's copy of the .conf
+# file
+. /lib/kdump/kdump-create-config.sh
+
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()
{
@@ -683,7 +692,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()
@@ -932,7 +941,7 @@ save_raw()
get_save_path()
{
- local _save_path=$(grep "^path" /etc/kdump.conf|awk '{print $2}')
+ local _save_path=$(grep "^path" $KDUMP_CONFIG_FILE|awk '{print $2}')
if [ -z "$_save_path" ]; then
_save_path="/var/crash"
fi
@@ -944,7 +953,7 @@ is_dump_target_configured()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" /etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix|^raw|^ssh|^nfs" $KDUMP_CONFIG_FILE)
[ -n "$_target" ]
}
@@ -953,7 +962,7 @@ local_fs_dump_target()
{
local _target
- _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" /etc/kdump.conf)
+ _target=$(egrep "^ext[234]|^xfs|^btrfs|^minix" $KDUMP_CONFIG_FILE)
if [ $? -eq 0 ]; then
echo $_target|awk '{print $2}'
fi
@@ -1120,6 +1129,12 @@ check_default_config()
start()
{
+ # Gracefully handle all possible combinations od kdump
+ # configuration files and generate the final version of the same
+ # which can be used further
+ handle_dump_config_files
+ source_dump_file
+
check_config
if [ $? -ne 0 ]; then
echo "Starting kdump: [FAILED]"
@@ -1215,11 +1230,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
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 dcf074ced3fb..6ce4e218a722 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: 7%{?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 e0bc9f1f7e1b..3e80be9e3a86 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 b/mkdumprd
index f30d9c27cb1b..9644d7a6bd77 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -11,7 +11,7 @@
. /lib/kdump/kdump-lib.sh
export IN_KDUMP=1
-conf_file="/etc/kdump.conf"
+conf_file="/etc/kdump/kdump.conf"
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
@@ -305,7 +305,7 @@ handle_default_dump_target()
get_default_action_target()
{
local _target
- local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk '{print $2}')
+ local _action=$(grep "^default" $conf_file 2>/dev/null | awk '{print $2}')
if [ -n "$_action" ] && [ "$_action" = "dump_to_rootfs" ]; then
#get rootfs device name
_target=$(findmnt -k -f -n -o SOURCE /)
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.
--
2.7.4