2006-07-20 03:36:18 +00:00
|
|
|
#!/bin/bash --norc
|
2011-07-21 10:51:33 +00:00
|
|
|
# New mkdumprd
|
2006-07-20 03:36:18 +00:00
|
|
|
#
|
2011-07-21 10:51:33 +00:00
|
|
|
# Copyright 2011 Red Hat, Inc.
|
2006-07-20 03:36:18 +00:00
|
|
|
#
|
2011-07-21 10:51:33 +00:00
|
|
|
# Written by Cong Wang <amwang@redhat.com>
|
2006-07-20 03:36:18 +00:00
|
|
|
#
|
|
|
|
|
2020-10-27 09:04:22 +00:00
|
|
|
if [ -f /etc/sysconfig/kdump ]; then
|
|
|
|
. /etc/sysconfig/kdump
|
|
|
|
fi
|
|
|
|
|
2016-11-17 04:51:12 +00:00
|
|
|
[[ $dracutbasedir ]] || dracutbasedir=/usr/lib/dracut
|
|
|
|
. $dracutbasedir/dracut-functions.sh
|
2013-09-24 13:33:27 +00:00
|
|
|
. /lib/kdump/kdump-lib.sh
|
2021-01-19 12:10:28 +00:00
|
|
|
. /lib/kdump/kdump-logger.sh
|
2011-07-21 10:51:33 +00:00
|
|
|
export IN_KDUMP=1
|
2006-07-20 03:36:18 +00:00
|
|
|
|
2020-10-27 09:04:22 +00:00
|
|
|
#initiate the kdump logger
|
|
|
|
dlog_init
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "failed to initiate the kdump logger."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-02-22 03:16:09 +00:00
|
|
|
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
|
2020-03-08 08:41:10 +00:00
|
|
|
SAVE_PATH=$(get_save_path)
|
2019-11-20 14:58:10 +00:00
|
|
|
OVERRIDE_RESETTABLE=0
|
|
|
|
|
|
|
|
extra_modules=""
|
2021-08-03 19:50:04 +00:00
|
|
|
dracut_args=( --add kdumpbase --quiet --hostonly --hostonly-cmdline --hostonly-i18n --hostonly-mode strict -o "plymouth dash resume ifcfg earlykdump" )
|
2015-04-10 08:18:57 +00:00
|
|
|
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
readonly MKDUMPRD_TMPDIR="$(mktemp -d -t mkdumprd.XXXXXX)"
|
|
|
|
[ -d "$MKDUMPRD_TMPDIR" ] || perror_exit "dracut: mktemp -p -d -t dracut.XXXXXX failed."
|
|
|
|
readonly MKDUMPRD_TMPMNT="$MKDUMPRD_TMPDIR/target"
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2011-07-21 10:51:33 +00:00
|
|
|
add_dracut_arg() {
|
2021-08-03 19:50:04 +00:00
|
|
|
dracut_args+=( "$@" )
|
2006-07-20 03:36:18 +00:00
|
|
|
}
|
|
|
|
|
2011-12-16 10:06:45 +00:00
|
|
|
add_dracut_mount() {
|
2021-08-03 19:50:04 +00:00
|
|
|
add_dracut_arg "--mount" "$1"
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 03:16:09 +00:00
|
|
|
add_dracut_sshkey() {
|
2021-08-03 19:50:04 +00:00
|
|
|
add_dracut_arg "--sshkey" "$1"
|
2012-02-22 03:16:09 +00:00
|
|
|
}
|
|
|
|
|
2013-03-05 08:07:36 +00:00
|
|
|
# caller should ensure $1 is valid and mounted in 1st kernel
|
2012-06-26 09:21:54 +00:00
|
|
|
to_mount() {
|
2020-06-16 03:33:39 +00:00
|
|
|
local _target=$1 _fstype=$2 _options=$3 _new_mntpoint _pdev
|
2020-03-12 12:57:08 +00:00
|
|
|
|
|
|
|
_new_mntpoint=$(get_kdump_mntpoint_from_target $_target)
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
_fstype="${_fstype:-$(get_fs_type_from_target $_target)}"
|
2020-05-22 09:18:06 +00:00
|
|
|
_options="${_options:-$(get_mntopt_from_target $_target)}"
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
_options="${_options:-defaults}"
|
2020-03-12 12:57:08 +00:00
|
|
|
|
|
|
|
if [[ "$_fstype" == "nfs"* ]]; then
|
2020-06-16 03:33:39 +00:00
|
|
|
_pdev=$_target
|
2020-03-12 12:57:08 +00:00
|
|
|
_options=$(echo $_options | sed 's/,addr=[^,]*//')
|
|
|
|
_options=$(echo $_options | sed 's/,proto=[^,]*//')
|
|
|
|
_options=$(echo $_options | sed 's/,clientaddr=[^,]*//')
|
2020-06-16 03:33:39 +00:00
|
|
|
else
|
|
|
|
# for non-nfs _target converting to use udev persistent name
|
|
|
|
_pdev="$(kdump_get_persistent_dev $_target)"
|
|
|
|
if [ -z "$_pdev" ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
2018-11-21 09:08:13 +00:00
|
|
|
fi
|
2020-03-12 12:57:08 +00:00
|
|
|
|
mkdumprd: refine regex on dropping mount options
Currently we use "\b" (word boundary) as the delimiter for ro option,
which is not correct. For mount options like
"defaults,errors=remount-ro" the ro on the tail will also be replaced
and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should
either starts with "," or "^" (begin of line) and ends with "," or "$"
(end of line), and keep the delimiter untouched. This should ensure
only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro,
defaults,errors=remount-ro => defaults,errors=remount-ro
defaults,ro,relatime => defaults,rw,relatime
defaults,ro => defaults,rw
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-01-28 05:21:33 +00:00
|
|
|
# mount fs target as rw in 2nd kernel
|
|
|
|
_options=$(echo $_options | sed 's/\(^\|,\)ro\($\|,\)/\1rw\2/g')
|
Partially Revert "Don't mount the dump target unless needed"
This partially reverts commit 6dee286467e5a697d25148712a110da1a720ac96.
There are reports that NFSv3 is failing after this commit, and after
more debug, I found NFSv4 may not work properly if
"nfs4_disable_idmapping" is set to 0.
The cause of the failure is that kdump.sh runs after dracut's pre-pivot
and clean up hook, many dracut module will install hooks to kill some
running services, so if the dump target requires a service to be running
but it's killed, mount will fail.
Dracut ensures the configured mount points are ready before pre-pivot.
After pre-pivot, any further mounting operation may not work as expected.
Although there is no report of other type of dump target failure except
NFSv3, it's better to revert this, to avoid other potential risk, and wait
for a proper fix for that systemd/kernel issue.
Else, this may bring more trouble for further development.
But still keep the change in kdump-lib-initramfs.sh for better
robustness.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-04-30 09:33:15 +00:00
|
|
|
# with 'noauto' in fstab nfs and non-root disk mount will fail in 2nd
|
|
|
|
# kernel, filter it out here.
|
mkdumprd: refine regex on dropping mount options
Currently we use "\b" (word boundary) as the delimiter for ro option,
which is not correct. For mount options like
"defaults,errors=remount-ro" the ro on the tail will also be replaced
and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should
either starts with "," or "^" (begin of line) and ends with "," or "$"
(end of line), and keep the delimiter untouched. This should ensure
only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro,
defaults,errors=remount-ro => defaults,errors=remount-ro
defaults,ro,relatime => defaults,rw,relatime
defaults,ro => defaults,rw
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-01-28 05:21:33 +00:00
|
|
|
_options=$(echo $_options | sed 's/\(^\|,\)noauto\($\|,\)/\1/g')
|
2018-08-09 02:15:52 +00:00
|
|
|
# drop nofail or nobootwait
|
mkdumprd: refine regex on dropping mount options
Currently we use "\b" (word boundary) as the delimiter for ro option,
which is not correct. For mount options like
"defaults,errors=remount-ro" the ro on the tail will also be replaced
and result in an invalid mount option.
So we use a more strict logic on detecting ro mount option. It should
either starts with "," or "^" (begin of line) and ends with "," or "$"
(end of line), and keep the delimiter untouched. This should ensure
only valid mount option got detected and replaced.
This passed following tests:
defaults,ro,noauto,errors=remount-ro,nobootwait,nofail => defaults,rw,errors=remount-ro,
defaults,errors=remount-ro => defaults,errors=remount-ro
defaults,ro,relatime => defaults,rw,relatime
defaults,ro => defaults,rw
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2019-01-28 05:21:33 +00:00
|
|
|
_options=$(echo $_options | sed 's/\(^\|,\)nofail\($\|,\)/\1/g')
|
|
|
|
_options=$(echo $_options | sed 's/\(^\|,\)nobootwait\($\|,\)/\1/g')
|
mkdumprd: remove useless "x-initrd.mount"
After the following systemd commit, "x-initrd.mount"
option became useless actually, we can safely remove
it now.
commit ce3f6d82b003f365f718f24e48f55b8a0372b924
Author: nmartensen <nis.martensen@web.de>
Date: Fri Jan 15 07:55:25 2016 +0100
fstab-generator: remove bogus condition
The sysroot mount is already taken care of by the
add_sysroot_mount function. With this condition
left in, we can we can get something like this:
initrd-root-fs.target.requires
`-- usr.mount -> /run/systemd/generator/usr.mount
in the main system (i.e., not in the initramfs). In
the initramfs, the previous condition already kicks in.
[snip]
"mount_in_initrd(me)" is true with "x-initrd.mount" option,
the behaviour of systemd fstab generator changed after the
above-mentioned patch, it always generates local mount units
required by local-fs.target regardless of "x-initrd.mount".
After failure, it enters dracut emergency, further triggers
kdump emergency service, thus there is no problem.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
2017-07-13 03:43:52 +00:00
|
|
|
|
2020-06-16 03:33:39 +00:00
|
|
|
echo "$_pdev $_new_mntpoint $_fstype $_options"
|
2012-06-26 09:21:54 +00:00
|
|
|
}
|
|
|
|
|
2012-06-26 09:21:53 +00:00
|
|
|
#Function: get_ssh_size
|
|
|
|
#$1=dump target
|
2013-12-24 09:37:01 +00:00
|
|
|
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
2012-06-26 09:21:53 +00:00
|
|
|
get_ssh_size() {
|
2021-08-04 09:15:42 +00:00
|
|
|
local _out
|
|
|
|
local _opt=("-i" "$SSH_KEY_LOCATION" "-o" "BatchMode=yes" "-o" "StrictHostKeyChecking=yes")
|
|
|
|
|
|
|
|
if ! _out=$(ssh -q -n "${_opt[@]}" "$1" "df" "--output=avail" "$SAVE_PATH"); then
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "checking remote ssh server available size failed."
|
2021-08-04 09:15:42 +00:00
|
|
|
fi
|
2014-03-13 06:09:15 +00:00
|
|
|
|
2021-08-04 09:15:42 +00:00
|
|
|
echo -n "$_out" | tail -1
|
2012-06-26 09:21:53 +00:00
|
|
|
}
|
|
|
|
|
2013-06-13 08:49:38 +00:00
|
|
|
#mkdir if save path does not exist on ssh dump target
|
|
|
|
#$1=ssh dump target
|
2020-03-09 12:38:40 +00:00
|
|
|
#caller should ensure write permission on $1:$SAVE_PATH
|
2013-12-24 09:37:01 +00:00
|
|
|
#called from while loop and shouldn't read from stdin, so we're using "ssh -n"
|
2013-06-13 08:49:38 +00:00
|
|
|
mkdir_save_path_ssh()
|
|
|
|
{
|
|
|
|
local _opt _dir
|
|
|
|
_opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
2013-12-24 09:37:01 +00:00
|
|
|
ssh -qn $_opt $1 mkdir -p $SAVE_PATH 2>&1 > /dev/null
|
2013-06-13 08:49:38 +00:00
|
|
|
_ret=$?
|
|
|
|
if [ $_ret -ne 0 ]; then
|
2020-03-09 12:38:40 +00:00
|
|
|
perror_exit "mkdir failed on $1:$SAVE_PATH"
|
2013-06-13 08:49:38 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-09 12:38:40 +00:00
|
|
|
#check whether user has write permission on $1:$SAVE_PATH
|
2013-06-13 08:49:38 +00:00
|
|
|
_dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
|
|
|
|
_ret=$?
|
|
|
|
if [ $_ret -ne 0 ]; then
|
2020-03-09 12:38:40 +00:00
|
|
|
perror_exit "Could not create temporary directory on $1:$SAVE_PATH. Make sure user has write permission on destination"
|
2013-06-13 08:49:38 +00:00
|
|
|
fi
|
2013-12-24 09:37:01 +00:00
|
|
|
ssh -qn $_opt $1 rmdir $_dir
|
2013-06-13 08:49:38 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-11-27 04:48:56 +00:00
|
|
|
#Function: get_fs_size
|
|
|
|
#$1=dump target
|
|
|
|
get_fs_size() {
|
2021-08-03 19:53:35 +00:00
|
|
|
df -P "$(get_mntpoint_from_target "$1")/$SAVE_PATH"|tail -1|awk '{print $4}'
|
2012-06-26 09:21:54 +00:00
|
|
|
}
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
#Function: get_raw_size
|
|
|
|
#$1=dump target
|
|
|
|
get_raw_size() {
|
2021-08-03 19:53:35 +00:00
|
|
|
fdisk -s "$1"
|
2012-04-28 10:01:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#Function: check_size
|
2012-06-26 09:21:54 +00:00
|
|
|
#$1: dump type string ('raw', 'fs', 'ssh')
|
2012-04-28 10:01:18 +00:00
|
|
|
#$2: dump target
|
|
|
|
check_size() {
|
|
|
|
local avail memtotal
|
|
|
|
|
|
|
|
memtotal=$(awk '/MemTotal/{print $2}' /proc/meminfo)
|
|
|
|
case "$1" in
|
|
|
|
raw)
|
|
|
|
avail=$(get_raw_size "$2")
|
|
|
|
;;
|
2012-06-26 09:21:53 +00:00
|
|
|
ssh)
|
|
|
|
avail=$(get_ssh_size "$2")
|
|
|
|
;;
|
2012-06-26 09:21:54 +00:00
|
|
|
fs)
|
|
|
|
avail=$(get_fs_size "$2")
|
|
|
|
;;
|
2012-04-28 10:01:18 +00:00
|
|
|
*)
|
|
|
|
return
|
|
|
|
esac
|
|
|
|
|
2013-06-26 09:52:40 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
perror_exit "Check dump target size failed"
|
|
|
|
fi
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
if [ $avail -lt $memtotal ]; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dwarn "Warning: There might not be enough space to save a vmcore."
|
|
|
|
dwarn " The size of $2 should be greater than $memtotal kilo bytes."
|
2012-04-28 10:01:18 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
check_save_path_fs()
|
|
|
|
{
|
|
|
|
local _path=$1
|
|
|
|
|
|
|
|
if [ ! -d $_path ]; then
|
|
|
|
perror_exit "Dump path $_path does not exist."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-02-20 03:55:52 +00:00
|
|
|
mount_failure()
|
|
|
|
{
|
|
|
|
local _target=$1
|
|
|
|
local _mnt=$2
|
|
|
|
local _fstype=$3
|
|
|
|
local msg="Failed to mount $_target"
|
|
|
|
|
|
|
|
if [ -n "$_mnt" ]; then
|
|
|
|
msg="$msg on $_mnt"
|
|
|
|
fi
|
|
|
|
|
|
|
|
msg="$msg for kdump preflight check."
|
|
|
|
|
|
|
|
if [[ $_fstype = "nfs" ]]; then
|
|
|
|
msg="$msg Please make sure nfs-utils has been installed."
|
|
|
|
fi
|
|
|
|
|
|
|
|
perror_exit "$msg"
|
|
|
|
}
|
|
|
|
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
check_user_configured_target()
|
|
|
|
{
|
|
|
|
local _target=$1 _cfg_fs_type=$2 _mounted
|
|
|
|
local _mnt=$(get_mntpoint_from_target $_target)
|
|
|
|
local _opt=$(get_mntopt_from_target $_target)
|
|
|
|
local _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
|
2021-02-20 03:55:52 +00:00
|
|
|
[ $? -ne 0 ] && mount_failure "$_target" "$_mnt" "$_fstype"
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
_mounted=$_mnt
|
|
|
|
else
|
2020-06-24 04:11:47 +00:00
|
|
|
perror_exit "Dump target \"$_target\" is neither mounted nor configured as \"noauto\""
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
_mnt=$MKDUMPRD_TMPMNT
|
|
|
|
mkdir -p $_mnt
|
|
|
|
mount $_target $_mnt -t $_fstype -o defaults
|
2021-02-20 03:55:52 +00:00
|
|
|
[ $? -ne 0 ] && mount_failure "$_target" "" "$_fstype"
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
_mounted=$_mnt
|
|
|
|
fi
|
|
|
|
|
|
|
|
# For user configured target, use $SAVE_PATH as the dump path within the target
|
|
|
|
if [ ! -d "$_mnt/$SAVE_PATH" ]; then
|
2021-06-01 10:33:44 +00:00
|
|
|
perror_exit "Dump path \"$_mnt/$SAVE_PATH\" does not exist in dump target \"$_target\""
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +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
|
|
|
|
}
|
|
|
|
|
2012-06-14 01:56:10 +00:00
|
|
|
# $1: core_collector config value
|
|
|
|
verify_core_collector() {
|
2020-02-27 16:18:20 +00:00
|
|
|
local _cmd="${1%% *}"
|
|
|
|
local _params="${1#* }"
|
|
|
|
|
|
|
|
if [ "$_cmd" != "makedumpfile" ]; then
|
|
|
|
if is_raw_dump_target; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dwarn "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
2020-02-27 16:18:20 +00:00
|
|
|
fi
|
|
|
|
return
|
2012-06-14 01:56:10 +00:00
|
|
|
fi
|
2020-02-27 16:18:20 +00:00
|
|
|
|
2012-06-14 01:57:07 +00:00
|
|
|
if is_ssh_dump_target || is_raw_dump_target; then
|
2020-02-27 16:18:20 +00:00
|
|
|
if ! strstr "$_params" "-F"; then
|
|
|
|
perror_exit "The specified dump target needs makedumpfile \"-F\" option."
|
2012-06-14 01:57:07 +00:00
|
|
|
fi
|
2020-02-27 16:18:20 +00:00
|
|
|
_params="$_params vmcore"
|
|
|
|
else
|
|
|
|
_params="$_params vmcore dumpfile"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! $_cmd --check-params $_params; then
|
|
|
|
perror_exit "makedumpfile parameter check failed."
|
2012-06-14 01:56:10 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-01-25 08:58:35 +00:00
|
|
|
add_mount() {
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
local _mnt=$(to_mount $@)
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
exit 1
|
2012-01-25 08:58:35 +00:00
|
|
|
fi
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
|
|
|
|
add_dracut_mount "$_mnt"
|
2012-01-25 08:58:35 +00:00
|
|
|
}
|
|
|
|
|
pass mount info to dracut when default target is a separate disk
When user does not specify dump target explicitly, it's better to
dump to the "path" specified. That means after dump user enter into
1st kernel, can find vmcore in the "path". If that path is in root
fs, vmcore is stored in root fs. If separate disk is mounted on
any tier of "path", we just dump vmcore into the left path on the
left separate disk.
E.g in kdump.conf
path /mnt/nfs
in mount info,
/dev/vdb on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
Then vmcore will be saved in /nfs of /dev/vdb.
In this patch, pass mount info to dracut in this case if separate
disk is mounted on any tier of "path".
Meanwhile introduce a function in kdump-lib.sh to check if any
target is specified.
v4->v5:
Per Vivek's comment, add a helper function is_fs_dump_target.
Then is_user_configured_dump_target is rewrite with these helper
functions.
v5->v7:
No v6 for this patch. Just use newly introduced function
is_fs_type_nfs in handle_default_dump_target.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-11 12:27:01 +00:00
|
|
|
#handle the case user does not specify the dump target explicitly
|
|
|
|
handle_default_dump_target()
|
2014-03-05 03:17:57 +00:00
|
|
|
{
|
|
|
|
local _target
|
|
|
|
local _mntpoint
|
|
|
|
|
2014-03-24 09:15:28 +00:00
|
|
|
is_user_configured_dump_target && return
|
2014-03-05 03:17:57 +00:00
|
|
|
|
pass mount info to dracut when default target is a separate disk
When user does not specify dump target explicitly, it's better to
dump to the "path" specified. That means after dump user enter into
1st kernel, can find vmcore in the "path". If that path is in root
fs, vmcore is stored in root fs. If separate disk is mounted on
any tier of "path", we just dump vmcore into the left path on the
left separate disk.
E.g in kdump.conf
path /mnt/nfs
in mount info,
/dev/vdb on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
Then vmcore will be saved in /nfs of /dev/vdb.
In this patch, pass mount info to dracut in this case if separate
disk is mounted on any tier of "path".
Meanwhile introduce a function in kdump-lib.sh to check if any
target is specified.
v4->v5:
Per Vivek's comment, add a helper function is_fs_dump_target.
Then is_user_configured_dump_target is rewrite with these helper
functions.
v5->v7:
No v6 for this patch. Just use newly introduced function
is_fs_type_nfs in handle_default_dump_target.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-11 12:27:01 +00:00
|
|
|
check_save_path_fs $SAVE_PATH
|
|
|
|
|
2020-03-10 15:52:33 +00:00
|
|
|
_save_path=$(get_bind_mount_source $SAVE_PATH)
|
|
|
|
_target=$(get_target_from_path $_save_path)
|
|
|
|
_mntpoint=$(get_mntpoint_from_target $_target)
|
2015-04-17 08:26:27 +00:00
|
|
|
|
2020-03-10 15:52:33 +00:00
|
|
|
SAVE_PATH=${_save_path##"$_mntpoint"}
|
kdumpctl: remove "root=X" for kdump boot
Since the current dracut of Fedora already supports not always
mounting root device, we can remove "root=X" from the command
line directly, and always get the dump target specified in
"/etc/kdump.conf" and mount it. If the dump target is located
at root filesystem, we will add the root mount info explicitly
from kdump side instead of from dracut side.
For example, in case of nfs/ssh/usb/raw/etc(non-root) dumping,
kdump will not mount the unnecessary root fs after this change.
This patch removes "root=X" via the "KDUMP_COMMANDLINE_REMOVE"
(if "default dump_to_rootfs" is specified, don't remove "root=X"),
and mounts non-root target under "/kdumproot", the root target
still under "/sysroot"(to be align with systemd sysroot.mount).
After removing "root=X", we now add root fs mount information
explicitly from the kdump side.
Changed check_dump_fs_modified() a little to avoid rebuild when
dump target is root, since we add root fs mount explicitly now.
Signed-off-by: Xunlei Pang <xlpang@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
Acked-by:Dave Young <dyoung@redhat.com>
2017-04-05 11:34:12 +00:00
|
|
|
add_mount "$_target"
|
|
|
|
check_size fs $_target
|
2014-03-05 03:17:57 +00:00
|
|
|
}
|
|
|
|
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
# $1: function name
|
|
|
|
for_each_block_target()
|
|
|
|
{
|
|
|
|
local dev majmin
|
|
|
|
|
2017-07-07 07:48:54 +00:00
|
|
|
for dev in $(get_kdump_targets); do
|
|
|
|
[ -b "$dev" ] || continue
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
majmin=$(get_maj_min $dev)
|
|
|
|
check_block_and_slaves $1 $majmin && return 1
|
2017-07-07 07:48:54 +00:00
|
|
|
done
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
#judge if a specific device with $1 is unresettable
|
|
|
|
#return false if unresettable.
|
|
|
|
is_unresettable()
|
|
|
|
{
|
|
|
|
local 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"
|
|
|
|
local resettable=1
|
|
|
|
|
|
|
|
if [ -f "$path" ]
|
|
|
|
then
|
|
|
|
resettable="$(cat $path)"
|
|
|
|
[ $resettable -eq 0 -a "$OVERRIDE_RESETTABLE" -eq 0 ] && {
|
|
|
|
local device=$(udevadm info --query=all --path=/sys/dev/block/$1 | awk -F= '/DEVNAME/{print $2}')
|
2020-10-27 09:04:22 +00:00
|
|
|
derror "Error: Can not save vmcore because device $device is unresettable"
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#check if machine is resettable.
|
|
|
|
#return true if resettable
|
|
|
|
check_resettable()
|
|
|
|
{
|
2021-08-03 17:58:04 +00:00
|
|
|
local _ret _target _override_resettable
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
|
2021-08-03 17:58:04 +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
|
Check if block device as dump target is resettable
Some Smart Array (hpsa/cciss) adapters don't support reset, we need
to disable kdump on those devices, like rhel6 did.
In this patch, the dump target is checked according to below
criteria if it's a block device.
If it's cciss disk but is resettbale, can be used as dump target.
If it's cciss disk but is not resettable, can not be used as dump
target.
If it's cciss disk and not resettable, but user set OVERRIDE_RESETTABLE
to 1 in /etc/sysconfig/kdump, can be taken as dump target. Because
user know the situation and want to have a try.
In this patch, added codes include 4 parts:
1)Add an option "override_resettable <0 | 1>" into kdump.conf, and
add related section into kdump.conf man page. In mkdumprd, will check
whether user has set a value, get that value if yes. By default, the
value is 0.
2)port utility functions from dracut-functions.sh.
3)The check_resettable function checks if dump target is a resettable
block device. This includes the case where default action dump_to_rootfs
is set.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-03-29 07:32:31 +00:00
|
|
|
|
|
|
|
for_each_block_target is_unresettable
|
|
|
|
_ret=$?
|
|
|
|
|
|
|
|
[ $_ret -eq 0 ] && return
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-03-29 08:25:39 +00:00
|
|
|
check_crypt()
|
|
|
|
{
|
2021-04-07 17:41:21 +00:00
|
|
|
local _dev
|
2013-03-29 08:25:39 +00:00
|
|
|
|
2021-04-07 17:41:21 +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
|
2013-03-29 08:25:39 +00:00
|
|
|
}
|
|
|
|
|
2014-03-03 10:37:15 +00:00
|
|
|
if ! check_resettable; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2013-03-29 08:25:39 +00:00
|
|
|
if ! check_crypt; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dwarn "Warning: Encrypted device is in dump path, which is not recommended, see kexec-kdump-howto.txt for more details."
|
2013-03-29 08:25:39 +00:00
|
|
|
fi
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
# firstly get right SSH_KEY_LOCATION
|
2021-08-03 17:58:04 +00:00
|
|
|
keyfile=$(kdump_get_conf_val sshkey)
|
2012-04-28 10:01:18 +00:00
|
|
|
if [ -f "$keyfile" ]; then
|
|
|
|
# canonicalize the path
|
|
|
|
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
|
|
|
|
fi
|
|
|
|
|
|
|
|
while read config_opt config_val;
|
|
|
|
do
|
2013-09-26 11:46:48 +00:00
|
|
|
# remove inline comments after the end of a directive.
|
2012-04-28 10:01:18 +00:00
|
|
|
case "$config_opt" in
|
|
|
|
extra_modules)
|
|
|
|
extra_modules="$extra_modules $config_val"
|
|
|
|
;;
|
2012-07-23 07:31:28 +00:00
|
|
|
ext[234]|xfs|btrfs|minix|nfs)
|
mkdumprd: generate usable kdump initramfs even target is not mounted
Currently kexec-tools always depend on dump target to be mounted, which
caused some inconvenience for setup.
So for user configured target, allow kdump to start and build initramfs
even if target is not mounted.
When a mounted user configured target is used, the behavior is not
changed.
When a unmounted user configured target is used, mkdumprd will look for
corresponding mount info in fstab, and a entry with noauto option is
founded, mkdumprd will try to mount it inplace with optoins specified
in fstab and do basic checks on the device, then umount it.
If there is no fstab entry, mkdumprd will try to mount it in temporary
path with defaults option, do same basic check and umount it.
If there is a fstab entry but "noauto" option is not used, then there
must be some reason that the target device is not mounted, mkdumprd will
error out.
When path based target is used, there is no behavior change.
Signed-off-by: Kairui Song <kasong@redhat.com>
Acked-by: Pingfan Liu <piliu@redhat.com>
2020-05-12 10:47:19 +00:00
|
|
|
check_user_configured_target "$config_val" "$config_opt"
|
|
|
|
add_mount "$config_val" "$config_opt"
|
2012-04-28 10:01:18 +00:00
|
|
|
;;
|
|
|
|
raw)
|
2020-03-08 15:24:50 +00:00
|
|
|
# checking raw disk writable
|
2012-04-28 10:01:18 +00:00
|
|
|
dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "Bad raw disk $config_val"
|
2012-04-28 10:01:18 +00:00
|
|
|
}
|
2020-06-16 03:25:26 +00:00
|
|
|
_praw=$(persistent_policy="by-id" kdump_get_persistent_dev $config_val)
|
2016-11-17 04:51:12 +00:00
|
|
|
if [ -z "$_praw" ]; then
|
2013-06-26 09:52:40 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
add_dracut_arg "--device" "$_praw"
|
2012-04-28 10:01:18 +00:00
|
|
|
check_size raw $config_val
|
|
|
|
;;
|
2012-07-23 07:31:28 +00:00
|
|
|
ssh)
|
2012-04-28 10:01:18 +00:00
|
|
|
if strstr "$config_val" "@";
|
|
|
|
then
|
2013-06-13 08:49:38 +00:00
|
|
|
mkdir_save_path_ssh $config_val
|
2019-10-18 06:10:15 +00:00
|
|
|
check_size ssh $config_val
|
|
|
|
add_dracut_sshkey "$SSH_KEY_LOCATION"
|
2012-04-28 10:01:18 +00:00
|
|
|
else
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "Bad ssh dump target $config_val"
|
2012-04-28 10:01:18 +00:00
|
|
|
fi
|
|
|
|
;;
|
|
|
|
core_collector)
|
2012-06-14 01:56:10 +00:00
|
|
|
verify_core_collector "$config_val"
|
2012-04-28 10:01:18 +00:00
|
|
|
;;
|
add dracut_args option to kdump.conf
mkdumprd call dracut to rebuilding kdump initrd, sometimes passing extra
dracut args is helpful. For example user can enable debug output with
--debug, --printsize to print roughly increased initramfs size by each module,
--omit-drivers to omit kernel modules, etc.
This patch enables dracut_args option for passing extra args to dracut.
Also it modifies add_dracut_arg() to treat a string with-in quote as single
string because for dracut options which has its own args, the args need to be
quoted and space seperated.
If add_dracut_arg() gets an string read from kdump.conf and if that string
contains double quotes, then while converting to positional parameters
those double quotes are not interpreted. Hence if /etc/kdump.conf contains
following.
dracut_args --add-drivers "driver1 driver2"
then add_dracut_args() sees following positional parameters
$1= --add-drivers
$2= "driver1
$3= driver2"
Notice, double quotes have been ignored and parameters have been broken
based on white space.
Modify add_dracut_arg() to look for parameters starting with " and
if one is found, it tries to merge all the next parameters till one
is found with ending double quote. Hence effectively simulating
following behavior.
$1= --add-drivers
$2= "driver1 driver2"
[v1->v2]: address quoted substring in dracut_args, also handle the leading
and ending spaces in substring.
[v2->v3]: fix dracut arguments seperator in kdump.conf.
[v3->v4]: improve changelog, thanks vivek.
[v4->v5]: make the manpage more verbose [vivek].
Tested with below dracut_args test cases:
1. dracut_args --add-drivers "pcspkr virtio_net" --omit-drivers "sdhci-pci hid-logitech-dj e1000"
2. dracut_args --add-drivers " pcspkr virtio_net " --omit-drivers "sdhci-pci hid-logitech-dj e1000"
Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-04-15 02:12:05 +00:00
|
|
|
dracut_args)
|
2021-08-03 19:50:04 +00:00
|
|
|
while read -r dracut_arg; do
|
|
|
|
add_dracut_arg "$dracut_arg"
|
|
|
|
done <<< "$(echo "$config_val" | xargs -n 1 echo)"
|
add dracut_args option to kdump.conf
mkdumprd call dracut to rebuilding kdump initrd, sometimes passing extra
dracut args is helpful. For example user can enable debug output with
--debug, --printsize to print roughly increased initramfs size by each module,
--omit-drivers to omit kernel modules, etc.
This patch enables dracut_args option for passing extra args to dracut.
Also it modifies add_dracut_arg() to treat a string with-in quote as single
string because for dracut options which has its own args, the args need to be
quoted and space seperated.
If add_dracut_arg() gets an string read from kdump.conf and if that string
contains double quotes, then while converting to positional parameters
those double quotes are not interpreted. Hence if /etc/kdump.conf contains
following.
dracut_args --add-drivers "driver1 driver2"
then add_dracut_args() sees following positional parameters
$1= --add-drivers
$2= "driver1
$3= driver2"
Notice, double quotes have been ignored and parameters have been broken
based on white space.
Modify add_dracut_arg() to look for parameters starting with " and
if one is found, it tries to merge all the next parameters till one
is found with ending double quote. Hence effectively simulating
following behavior.
$1= --add-drivers
$2= "driver1 driver2"
[v1->v2]: address quoted substring in dracut_args, also handle the leading
and ending spaces in substring.
[v2->v3]: fix dracut arguments seperator in kdump.conf.
[v3->v4]: improve changelog, thanks vivek.
[v4->v5]: make the manpage more verbose [vivek].
Tested with below dracut_args test cases:
1. dracut_args --add-drivers "pcspkr virtio_net" --omit-drivers "sdhci-pci hid-logitech-dj e1000"
2. dracut_args --add-drivers " pcspkr virtio_net " --omit-drivers "sdhci-pci hid-logitech-dj e1000"
Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2013-04-15 02:12:05 +00:00
|
|
|
;;
|
2012-04-28 10:01:18 +00:00
|
|
|
*)
|
|
|
|
;;
|
|
|
|
esac
|
2021-08-03 11:49:51 +00:00
|
|
|
done <<< "$(kdump_read_conf)"
|
2006-07-20 03:36:18 +00:00
|
|
|
|
pass mount info to dracut when default target is a separate disk
When user does not specify dump target explicitly, it's better to
dump to the "path" specified. That means after dump user enter into
1st kernel, can find vmcore in the "path". If that path is in root
fs, vmcore is stored in root fs. If separate disk is mounted on
any tier of "path", we just dump vmcore into the left path on the
left separate disk.
E.g in kdump.conf
path /mnt/nfs
in mount info,
/dev/vdb on /mnt type ext4 (rw,relatime,seclabel,data=ordered)
Then vmcore will be saved in /nfs of /dev/vdb.
In this patch, pass mount info to dracut in this case if separate
disk is mounted on any tier of "path".
Meanwhile introduce a function in kdump-lib.sh to check if any
target is specified.
v4->v5:
Per Vivek's comment, add a helper function is_fs_dump_target.
Then is_user_configured_dump_target is rewrite with these helper
functions.
v5->v7:
No v6 for this patch. Just use newly introduced function
is_fs_type_nfs in handle_default_dump_target.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-04-11 12:27:01 +00:00
|
|
|
handle_default_dump_target
|
|
|
|
|
2011-07-21 10:51:33 +00:00
|
|
|
if [ -n "$extra_modules" ]
|
|
|
|
then
|
2021-08-03 19:50:04 +00:00
|
|
|
add_dracut_arg "--add-drivers" "$extra_modules"
|
2010-06-13 19:20:48 +00:00
|
|
|
fi
|
|
|
|
|
2021-06-23 14:36:48 +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.
|
2017-08-30 08:45:46 +00:00
|
|
|
if ! is_fadump_capable; then
|
|
|
|
# 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))"
|
2017-08-30 08:45:47 +00:00
|
|
|
|
|
|
|
add_dracut_arg "--no-hostonly-default-device"
|
2017-08-30 08:45:46 +00:00
|
|
|
fi
|
|
|
|
|
2021-08-03 19:50:04 +00:00
|
|
|
dracut "${dracut_args[@]}" "$@"
|
2019-11-20 14:58:10 +00:00
|
|
|
|
2012-01-25 04:18:51 +00:00
|
|
|
_rc=$?
|
2012-01-10 05:28:27 +00:00
|
|
|
sync
|
2012-01-25 04:18:51 +00:00
|
|
|
exit $_rc
|