2020-10-15 12:45:57 +00:00
|
|
|
#!/bin/bash --norc
|
|
|
|
# New mkdumprd
|
|
|
|
#
|
|
|
|
# Copyright 2011 Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# Written by Cong Wang <amwang@redhat.com>
|
|
|
|
#
|
|
|
|
|
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
upstream: fedora
resolves: bz2003832
conflict:
function load_kdump_kernel_key() not presented in rhel9,
so related patch hunk are removed.
commit 70978c00e5a573f0901ac404067eaea2c6536370
Author: Kairui Song <kasong@redhat.com>
Date: Wed Sep 8 17:20:51 2021 +0800
bash scripts: replace '[ ]' with '[[ ]]' for bash scripts
kdumpctl, mkdumprd, *-module-setup.sh only target bash, since they
only run in first kernel and depend on dracut, and dracut depends
on bash. So use '[[ ]]' to replace '[ ]'.
This is a batch update done with following command:
`sed -i -e 's/\(\s\)\[\s\([^]]*\)\s\]/\1\[\[\ \2 \]\]/g' kdumpctl, mkdumprd, *-module-setup.sh`
and replaced [ ... -a ... ] with [[ ... ]] && [[ ... ]] manually.
See https://tldp.org/LDP/abs/html/testconstructs.html for more details
on '[[ ]]', it's more versatile, safer, and slightly faster than '[ ]'.
This will also help shfmt to clean up the code in later commits.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2021-11-09 13:13:59 +00:00
|
|
|
if [[ -f /etc/sysconfig/kdump ]]; then
|
2020-11-05 05:34:29 +00:00
|
|
|
. /etc/sysconfig/kdump
|
|
|
|
fi
|
|
|
|
|
2020-10-15 12:45:57 +00:00
|
|
|
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
|
|
|
. $dracutbasedir/dracut-functions.sh
|
|
|
|
. /lib/kdump/kdump-lib.sh
|
2021-01-22 08:12:00 +00:00
|
|
|
. /lib/kdump/kdump-logger.sh
|
2020-10-15 12:45:57 +00:00
|
|
|
export IN_KDUMP=1
|
|
|
|
|
2020-11-05 05:34:29 +00:00
|
|
|
#initiate the kdump logger
|
2021-11-09 13:35:45 +00:00
|
|
|
if ! dlog_init; then
|
2020-11-05 05:34:29 +00:00
|
|
|
echo "failed to initiate the kdump logger."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-10-15 12:45:57 +00:00
|
|
|
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
|
|
|
|
SAVE_PATH=$(get_save_path)
|
|
|
|
OVERRIDE_RESETTABLE=0
|
|
|
|
|
|
|
|
extra_modules=""
|
Add kdump dracut config
Resolves: RHEL-49590
Upstream: https://github.com/rhkdump/kdump-utils
Conflict: Yes, kexec-tools is split into 3 parts upstream, some changes should
be applied to kdump-utils Makefile, but RHEL-9 kexec-tools doesn't have that.
Also missing upstream commits:
- 1732a3b(mkdumprd: Omit rdma module)
- 7fec2f56(mkdumprd: simplify handling of dracut arguments)
commit dacb34341113fa925c15e28a7ce56a80dd370e2f
Author: Lichen Liu <lichliu@redhat.com>
Date: Tue Nov 5 12:07:42 2024 +0800
Add kdump dracut config
In some cases, customizing the first kernel's initrd is necessary by
modifying the dracut `omit_dracutmodules` options, such as in Bootc
or CoreOS scenarios [1]. However, these changes can unintentionally
break existing functionality in kdump. For instance, setting
`omit_dracutmodules='nfs'` prevents the `nfs` module from being added.
Additionally, some dracut configurations [2] use
`dracutmodules+='some modules'` instead of
`add_dracutmodules+='some modules'`. When `dracutmodules` is non-empty,
dracut includes only the specified modules, which can result in an
initrd that lacks necessary modules, causing kdump to fail.
Dracut upstream support --add-confdir now, kdump can use this
option when building kdump initramfs.
This patch moved the hardcoded dracutmodules from mkdumprd to the new
conf file /lib/kdump/dracut.conf.d/99-kdump.conf, it is easier to check
and modify to omit or add certain modules. This patch also initialize
dracutmodules to empty to avoid the influence of other configurations.
See also:
[1] https://github.com/rhkdump/kdump-utils/issues/11
[2] https://issues.redhat.com/browse/RHEL-49590?focusedId=25197134&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-25197134
Suggested-by: Dave Young <dyoung@redhat.com>
Suggested-by: Colin Walters <walters@verbum.org>
Signed-off-by: Lichen Liu <lichliu@redhat.com>
Signed-off-by: Lichen Liu <lichliu@redhat.com>
2024-12-05 02:45:27 +00:00
|
|
|
dracut_args=(--quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict --hostonly-nics '')
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-03 09:30:56 +00:00
|
|
|
MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
|
2020-10-15 12:45:57 +00:00
|
|
|
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
|
2021-11-03 09:30:56 +00:00
|
|
|
MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
|
|
|
trap '
|
|
|
|
ret=$?;
|
|
|
|
is_mounted $MKDUMPRD_TMPMNT && umount -f $MKDUMPRD_TMPMNT;
|
|
|
|
[[ -d $MKDUMPRD_TMPDIR ]] && rm --one-file-system -rf -- "$MKDUMPRD_TMPDIR";
|
|
|
|
exit $ret;
|
|
|
|
' EXIT
|
|
|
|
|
|
|
|
# clean up after ourselves no matter how we die.
|
|
|
|
trap 'exit 1;' SIGINT
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_dracut_arg()
|
|
|
|
{
|
|
|
|
dracut_args+=("$@")
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_dracut_mount()
|
|
|
|
{
|
|
|
|
add_dracut_arg "--mount" "$1"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_dracut_sshkey()
|
|
|
|
{
|
|
|
|
add_dracut_arg "--sshkey" "$1"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# caller should ensure $1 is valid and mounted in 1st kernel
|
2021-11-09 13:42:45 +00:00
|
|
|
to_mount()
|
|
|
|
{
|
Introduce vmcore creation notification to kdump
Upstream: fedora
Resolves: RHEL-32060
Conflict: Yes, there are several conflicts. 1) Upstream have moved
dracut-kdump.sh into kdump-utils/dracut/99kdumpbase/kdump.sh,
so the targeting files are changed. 2) There are several
patchsets([1] [2]) which not backported to rhel9, so some
formating conflicts encountered. But there is no functional
change been made for the patch backporting.
[1]: https://github.com/rhkdump/kdump-utils/pull/18/commits
[2]: https://github.com/rhkdump/kdump-utils/pull/33/commits
commit 88525ebf5e43cc86aea66dc75ec83db58233883b
Author: Tao Liu <ltao@redhat.com>
Date: Thu Sep 5 15:49:07 2024 +1200
Introduce vmcore creation notification to kdump
Motivation
==========
People may forget to recheck to ensure kdump works, which as a result, a
possibility of no vmcores generated after a real system crash. It is
unexpected for kdump.
It is highly recommended people to recheck kdump after any system
modification, such as:
a. after kernel patching or whole yum update, as it might break something
on which kdump is dependent, maybe due to introduction of any new bug etc.
b. after any change at hardware level, maybe storage, networking,
firmware upgrading etc.
c. after implementing any new application, like which involves 3rd party modules
etc.
Though these exceed the range of kdump, however a simple vmcore creation
status notification is good to have for now.
Design
======
Kdump currently will check any relating files/fs/drivers modified before
determine if initrd should rebuild when (re)start. A rebuild is an
indicator of such modification, and kdump need to be rechecked. This will
clear the vmcore creation status specified in $VMCORE_CREATION_STATUS.
Vmcore creation check will happen at "kdumpctl (re)start/status", and will
report the creation success/fail status to users. A "success" status indicates
previously there has been a vmcore successfully generated based on the current
env, so it is more likely a vmcore will be generated later when real crash
happens; A "fail" status indicates previously there was no vmcore
generated, or has been a vmcore creation failed based on current env. User
should check the 2nd kernel log or the kexec-dmesg.log for the failing reason.
$VMCORE_CREATION_STATUS is used for recording the vmcore creation status of
the current env. The format will be like:
success 1718682002
Which means, there has been a vmcore generated successfully at this
timestamp for the current env.
Usage
=====
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: No vmcore creation test performed!
[root@localhost ~]# kdumpctl test
[root@localhost ~]# kdumpctl status
kdump: Kdump is operational
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
The notification for kdumpctl (re)start/status can be disabled by
setting VMCORE_CREATION_NOTIFICATION in /etc/sysconfig/kdump
Signed-off-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2024-10-08 01:48:04 +00:00
|
|
|
local _target=$1 _fstype=$2 _options=$3 _new_mntpoint=$4
|
|
|
|
local _sed_cmd _pdev
|
2021-11-09 13:42:45 +00:00
|
|
|
|
Introduce vmcore creation notification to kdump
Upstream: fedora
Resolves: RHEL-32060
Conflict: Yes, there are several conflicts. 1) Upstream have moved
dracut-kdump.sh into kdump-utils/dracut/99kdumpbase/kdump.sh,
so the targeting files are changed. 2) There are several
patchsets([1] [2]) which not backported to rhel9, so some
formating conflicts encountered. But there is no functional
change been made for the patch backporting.
[1]: https://github.com/rhkdump/kdump-utils/pull/18/commits
[2]: https://github.com/rhkdump/kdump-utils/pull/33/commits
commit 88525ebf5e43cc86aea66dc75ec83db58233883b
Author: Tao Liu <ltao@redhat.com>
Date: Thu Sep 5 15:49:07 2024 +1200
Introduce vmcore creation notification to kdump
Motivation
==========
People may forget to recheck to ensure kdump works, which as a result, a
possibility of no vmcores generated after a real system crash. It is
unexpected for kdump.
It is highly recommended people to recheck kdump after any system
modification, such as:
a. after kernel patching or whole yum update, as it might break something
on which kdump is dependent, maybe due to introduction of any new bug etc.
b. after any change at hardware level, maybe storage, networking,
firmware upgrading etc.
c. after implementing any new application, like which involves 3rd party modules
etc.
Though these exceed the range of kdump, however a simple vmcore creation
status notification is good to have for now.
Design
======
Kdump currently will check any relating files/fs/drivers modified before
determine if initrd should rebuild when (re)start. A rebuild is an
indicator of such modification, and kdump need to be rechecked. This will
clear the vmcore creation status specified in $VMCORE_CREATION_STATUS.
Vmcore creation check will happen at "kdumpctl (re)start/status", and will
report the creation success/fail status to users. A "success" status indicates
previously there has been a vmcore successfully generated based on the current
env, so it is more likely a vmcore will be generated later when real crash
happens; A "fail" status indicates previously there was no vmcore
generated, or has been a vmcore creation failed based on current env. User
should check the 2nd kernel log or the kexec-dmesg.log for the failing reason.
$VMCORE_CREATION_STATUS is used for recording the vmcore creation status of
the current env. The format will be like:
success 1718682002
Which means, there has been a vmcore generated successfully at this
timestamp for the current env.
Usage
=====
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: No vmcore creation test performed!
[root@localhost ~]# kdumpctl test
[root@localhost ~]# kdumpctl status
kdump: Kdump is operational
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
The notification for kdumpctl (re)start/status can be disabled by
setting VMCORE_CREATION_NOTIFICATION in /etc/sysconfig/kdump
Signed-off-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2024-10-08 01:48:04 +00:00
|
|
|
_new_mntpoint="${_new_mntpoint:-$(get_kdump_mntpoint_from_target "$_target")}"
|
2021-11-09 13:42:45 +00:00
|
|
|
_fstype="${_fstype:-$(get_fs_type_from_target "$_target")}"
|
|
|
|
_options="${_options:-$(get_mntopt_from_target "$_target")}"
|
|
|
|
_options="${_options:-defaults}"
|
|
|
|
|
|
|
|
if [[ $_fstype == "nfs"* ]]; then
|
|
|
|
_pdev=$_target
|
2021-11-09 14:47:22 +00:00
|
|
|
_sed_cmd+='s/,\(mount\)\?addr=[^,]*//g;'
|
|
|
|
_sed_cmd+='s/,\(mount\)\?proto=[^,]*//g;'
|
2021-11-09 13:42:45 +00:00
|
|
|
_sed_cmd+='s/,clientaddr=[^,]*//;'
|
|
|
|
else
|
|
|
|
# for non-nfs _target converting to use udev persistent name
|
|
|
|
_pdev="$(kdump_get_persistent_dev "$_target")"
|
|
|
|
if [[ -z $_pdev ]]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# mount fs target as rw in 2nd kernel
|
|
|
|
_sed_cmd+='s/\(^\|,\)ro\($\|,\)/\1rw\2/g;'
|
|
|
|
# with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
|
|
|
|
# kernel, filter it out here.
|
|
|
|
_sed_cmd+='s/\(^\|,\)noauto\($\|,\)/\1/g;'
|
|
|
|
# drop nofail or nobootwait
|
|
|
|
_sed_cmd+='s/\(^\|,\)nofail\($\|,\)/\1/g;'
|
|
|
|
_sed_cmd+='s/\(^\|,\)nobootwait\($\|,\)/\1/g;'
|
|
|
|
|
|
|
|
_options=$(echo "$_options" | sed "$_sed_cmd")
|
|
|
|
|
|
|
|
echo "$_pdev $_new_mntpoint $_fstype $_options"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Function: get_ssh_size
|
|
|
|
#$1=dump target
|
|
|
|
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
2021-11-09 13:42:45 +00:00
|
|
|
get_ssh_size()
|
|
|
|
{
|
|
|
|
local _out
|
|
|
|
local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes")
|
2021-11-03 07:36:02 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then
|
|
|
|
perror_exit "checking remote ssh server available size failed."
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
echo -n "$_out" | tail -1
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#mkdir if save path does not exist on ssh dump target
|
|
|
|
#$1=ssh dump target
|
|
|
|
#caller should ensure write permission on $1:$SAVE_PATH
|
|
|
|
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
|
|
|
mkdir_save_path_ssh()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _opt _dir
|
|
|
|
_opt=(-i "$SSH_KEY_LOCATION" -o BatchMode=yes -o StrictHostKeyChecking=yes)
|
|
|
|
ssh -qn "${_opt[@]}" "$1" mkdir -p "$SAVE_PATH" &> /dev/null ||
|
|
|
|
perror_exit "mkdir failed on $1:$SAVE_PATH"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
# check whether user has write permission on $1:$SAVE_PATH
|
|
|
|
_dir=$(ssh -qn "${_opt[@]}" "$1" mktemp -dqp "$SAVE_PATH" 2> /dev/null) ||
|
|
|
|
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
|
|
|
|
ssh -qn "${_opt[@]}" "$1" rmdir "$_dir"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
return 0
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Function: get_fs_size
|
|
|
|
#$1=dump target
|
2021-11-09 13:42:45 +00:00
|
|
|
get_fs_size()
|
|
|
|
{
|
|
|
|
df --output=avail "$(get_mntpoint_from_target "$1")/$SAVE_PATH" | tail -1
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Function: get_raw_size
|
|
|
|
#$1=dump target
|
2021-11-09 13:42:45 +00:00
|
|
|
get_raw_size()
|
|
|
|
{
|
|
|
|
fdisk -s "$1"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Function: check_size
|
|
|
|
#$1: dump type string ('raw', 'fs', 'ssh')
|
|
|
|
#$2: dump target
|
2021-11-09 13:42:45 +00:00
|
|
|
check_size()
|
|
|
|
{
|
|
|
|
local avail memtotal
|
|
|
|
|
|
|
|
memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
|
|
|
|
case "$1" in
|
|
|
|
raw)
|
|
|
|
avail=$(get_raw_size "$2")
|
|
|
|
;;
|
|
|
|
ssh)
|
|
|
|
avail=$(get_ssh_size "$2")
|
|
|
|
;;
|
|
|
|
fs)
|
|
|
|
avail=$(get_fs_size "$2")
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
return
|
|
|
|
;;
|
|
|
|
esac || perror_exit "Check dump target size failed"
|
|
|
|
|
|
|
|
if [[ $avail -lt $memtotal ]]; then
|
|
|
|
dwarn "Warning: There might not be enough space to save a vmcore."
|
|
|
|
dwarn " The size of $2 should be greater than $memtotal kilo bytes."
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_save_path_fs()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _path=$1
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
if [[ ! -d $_path ]]; then
|
|
|
|
perror_exit "Dump path $_path does not exist."
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 12:41:42 +00:00
|
|
|
mount_failure()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _target=$1
|
|
|
|
local _mnt=$2
|
|
|
|
local _fstype=$3
|
|
|
|
local msg="Failed to mount $_target"
|
2021-11-09 12:41:42 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
if [[ -n $_mnt ]]; then
|
|
|
|
msg="$msg on $_mnt"
|
|
|
|
fi
|
2021-11-09 12:41:42 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
msg="$msg for kdump preflight check."
|
2021-11-09 12:41:42 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
if [[ $_fstype == "nfs" ]]; then
|
|
|
|
msg="$msg Please make sure nfs-utils has been installed."
|
|
|
|
fi
|
2021-11-09 12:41:42 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
perror_exit "$msg"
|
2021-11-09 12:41:42 +00:00
|
|
|
}
|
|
|
|
|
2020-10-15 12:45:57 +00:00
|
|
|
check_user_configured_target()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _target=$1 _cfg_fs_type=$2 _mounted
|
|
|
|
local _mnt _opt _fstype
|
|
|
|
|
|
|
|
_mnt=$(get_mntpoint_from_target "$_target")
|
|
|
|
_opt=$(get_mntopt_from_target "$_target")
|
|
|
|
_fstype=$(get_fs_type_from_target "$_target")
|
|
|
|
|
|
|
|
if [[ -n $_fstype ]]; then
|
|
|
|
# In case of nfs4, nfs should be used instead, nfs* options is deprecated in kdump.conf
|
|
|
|
[[ $_fstype == "nfs"* ]] && _fstype=nfs
|
|
|
|
|
|
|
|
if [[ -n $_cfg_fs_type ]] && [[ $_fstype != "$_cfg_fs_type" ]]; then
|
|
|
|
perror_exit "\"$_target\" have a wrong type config \"$_cfg_fs_type\", expected \"$_fstype\""
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
_fstype="$_cfg_fs_type"
|
|
|
|
_fstype="$_cfg_fs_type"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For noauto mount, mount it inplace with default value.
|
|
|
|
# Else use the temporary target directory
|
|
|
|
if [[ -n $_mnt ]]; then
|
|
|
|
if ! is_mounted "$_mnt"; then
|
|
|
|
if [[ $_opt == *",noauto"* ]]; then
|
|
|
|
mount "$_mnt" || mount_failure "$_target" "$_mnt" "$_fstype"
|
|
|
|
_mounted=$_mnt
|
|
|
|
else
|
|
|
|
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
_mnt=$MKDUMPRD_TMPMNT
|
|
|
|
mkdir -p "$_mnt"
|
|
|
|
mount "$_target" "$_mnt" -t "$_fstype" -o defaults || mount_failure "$_target" "" "$_fstype"
|
|
|
|
_mounted=$_mnt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For user configured target, use $SAVE_PATH as the dump path within the target
|
|
|
|
if [[ ! -d "$_mnt/$SAVE_PATH" ]]; then
|
2022-09-21 09:13:44 +00:00
|
|
|
perror_exit "Dump path \"$SAVE_PATH\" does not exist in dump target \"$_target\""
|
2021-11-09 13:42:45 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
check_size fs "$_target"
|
|
|
|
|
|
|
|
# Unmount it early, if function is interrupted and didn't reach here, the shell trap will clear it up anyway
|
|
|
|
if [[ -n $_mounted ]]; then
|
|
|
|
umount -f -- "$_mounted"
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: core_collector config value
|
2021-11-09 13:42:45 +00:00
|
|
|
verify_core_collector()
|
|
|
|
{
|
|
|
|
local _cmd="${1%% *}"
|
2024-05-09 06:45:17 +00:00
|
|
|
local _params="${1#${_cmd}}"
|
2021-11-09 13:42:45 +00:00
|
|
|
|
|
|
|
if [[ $_cmd != "makedumpfile" ]]; then
|
|
|
|
if is_raw_dump_target; then
|
|
|
|
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
|
|
|
fi
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if is_ssh_dump_target || is_raw_dump_target; then
|
|
|
|
if ! strstr "$_params" "-F"; then
|
|
|
|
perror_exit 'The specified dump target needs makedumpfile "-F" option.'
|
|
|
|
fi
|
|
|
|
_params="$_params vmcore"
|
|
|
|
else
|
|
|
|
_params="$_params vmcore dumpfile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
if ! $_cmd --check-params $_params; then
|
|
|
|
perror_exit "makedumpfile parameter check failed."
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_mount()
|
|
|
|
{
|
|
|
|
local _mnt
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
_mnt=$(to_mount "$@") || exit 1
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_dracut_mount "$_mnt"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#handle the case user does not specify the dump target explicitly
|
|
|
|
handle_default_dump_target()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _target
|
|
|
|
local _mntpoint
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
is_user_configured_dump_target && return
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
check_save_path_fs "$SAVE_PATH"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
_save_path=$(get_bind_mount_source "$SAVE_PATH")
|
|
|
|
_target=$(get_target_from_path "$_save_path")
|
|
|
|
_mntpoint=$(get_mntpoint_from_target "$_target")
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
SAVE_PATH=${_save_path##"$_mntpoint"}
|
|
|
|
add_mount "$_target"
|
|
|
|
check_size fs "$_target"
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
# $1: function name
|
|
|
|
for_each_block_target()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local dev majmin
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
for dev in $(get_kdump_targets); do
|
|
|
|
[[ -b $dev ]] || continue
|
|
|
|
majmin=$(get_maj_min "$dev")
|
|
|
|
check_block_and_slaves "$1" "$majmin" && return 1
|
|
|
|
done
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
return 0
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#judge if a specific device with $1 is unresettable
|
|
|
|
#return false if unresettable.
|
|
|
|
is_unresettable()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local path device resettable=1
|
|
|
|
|
|
|
|
path="/sys/$(udevadm info --query=all --path="/sys/dev/block/$1" | awk '/^P:/ {print $2}' | sed -e 's/\(cciss[0-9]\+\/\).*/\1/g' -e 's/\/block\/.*$//')/resettable"
|
|
|
|
if [[ -f $path ]]; then
|
|
|
|
resettable="$(< "$path")"
|
|
|
|
[[ $resettable -eq 0 ]] && [[ $OVERRIDE_RESETTABLE -eq 0 ]] && {
|
|
|
|
device=$(udevadm info --query=all --path="/sys/dev/block/$1" | awk -F= '/DEVNAME/{print $2}')
|
|
|
|
derror "Error: Can not save vmcore because device $device is unresettable"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#check if machine is resettable.
|
|
|
|
#return true if resettable
|
|
|
|
check_resettable()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _target _override_resettable
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
_override_resettable=$(kdump_get_conf_val override_resettable)
|
|
|
|
OVERRIDE_RESETTABLE=${_override_resettable:-$OVERRIDE_RESETTABLE}
|
|
|
|
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ]; then
|
|
|
|
perror_exit "override_resettable value '$OVERRIDE_RESETTABLE' is invalid"
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
for_each_block_target is_unresettable && return
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
return 1
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
check_crypt()
|
|
|
|
{
|
2021-11-09 13:42:45 +00:00
|
|
|
local _dev
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
for _dev in $(get_kdump_targets); do
|
|
|
|
if [[ -n $(get_luks_crypt_dev "$(get_maj_min "$_dev")") ]]; then
|
|
|
|
derror "Device $_dev is encrypted." && return 1
|
|
|
|
fi
|
|
|
|
done
|
2020-10-15 12:45:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ! check_resettable; then
|
2021-11-09 13:42:45 +00:00
|
|
|
exit 1
|
2020-10-15 12:45:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if ! check_crypt; then
|
2021-11-09 13:42:45 +00:00
|
|
|
dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details."
|
2020-10-15 12:45:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# firstly get right SSH_KEY_LOCATION
|
2021-11-03 07:31:19 +00:00
|
|
|
keyfile=$(kdump_get_conf_val sshkey)
|
2021-11-09 13:42:45 +00:00
|
|
|
if [[ -f $keyfile ]]; then
|
|
|
|
# canonicalize the path
|
|
|
|
SSH_KEY_LOCATION=$(/usr/bin/readlink -m "$keyfile")
|
2020-10-15 12:45:57 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
while read -r config_opt config_val; do
|
|
|
|
# remove inline comments after the end of a directive.
|
|
|
|
case "$config_opt" in
|
|
|
|
extra_modules)
|
|
|
|
extra_modules="$extra_modules $config_val"
|
|
|
|
;;
|
2022-10-26 02:24:57 +00:00
|
|
|
ext[234] | xfs | btrfs | minix | nfs | virtiofs)
|
2021-11-09 13:42:45 +00:00
|
|
|
check_user_configured_target "$config_val" "$config_opt"
|
|
|
|
add_mount "$config_val" "$config_opt"
|
|
|
|
;;
|
|
|
|
raw)
|
|
|
|
# checking raw disk writable
|
|
|
|
dd if="$config_val" count=1 of=/dev/null > /dev/null 2>&1 || {
|
|
|
|
perror_exit "Bad raw disk $config_val"
|
|
|
|
}
|
|
|
|
_praw=$(persistent_policy="by-id" kdump_get_persistent_dev "$config_val")
|
|
|
|
if [[ -z $_praw ]]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
add_dracut_arg "--device" "$_praw"
|
|
|
|
check_size raw "$config_val"
|
|
|
|
;;
|
|
|
|
ssh)
|
|
|
|
if strstr "$config_val" "@"; then
|
|
|
|
mkdir_save_path_ssh "$config_val"
|
|
|
|
check_size ssh "$config_val"
|
|
|
|
add_dracut_sshkey "$SSH_KEY_LOCATION"
|
|
|
|
else
|
|
|
|
perror_exit "Bad ssh dump target $config_val"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
core_collector)
|
|
|
|
verify_core_collector "$config_val"
|
|
|
|
;;
|
|
|
|
dracut_args)
|
2023-03-21 08:01:22 +00:00
|
|
|
|
|
|
|
# When users specify nfs dumping via dracut_args, kexec-tools won't
|
|
|
|
# mount nfs fs beforehand thus nfsv4-related drivers won't be installed
|
|
|
|
# because we call dracut with --hostonly-mode strict. So manually install
|
|
|
|
# nfsv4-related drivers.
|
|
|
|
if [[ $(get_dracut_args_fstype "$config_val") == nfs* ]]; then
|
|
|
|
add_dracut_arg "--add-drivers" nfs_layout_nfsv41_files
|
|
|
|
fi
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
while read -r dracut_arg; do
|
|
|
|
add_dracut_arg "$dracut_arg"
|
|
|
|
done <<< "$(echo "$config_val" | xargs -n 1 echo)"
|
|
|
|
;;
|
|
|
|
*) ;;
|
|
|
|
|
|
|
|
esac
|
2021-11-03 07:12:31 +00:00
|
|
|
done <<< "$(kdump_read_conf)"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
|
|
|
handle_default_dump_target
|
|
|
|
|
2022-01-06 06:23:41 +00:00
|
|
|
if ! have_compression_in_dracut_args; then
|
Seperate dracut and dracut-squash compressor for zstd
Upstream: fedora
Resolves: bz2045949
Resolves: bz2044804
Conflict: none
commit fc1c79ffd21e7bcb3a710368cd7023c9a634258e
Author: Tao Liu <ltao@redhat.com>
Date: Sat Oct 8 12:09:08 2022 +0800
Seperate dracut and dracut-squash compressor for zstd
Previously kexec-tools will pass "--compress zstd" to dracut. It
will make dracut to decide whether: a) call mksquashfs to make a
zstd format squash-root.img, b) call cmd zstd to make a initramfs.
Since dracut(>= 057) has decoupled the compressor for dracut and
dracut-squash, So in this patch, we will pass the compressor seperately.
Note:
The is_squash_available && !dracut_has_option --squash-compressor
&& !is_zsdt_command_available case is left unprocessed on purpose.
Actually, the situation when we want to call zstd compression is:
1) If squash function OK, we want dracut to invoke mksquashfs to make
a zstd format squash-root.img within initramfs.
2) If squash function is not OK, and cmd zstd presents, we want dracut
to invoke cmd zstd to make a zstd format initramfs.
is_zstd_command_available check can handle case 2 completely.
However, for the is_squash_available check, it cannot handle case 1
completely. It only checks if the kernel supports squashfs, it doesn't
check whether the squash module has been added by dracut when making
initramfs. In fact, in kexec-tools we are unable to do the check,
there are multiple ways to forbit dracut to load a module, such as
"dracut -o module" and "omit_dracutmodules in dracut.conf".
When squash dracut module is omitted, is_squash_available check will
still pass, so "--compress zstd" will be appended to dracut cmdline,
and it will call cmd zstd to do the compression. However cmd zstd may
not exist, so it fails.
The previous "--compress zstd" is ambiguous, after the intro of
"--squash-compressor", "--squash-compressor" only effect for
mksquashfs and "--compress" only effect for specific cmd.
So for the is_squash_available && !dracut_has_option
--squash-compressor && !is_zsdt_command_available case, we just leave
it to be handled the default way.
Reviewed-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2022-10-26 02:16:16 +00:00
|
|
|
if is_squash_available && dracut_have_option "--squash-compressor"; then
|
|
|
|
add_dracut_arg "--squash-compressor" "zstd"
|
|
|
|
elif is_zstd_command_available; then
|
2022-01-07 11:47:06 +00:00
|
|
|
add_dracut_arg "--compress" "zstd"
|
|
|
|
fi
|
2022-01-06 06:23:41 +00:00
|
|
|
fi
|
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
if [[ -n $extra_modules ]]; then
|
|
|
|
add_dracut_arg "--add-drivers" "$extra_modules"
|
2020-10-15 12:45:57 +00:00
|
|
|
fi
|
|
|
|
|
2021-07-12 08:07:05 +00:00
|
|
|
# TODO: The below check is not needed anymore with the introduction of
|
|
|
|
# 'zz-fadumpinit' module, that isolates fadump's capture kernel initrd,
|
|
|
|
# but still sysroot.mount unit gets generated based on 'root=' kernel
|
|
|
|
# parameter available in fadump case. So, find a way to fix that first
|
|
|
|
# before removing this check.
|
2020-10-15 12:45:57 +00:00
|
|
|
if ! is_fadump_capable; then
|
2021-11-09 13:42:45 +00:00
|
|
|
# The 2nd rootfs mount stays behind the normal dump target mount,
|
|
|
|
# so it doesn't affect the logic of check_dump_fs_modified().
|
|
|
|
is_dump_to_rootfs && add_mount "$(to_dev_name "$(get_root_fs_device)")"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
2021-11-09 13:42:45 +00:00
|
|
|
add_dracut_arg "--no-hostonly-default-device"
|
mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS
Resolves: https://issues.redhat.com/browse/RHEL-512
Upstream: Fedora
Conflict: None
commit 443a43e0750d14c8e3290ecf76535d1746bfac6a
Author: Coiby Xu <coxu@redhat.com>
Date: Wed May 24 12:01:45 2023 +0800
mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS
Currently, kdump doesn't work on many FIPS-enabled systems including
Azure, ESXI, Hyper, POWER and etc. When FIPS is enabled, it needs to
access /boot//.vmlinuz-xxx.hmac to verify the integrity of the kernel.
However, on those systems, /boot fails to be mounted due to a lack of
fs and block device drivers and the system just halted after failing to
verify the integrity of the kernel. For example, on Hyper-V, sd_mod, sg,
scsi_transport_fc, hv_storvsc and hv_vmbus need to be installed in order
for /boot to be mounted.
mkdumprd calls dracut with the --no-hostonly-default-device. Following
the documentation (man dracut),
--no-hostonly-default-device
Do not generate implicit host devices like root, swap, fstab, etc.
Use "--mount" or "--add-device" to explicitly add devices as needed
this patch uses "--add-device" to explicitly add the device of /boot.
Note there is already an attempt to fix it in dracut's 01fips module
i.e. via the commit 83651776 ("fips: ensure fs module for /boot is
installed"). Unfortunately it only installs the file system driver e.g.
xfs.
Reviewed-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
2023-05-29 02:43:57 +00:00
|
|
|
|
2023-06-01 08:42:27 +00:00
|
|
|
if fips-mode-setup --is-enabled 2> /dev/null; then
|
mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS
Resolves: https://issues.redhat.com/browse/RHEL-512
Upstream: Fedora
Conflict: None
commit 443a43e0750d14c8e3290ecf76535d1746bfac6a
Author: Coiby Xu <coxu@redhat.com>
Date: Wed May 24 12:01:45 2023 +0800
mkdumprd: call dracut with --add-device to install the drivers needed by /boot partition automatically for FIPS
Currently, kdump doesn't work on many FIPS-enabled systems including
Azure, ESXI, Hyper, POWER and etc. When FIPS is enabled, it needs to
access /boot//.vmlinuz-xxx.hmac to verify the integrity of the kernel.
However, on those systems, /boot fails to be mounted due to a lack of
fs and block device drivers and the system just halted after failing to
verify the integrity of the kernel. For example, on Hyper-V, sd_mod, sg,
scsi_transport_fc, hv_storvsc and hv_vmbus need to be installed in order
for /boot to be mounted.
mkdumprd calls dracut with the --no-hostonly-default-device. Following
the documentation (man dracut),
--no-hostonly-default-device
Do not generate implicit host devices like root, swap, fstab, etc.
Use "--mount" or "--add-device" to explicitly add devices as needed
this patch uses "--add-device" to explicitly add the device of /boot.
Note there is already an attempt to fix it in dracut's 01fips module
i.e. via the commit 83651776 ("fips: ensure fs module for /boot is
installed"). Unfortunately it only installs the file system driver e.g.
xfs.
Reviewed-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
2023-05-29 02:43:57 +00:00
|
|
|
add_dracut_arg --add-device "$(findmnt -n -o SOURCE --target /boot)"
|
|
|
|
fi
|
2020-10-15 12:45:57 +00:00
|
|
|
fi
|
|
|
|
|
2022-01-24 01:27:24 +00:00
|
|
|
# This is RHEL-only to work around nvme problem, then real fix should go to dracut
|
|
|
|
if [[ -d /sys/module/nvme ]]; then
|
|
|
|
add_dracut_arg "--add-drivers" "nvme"
|
|
|
|
fi
|
|
|
|
|
Introduce vmcore creation notification to kdump
Upstream: fedora
Resolves: RHEL-32060
Conflict: Yes, there are several conflicts. 1) Upstream have moved
dracut-kdump.sh into kdump-utils/dracut/99kdumpbase/kdump.sh,
so the targeting files are changed. 2) There are several
patchsets([1] [2]) which not backported to rhel9, so some
formating conflicts encountered. But there is no functional
change been made for the patch backporting.
[1]: https://github.com/rhkdump/kdump-utils/pull/18/commits
[2]: https://github.com/rhkdump/kdump-utils/pull/33/commits
commit 88525ebf5e43cc86aea66dc75ec83db58233883b
Author: Tao Liu <ltao@redhat.com>
Date: Thu Sep 5 15:49:07 2024 +1200
Introduce vmcore creation notification to kdump
Motivation
==========
People may forget to recheck to ensure kdump works, which as a result, a
possibility of no vmcores generated after a real system crash. It is
unexpected for kdump.
It is highly recommended people to recheck kdump after any system
modification, such as:
a. after kernel patching or whole yum update, as it might break something
on which kdump is dependent, maybe due to introduction of any new bug etc.
b. after any change at hardware level, maybe storage, networking,
firmware upgrading etc.
c. after implementing any new application, like which involves 3rd party modules
etc.
Though these exceed the range of kdump, however a simple vmcore creation
status notification is good to have for now.
Design
======
Kdump currently will check any relating files/fs/drivers modified before
determine if initrd should rebuild when (re)start. A rebuild is an
indicator of such modification, and kdump need to be rechecked. This will
clear the vmcore creation status specified in $VMCORE_CREATION_STATUS.
Vmcore creation check will happen at "kdumpctl (re)start/status", and will
report the creation success/fail status to users. A "success" status indicates
previously there has been a vmcore successfully generated based on the current
env, so it is more likely a vmcore will be generated later when real crash
happens; A "fail" status indicates previously there was no vmcore
generated, or has been a vmcore creation failed based on current env. User
should check the 2nd kernel log or the kexec-dmesg.log for the failing reason.
$VMCORE_CREATION_STATUS is used for recording the vmcore creation status of
the current env. The format will be like:
success 1718682002
Which means, there has been a vmcore generated successfully at this
timestamp for the current env.
Usage
=====
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: No vmcore creation test performed!
[root@localhost ~]# kdumpctl test
[root@localhost ~]# kdumpctl status
kdump: Kdump is operational
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
[root@localhost ~]# kdumpctl restart
kdump: kexec: unloaded kdump kernel
kdump: Stopping kdump: [OK]
kdump: kexec: loaded kdump kernel
kdump: Starting kdump: [OK]
kdump: Notice: Last successful vmcore creation on Tue Jun 18 16:39:10 CST 2024
The notification for kdumpctl (re)start/status can be disabled by
setting VMCORE_CREATION_NOTIFICATION in /etc/sysconfig/kdump
Signed-off-by: Tao Liu <ltao@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
2024-10-08 01:48:04 +00:00
|
|
|
status_target=$(get_target_from_path $(dirname "$VMCORE_CREATION_STATUS"))
|
|
|
|
|
|
|
|
if [[ $(get_root_fs_device) != "$status_target" ]]; then
|
|
|
|
new_mntpoint=$(echo /vmcorestatus/$(get_mntpoint_from_target "$status_target") \
|
|
|
|
| tr -s "/")
|
|
|
|
add_mount "$status_target" "" "" "$new_mntpoint"
|
|
|
|
elif ! is_fadump_capable && \
|
|
|
|
! [[ ${dracut_args[@]} == *"$(kdump_get_persistent_dev $status_target)"* ]]; then
|
|
|
|
add_mount "$status_target"
|
|
|
|
fi
|
|
|
|
|
Add kdump dracut config
Resolves: RHEL-49590
Upstream: https://github.com/rhkdump/kdump-utils
Conflict: Yes, kexec-tools is split into 3 parts upstream, some changes should
be applied to kdump-utils Makefile, but RHEL-9 kexec-tools doesn't have that.
Also missing upstream commits:
- 1732a3b(mkdumprd: Omit rdma module)
- 7fec2f56(mkdumprd: simplify handling of dracut arguments)
commit dacb34341113fa925c15e28a7ce56a80dd370e2f
Author: Lichen Liu <lichliu@redhat.com>
Date: Tue Nov 5 12:07:42 2024 +0800
Add kdump dracut config
In some cases, customizing the first kernel's initrd is necessary by
modifying the dracut `omit_dracutmodules` options, such as in Bootc
or CoreOS scenarios [1]. However, these changes can unintentionally
break existing functionality in kdump. For instance, setting
`omit_dracutmodules='nfs'` prevents the `nfs` module from being added.
Additionally, some dracut configurations [2] use
`dracutmodules+='some modules'` instead of
`add_dracutmodules+='some modules'`. When `dracutmodules` is non-empty,
dracut includes only the specified modules, which can result in an
initrd that lacks necessary modules, causing kdump to fail.
Dracut upstream support --add-confdir now, kdump can use this
option when building kdump initramfs.
This patch moved the hardcoded dracutmodules from mkdumprd to the new
conf file /lib/kdump/dracut.conf.d/99-kdump.conf, it is easier to check
and modify to omit or add certain modules. This patch also initialize
dracutmodules to empty to avoid the influence of other configurations.
See also:
[1] https://github.com/rhkdump/kdump-utils/issues/11
[2] https://issues.redhat.com/browse/RHEL-49590?focusedId=25197134&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-25197134
Suggested-by: Dave Young <dyoung@redhat.com>
Suggested-by: Colin Walters <walters@verbum.org>
Signed-off-by: Lichen Liu <lichliu@redhat.com>
Signed-off-by: Lichen Liu <lichliu@redhat.com>
2024-12-05 02:45:27 +00:00
|
|
|
# Use kdump managed dracut profile.
|
|
|
|
[[ $kdump_dracut_confdir ]] || kdump_dracut_confdir=/lib/kdump/dracut.conf.d
|
|
|
|
if [[ "$(dracut --help)" == *--add-confdir* ]] && [[ -d "$kdump_dracut_confdir" ]]; then
|
|
|
|
dracut_args+=("--add-confdir" "$kdump_dracut_confdir")
|
|
|
|
else
|
|
|
|
dracut_args+=(--add kdumpbase)
|
|
|
|
dracut_args+=(--omit "plymouth resume ifcfg earlykdump")
|
|
|
|
fi
|
|
|
|
|
2021-11-03 07:32:36 +00:00
|
|
|
dracut "${dracut_args[@]}" "$@"
|
2020-10-15 12:45:57 +00:00
|
|
|
|
|
|
|
_rc=$?
|
|
|
|
sync
|
|
|
|
exit $_rc
|