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
|
|
|
#
|
|
|
|
|
2013-09-24 13:33:27 +00:00
|
|
|
. /lib/kdump/kdump-lib.sh
|
2011-07-21 10:51:33 +00:00
|
|
|
export IN_KDUMP=1
|
2006-07-20 03:36:18 +00:00
|
|
|
|
2011-07-21 10:51:33 +00:00
|
|
|
conf_file="/etc/kdump.conf"
|
2012-02-22 03:16:09 +00:00
|
|
|
SSH_KEY_LOCATION="/root/.ssh/kdump_id_rsa"
|
2012-06-26 09:21:53 +00:00
|
|
|
SAVE_PATH=$(grep ^path $conf_file| cut -d' ' -f2)
|
2014-04-11 12:26:59 +00:00
|
|
|
[ -z "$SAVE_PATH" ] && SAVE_PATH=$DEFAULT_PATH
|
2015-04-10 08:18:57 +00:00
|
|
|
# strip the duplicated "/"
|
|
|
|
SAVE_PATH=$(echo $SAVE_PATH | tr -s /)
|
|
|
|
|
2011-07-21 10:51:33 +00:00
|
|
|
extra_modules=""
|
2014-03-07 03:06:16 +00:00
|
|
|
dracut_args=("--hostonly" "-o" "plymouth dash resume")
|
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
|
|
|
OVERRIDE_RESETTABLE=0
|
2006-07-20 03:36:18 +00:00
|
|
|
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit() {
|
|
|
|
echo $@ >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
perror() {
|
|
|
|
echo $@ >&2
|
|
|
|
}
|
|
|
|
|
2012-09-20 03:03:09 +00:00
|
|
|
get_persistent_dev() {
|
|
|
|
local i _tmp _dev
|
|
|
|
|
|
|
|
_dev=$(udevadm info --query=name --name="$1" 2>/dev/null)
|
|
|
|
[ -z "$_dev" ] && {
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "Kernel dev name of $1 is not found."
|
2012-09-20 03:03:09 +00:00
|
|
|
}
|
|
|
|
|
2012-10-10 07:09:15 +00:00
|
|
|
for i in /dev/mapper/* /dev/disk/by-uuid/* /dev/disk/by-id/*; do
|
2012-09-20 03:03:09 +00:00
|
|
|
_tmp=$(udevadm info --query=name --name="$i" 2>/dev/null)
|
|
|
|
if [ "$_tmp" = "$_dev" ]; then
|
|
|
|
echo $i
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2013-06-27 15:42:07 +00:00
|
|
|
perror "WARNING: Persistent device name of $1 not found. Using $1 as dump target name"
|
|
|
|
echo $1
|
2012-09-20 03:03:09 +00:00
|
|
|
}
|
|
|
|
|
2011-07-21 10:51:33 +00:00
|
|
|
add_dracut_arg() {
|
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
|
|
|
local arg qarg is_quoted=0
|
2011-12-16 10:06:45 +00:00
|
|
|
while [ $# -gt 0 ];
|
|
|
|
do
|
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
|
|
|
arg="${1//\'/\"}"
|
|
|
|
#Handle quoted substring properly for passing it to dracut_args array.
|
|
|
|
if [ $is_quoted -eq 0 ]; then
|
|
|
|
if [[ "$arg" == "\"" ]] || [[ $arg != ${arg#\"} ]]; then
|
|
|
|
is_quoted=1
|
|
|
|
arg=${arg#\"}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ $is_quoted -eq 1 ]; then
|
|
|
|
qarg="$qarg $arg"
|
|
|
|
if [[ "$arg" == "\"" ]] || [[ $arg != ${arg%\"} ]]; then
|
|
|
|
is_quoted=0
|
|
|
|
arg=${qarg%\"}
|
|
|
|
qarg=""
|
|
|
|
else
|
|
|
|
shift
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
dracut_args+=("$arg")
|
2011-12-16 10:06:45 +00:00
|
|
|
shift
|
|
|
|
done
|
2006-07-20 03:36:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-01 09:19:24 +00:00
|
|
|
add_dracut_module() {
|
2011-12-16 10:06:45 +00:00
|
|
|
add_dracut_arg "--add" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
add_dracut_mount() {
|
|
|
|
add_dracut_arg "--mount" "$1"
|
2011-08-01 09:19:24 +00:00
|
|
|
}
|
|
|
|
|
2012-02-22 03:16:09 +00:00
|
|
|
add_dracut_sshkey() {
|
|
|
|
add_dracut_arg "--sshkey" "$1"
|
|
|
|
}
|
|
|
|
|
2012-06-26 09:21:54 +00:00
|
|
|
# Generic substring function. If $2 is in $1, return 0.
|
|
|
|
strstr() { [[ $1 =~ $2 ]]; }
|
|
|
|
|
2013-03-05 08:07:35 +00:00
|
|
|
target_is_root() {
|
|
|
|
local _t
|
|
|
|
_t=$(findmnt -k -n -r -o TARGET $1|sort|head -1)
|
|
|
|
[ "$_t" = "/" ]
|
2012-06-26 09:21:54 +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() {
|
2014-05-08 11:37:13 +00:00
|
|
|
local _dev=$1 _source _target _fstype _options _mntopts _pdev
|
|
|
|
|
|
|
|
_source=$(findmnt -k -f -n -r -o SOURCE $_dev)
|
|
|
|
_target=$(findmnt -k -f -n -r -o TARGET $_dev)
|
mount fail if its mount point doesn't exist in /sysroot
Jerry Hoemann reported a bug that a mount will fail when he installed
a system with separate "/" "/var" and "/var/crash". That means root
disk /dev/a mounted on /, and another disk /dev/b is mounted on /var,
then the 3rd disk /dev/c mounted on /var/crash. Then kdump will fail
since mount will fail.
This is because the mount information will be written into
/$mntimage/etc/fstab like below. And the dump target is /dev/c. However
/dev/b is not related in kdump, its mount info is not necessary and not
saved. So when go into kdump kernel, it will find there's not a crash
dir under /sysroot/var. And in current implementation, if not a root
disk dump, sysroot is a read-only mount, no dir can be created in this
situation.
/dev/disk/by-uuid/cdcf007a-b623-45ee-8d73-a8be0d372440 /sysroot/var/crash xfs rw,relatime,...,x-initrd.mount 0 2
So in this patch, change the mount behavior to fix this bug. If dump
target is a root disk, mount point is /sysroot. If dump target is not
root, just mount it to /kdumproot/$_target. Now it works.
Signed-off-by: Baoquan He <bhe@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: WANG Chao <chaowang@redhat.com>
Tested-by: Jerry Hoemann <jerry.hoemann@hp.com>
2015-01-04 05:49:43 +00:00
|
|
|
# mount under /sysroot if dump to root disk or mount under
|
|
|
|
#/kdumproot/$_target in other cases in 2nd kernel. systemd
|
|
|
|
#will be in charge to umount it.
|
|
|
|
|
|
|
|
if [ "$_target" = "/" ];then
|
|
|
|
_target="/sysroot"
|
|
|
|
else
|
|
|
|
_target="/kdumproot/$_target"
|
|
|
|
fi
|
|
|
|
|
2014-05-08 11:37:13 +00:00
|
|
|
_fstype=$(findmnt -k -f -n -r -o FSTYPE $_dev)
|
2014-09-04 09:38:17 +00:00
|
|
|
_options=$(findmnt --fstab -f -n -r -o OPTIONS $_dev)
|
|
|
|
[ -z "$_options" ] && _options=$(findmnt -k -f -n -r -o OPTIONS $_dev)
|
2014-05-08 11:37:13 +00:00
|
|
|
_options=${_options/#ro/rw} #mount fs target as rw in 2nd kernel
|
mkdumprd: append "x-initrd.mount" to the mount options.
Now when mount in /etc/fstab fails, systemd would not consider it as
critical and it would continue to boot. In fact, emergency service is
triggered, but not in a isolation mode, and it results in the emergency
service getting shutdown at some point later of the boot process. We
need isolation otherwise we won't see any emergency service.
That is because in kdump initramfs, mount units specified in /etc/fstab
are required by "local-fs.target". When any of these mounts fails,
local-fs.target fails.
For kdump initramfs, we need to isolate to emergency service on any of
the mount failure, that said, every service should be stopped and onlu
emergency service would run. But local-fs.target won't trigger that on
its failure. That means in case of mount failure, local-fs.target also
enters failure state, but all the service will continue without any
interruption.
After digging looking into source code of systemd-fstab-generator. I
find "x-initrd.mount" using in initramfs mount, will make the mount
units required by "initrd-root-fs.target" rather than it's used to be
"local-fs.target".
"initrd-root-fs.target" is suitable to us because if it fails, it will
isolate to emergency service. That means in case of any mount failure,
the emergeny service will start and everything else will stop. We want
this effect because we need to take kdump fail-safe action when there's
a mount failure.
From systemd unit point of view, "initrd-root-fs.target" has
OnFailureIsolate=yes, but "local-fs.target" doesn't. From
systemd.unit(5):
OnFailureIsolate=
Takes a boolean argument. If true, the unit listed in OnFailure=
will be enqueued in isolation mode, i.e. all units that are not its
dependency will be stopped. If this is set, only a single unit may
be listed in OnFailure=. Defaults to false.
NOTE: Harald who contributed "x-initrd.mount" in systemd, confirmed that
this feature will stay.
Signed-off-by: WANG Chao <chaowang@redhat.com>
Acked-by: Vivek Goyal <vgoyal@redhat.com>
2014-06-16 08:57:21 +00:00
|
|
|
# "x-initrd.mount" mount failure will trigger isolate emergency service
|
|
|
|
# W/o this, systemd won't isolate, thus we won't get to emergency.
|
|
|
|
# This is not applicable to remote fs mount, because if we use
|
|
|
|
# "x-initrd.mount", remote mount will become required by
|
|
|
|
# "initrd-root-fs.target", instead of "remote-fs.target". That's how it is
|
|
|
|
# handled within systemd internal. We need remote mount to be required
|
|
|
|
# "remote-fs.target", because we need to bring up network before any remote
|
|
|
|
# mount and "remote-fs.target" can be a checkpoint of that.
|
|
|
|
# If remote mount fails, dracut-initqueue will still start and once
|
|
|
|
# dracut-initqueue finishes, kdump service will start. Because remote mount
|
|
|
|
# failed, kdump service will fail and it will lead to kdump error handler.
|
|
|
|
if ! is_nfs_dump_target; then
|
|
|
|
_options="$_options,x-initrd.mount"
|
|
|
|
fi
|
2014-05-08 11:37:13 +00:00
|
|
|
_mntopts="$_target $_fstype $_options"
|
2012-09-20 03:03:19 +00:00
|
|
|
#for non-nfs _dev converting to use udev persistent name
|
2014-05-08 11:37:13 +00:00
|
|
|
if [ -b "$_source" ]; then
|
|
|
|
_pdev="$(get_persistent_dev $_source)"
|
2013-06-26 09:52:40 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2012-09-20 03:03:19 +00:00
|
|
|
else
|
|
|
|
_pdev=$_dev
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "$_pdev $_mntopts"
|
2012-06-26 09:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
to_mount_point() {
|
2012-09-20 03:03:19 +00:00
|
|
|
echo $(findmnt -k -f -n -r -o TARGET $1)
|
2012-06-26 09:21:54 +00:00
|
|
|
}
|
|
|
|
|
2012-11-27 04:48:56 +00:00
|
|
|
is_readonly_mount() {
|
|
|
|
local _mnt
|
|
|
|
_mnt=$(findmnt -k -f -n -r -o OPTIONS $1)
|
|
|
|
|
|
|
|
#fs/proc_namespace.c: show_mountinfo():
|
|
|
|
#seq_puts(m, mnt->mnt_flags & MNT_READONLY ? " ro" : " rw");
|
|
|
|
[[ "$_mnt" =~ ^ro ]]
|
|
|
|
}
|
|
|
|
|
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() {
|
|
|
|
local _opt _out _size
|
|
|
|
_opt="-i $SSH_KEY_LOCATION -o BatchMode=yes -o StrictHostKeyChecking=yes"
|
2012-11-12 08:51:04 +00:00
|
|
|
_out=$(ssh -q -n $_opt $1 "df -P $SAVE_PATH")
|
2013-03-25 09:04:22 +00:00
|
|
|
[ $? -ne 0 ] && {
|
|
|
|
perror_exit "checking remote ssh server available size failed."
|
|
|
|
}
|
2014-03-13 06:09:15 +00:00
|
|
|
|
|
|
|
#ssh output removed the line break, so print field NF-2
|
|
|
|
_size=$(echo -n $_out| awk '{avail=NF-2; print $avail}')
|
2012-06-26 09:21:53 +00:00
|
|
|
echo -n $_size
|
|
|
|
}
|
|
|
|
|
2013-06-13 08:49:38 +00:00
|
|
|
#mkdir if save path does not exist on ssh dump target
|
|
|
|
#$1=ssh dump target
|
|
|
|
#caller should ensure write permission on $DUMP_TARGET:$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
|
|
|
|
perror_exit "mkdir failed on $DUMP_TARGET:$SAVE_PATH"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#check whether user has write permission on $SAVE_PATH/$DUMP_TARGET
|
|
|
|
_dir=$(ssh -qn $_opt $1 mktemp -dqp $SAVE_PATH 2>/dev/null)
|
|
|
|
_ret=$?
|
|
|
|
if [ $_ret -ne 0 ]; then
|
|
|
|
perror_exit "Could not create temporary directory on $DUMP_TARGET:$SAVE_PATH. Make sure user has write permission on destination"
|
|
|
|
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() {
|
|
|
|
local _mnt=$(to_mount_point $1)
|
2012-06-26 09:21:54 +00:00
|
|
|
echo -n $(df -P "${_mnt}/$SAVE_PATH"|tail -1|awk '{print $4}')
|
|
|
|
}
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
#Function: get_raw_size
|
|
|
|
#$1=dump target
|
|
|
|
get_raw_size() {
|
|
|
|
echo -n $(fdisk -s "$1")
|
|
|
|
}
|
|
|
|
|
|
|
|
#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
|
2012-07-12 03:15:35 +00:00
|
|
|
echo "Warning: There might not be enough space to save a vmcore."
|
|
|
|
echo " The size of $2 should be greater than $memtotal kilo bytes."
|
2012-04-28 10:01:18 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-06-14 01:56:10 +00:00
|
|
|
# $1: core_collector config value
|
|
|
|
verify_core_collector() {
|
|
|
|
if grep -q "^raw" $conf_file && [ "${1%% *}" != "makedumpfile" ]; then
|
|
|
|
echo "Warning: specifying a non-makedumpfile core collector, you will have to recover the vmcore manually."
|
|
|
|
fi
|
2012-06-14 01:57:07 +00:00
|
|
|
if is_ssh_dump_target || is_raw_dump_target; then
|
|
|
|
if [ "${1%% *}" = "makedumpfile" ]; then
|
|
|
|
! strstr "$1" "-F" && {
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "The specified dump target needs makedumpfile \"-F\" option."
|
2012-06-14 01:57:07 +00:00
|
|
|
}
|
|
|
|
fi
|
2012-06-14 01:56:10 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2012-01-25 08:58:35 +00:00
|
|
|
add_mount() {
|
2013-03-05 08:07:36 +00:00
|
|
|
if ! target_is_root "$1"; then
|
|
|
|
local _mnt=$(to_mount "$1")
|
2013-06-26 09:52:40 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2012-01-25 08:58:35 +00:00
|
|
|
add_dracut_mount "$_mnt"
|
|
|
|
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
|
|
|
# get_maj_min <device>
|
|
|
|
# Prints the major and minor of a device node.
|
|
|
|
# Example:
|
|
|
|
# $ get_maj_min /dev/sda2
|
|
|
|
# 8:2
|
|
|
|
get_maj_min() {
|
|
|
|
local _dev
|
|
|
|
_dev=$(stat -L -c '$((0x%t)):$((0x%T))' "$1" 2>/dev/null)
|
|
|
|
_dev=$(eval "echo $_dev")
|
|
|
|
echo $_dev
|
|
|
|
}
|
|
|
|
|
|
|
|
# ugly workaround for the lvm design
|
|
|
|
# There is no volume group device,
|
|
|
|
# so, there are no slave devices for volume groups.
|
|
|
|
# Logical volumes only have the slave devices they really live on,
|
|
|
|
# but you cannot create the logical volume without the volume group.
|
|
|
|
# And the volume group might be bigger than the devices the LV needs.
|
|
|
|
check_vol_slaves() {
|
|
|
|
local _lv _vg _pv
|
|
|
|
for i in /dev/mapper/*; do
|
|
|
|
_lv=$(get_maj_min $i)
|
|
|
|
if [[ $_lv = $2 ]]; then
|
|
|
|
_vg=$(lvm lvs --noheadings -o vg_name $i 2>/dev/null)
|
|
|
|
# strip space
|
|
|
|
_vg=$(echo $_vg)
|
|
|
|
if [[ $_vg ]]; then
|
|
|
|
for _pv in $(lvm vgs --noheadings -o pv_name "$_vg" 2>/dev/null)
|
|
|
|
do
|
|
|
|
check_block_and_slaves $1 $(get_maj_min $_pv) && return 0
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# Walk all the slave relationships for a given block device.
|
|
|
|
# Stop when our helper function returns success
|
|
|
|
# $1 = function to call on every found block device
|
|
|
|
# $2 = block device in major:minor format
|
|
|
|
check_block_and_slaves() {
|
|
|
|
local _x
|
|
|
|
[[ -b /dev/block/$2 ]] || return 1 # Not a block device? So sorry.
|
|
|
|
"$1" $2 && return
|
|
|
|
check_vol_slaves "$@" && return 0
|
|
|
|
if [[ -f /sys/dev/block/$2/../dev ]]; then
|
|
|
|
check_block_and_slaves $1 $(cat "/sys/dev/block/$2/../dev") && return 0
|
|
|
|
fi
|
|
|
|
[[ -d /sys/dev/block/$2/slaves ]] || return 1
|
|
|
|
for _x in /sys/dev/block/$2/slaves/*/dev; do
|
|
|
|
[[ -f $_x ]] || continue
|
|
|
|
check_block_and_slaves $1 $(cat "$_x") && return 0
|
|
|
|
done
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
to_dev_name() {
|
|
|
|
local dev="${1//\"/}"
|
|
|
|
|
|
|
|
case "$dev" in
|
|
|
|
UUID=*)
|
|
|
|
dev=`blkid -U "${dev#UUID=}"`
|
|
|
|
;;
|
|
|
|
LABEL=*)
|
|
|
|
dev=`blkid -L "${dev#LABEL=}"`
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
echo $dev
|
|
|
|
}
|
|
|
|
|
|
|
|
get_block_dump_target()
|
|
|
|
{
|
|
|
|
local _target
|
|
|
|
|
|
|
|
|
2014-03-03 10:37:14 +00:00
|
|
|
_target=$(get_user_configured_dump_disk)
|
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
|
|
|
[ -n "$_target" ] && echo $(to_dev_name $_target) && return
|
|
|
|
|
|
|
|
#get rootfs device name
|
2014-03-03 10:37:14 +00:00
|
|
|
_target=$(get_root_fs_device)
|
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
|
|
|
[ -b "$_target" ] && echo $(to_dev_name $_target)
|
|
|
|
}
|
|
|
|
|
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
|
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
|
|
|
local _fstype
|
2014-03-05 03:17:57 +00:00
|
|
|
|
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
|
|
|
|
|
|
|
|
_mntpoint=$(get_mntpoint_from_path $SAVE_PATH)
|
|
|
|
_target=$(get_target_from_path $SAVE_PATH)
|
|
|
|
if [ "$_mntpoint" != "/" ]; then
|
|
|
|
SAVE_PATH=${SAVE_PATH##"$_mntpoint"}
|
|
|
|
_fstype=$(get_fs_type_from_target $_target)
|
|
|
|
|
|
|
|
if $(is_fs_type_nfs $_fstype); then
|
|
|
|
add_dracut_module "nfs"
|
2014-03-05 03:17:57 +00:00
|
|
|
fi
|
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
|
|
|
|
|
|
|
add_mount "$_target"
|
|
|
|
check_size fs $_target
|
2014-03-05 03:17:57 +00:00
|
|
|
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
|
|
|
get_default_action_target()
|
|
|
|
{
|
|
|
|
local _target
|
|
|
|
local _action=$(grep "^default" /etc/kdump.conf 2>/dev/null | awk '{print $2}')
|
|
|
|
if [ -n "$_action" ] && [ "$_action" = "dump_to_rootfs" ]; then
|
|
|
|
#get rootfs device name
|
|
|
|
_target=$(findmnt -k -f -n -o SOURCE /)
|
|
|
|
[ -b "$_target" ] && echo $(to_dev_name $_target)
|
|
|
|
fi
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
get_override_resettable()
|
|
|
|
{
|
|
|
|
local override_resettable
|
|
|
|
|
|
|
|
override_resettable=$(grep "^override_resettable" $conf_file)
|
|
|
|
if [ -n "$override_resettable" ]; then
|
|
|
|
OVERRIDE_RESETTABLE=$(echo $override_resettable | cut -d' ' -f2)
|
|
|
|
if [ "$OVERRIDE_RESETTABLE" != "0" ] && [ "$OVERRIDE_RESETTABLE" != "1" ];then
|
|
|
|
perror_exit "override_resettable value $OVERRIDE_RESETTABLE is invalid"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# $1: function name
|
|
|
|
for_each_block_target()
|
|
|
|
{
|
|
|
|
local dev majmin
|
|
|
|
|
|
|
|
#check dump target
|
|
|
|
dev=$(get_block_dump_target)
|
|
|
|
|
|
|
|
if [ -n "$dev" ]; then
|
|
|
|
majmin=$(get_maj_min $dev)
|
|
|
|
check_block_and_slaves $1 $majmin && return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#check rootfs when default action dump_to_rootfs is set
|
|
|
|
dev=$(get_default_action_target)
|
|
|
|
if [ -n "$dev" ]; then
|
|
|
|
majmin=$(get_maj_min $dev)
|
|
|
|
check_block_and_slaves $1 $majmin && return 2
|
|
|
|
fi
|
|
|
|
|
|
|
|
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}')
|
|
|
|
echo "Device $device is unresettable"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
#check if machine is resettable.
|
|
|
|
#return true if resettable
|
|
|
|
check_resettable()
|
|
|
|
{
|
|
|
|
local _ret _target
|
|
|
|
|
|
|
|
get_override_resettable
|
|
|
|
|
|
|
|
for_each_block_target is_unresettable
|
|
|
|
_ret=$?
|
|
|
|
|
|
|
|
[ $_ret -eq 0 ] && return
|
|
|
|
|
|
|
|
if [ $_ret -eq 1 ]; then
|
|
|
|
_target=$(get_block_dump_target)
|
|
|
|
perror "Can not save vmcore to target device $_target . This device can not be initialized in kdump kernel as it is not resettable"
|
|
|
|
elif [ $_ret -eq 2 ]; then
|
|
|
|
_target=$(get_default_action_target)
|
|
|
|
perror "Rootfs device $_target is not resettable, can not be used as the default target, please specify a default action"
|
|
|
|
fi
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2013-03-29 08:25:39 +00:00
|
|
|
# $1: maj:min
|
|
|
|
is_crypt()
|
|
|
|
{
|
|
|
|
local majmin=$1 dev line ID_FS_TYPE=""
|
|
|
|
|
|
|
|
line=$(udevadm info --query=property --path=/sys/dev/block/$majmin \
|
|
|
|
| grep "^ID_FS_TYPE")
|
|
|
|
eval "$line"
|
|
|
|
[[ "$ID_FS_TYPE" = "crypto_LUKS" ]] && {
|
|
|
|
dev=$(udevadm info --query=all --path=/sys/dev/block/$majmin | awk -F= '/DEVNAME/{print $2}')
|
2014-02-19 02:02:19 +00:00
|
|
|
echo "Device $dev is encrypted."
|
2013-03-29 08:25:39 +00:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
check_crypt()
|
|
|
|
{
|
|
|
|
local _ret _target
|
|
|
|
|
|
|
|
for_each_block_target is_crypt
|
|
|
|
_ret=$?
|
|
|
|
|
|
|
|
[ $_ret -eq 0 ] && return
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
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
|
2014-02-19 02:02:19 +00:00
|
|
|
echo "Warning: Encrypted device is in dump path. User will prompted for password during second kernel boot."
|
2013-03-29 08:25:39 +00:00
|
|
|
fi
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
# firstly get right SSH_KEY_LOCATION
|
2012-12-20 05:24:25 +00:00
|
|
|
keyfile=$(awk '/^sshkey/ {print $2}' $conf_file)
|
2012-04-28 10:01:18 +00:00
|
|
|
if [ -f "$keyfile" ]; then
|
|
|
|
# canonicalize the path
|
|
|
|
SSH_KEY_LOCATION=$(/usr/bin/readlink -m $keyfile)
|
|
|
|
fi
|
|
|
|
|
2012-06-22 06:50:40 +00:00
|
|
|
if [ "$(uname -m)" = "s390x" ]; then
|
|
|
|
add_dracut_module "znet"
|
|
|
|
fi
|
|
|
|
|
2012-04-28 10:01:18 +00:00
|
|
|
while read config_opt config_val;
|
|
|
|
do
|
2013-09-26 11:46:48 +00:00
|
|
|
# remove inline comments after the end of a directive.
|
|
|
|
config_val=$(strip_comments $config_val)
|
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)
|
2013-03-05 08:07:36 +00:00
|
|
|
if ! findmnt $config_val >/dev/null; then
|
2013-03-25 09:04:22 +00:00
|
|
|
perror_exit "Dump target $config_val is probably not mounted."
|
2013-03-05 08:07:36 +00:00
|
|
|
fi
|
|
|
|
|
2012-07-23 07:31:28 +00:00
|
|
|
if [ "$config_opt" = "nfs" ]; then
|
|
|
|
add_dracut_module "nfs"
|
|
|
|
fi
|
2012-04-28 10:01:18 +00:00
|
|
|
add_mount "$config_val"
|
2014-04-11 12:27:00 +00:00
|
|
|
check_save_path_fs $(make_absolute_save_path $config_val)
|
2012-06-26 09:21:54 +00:00
|
|
|
check_size fs $config_val
|
2012-04-28 10:01:18 +00:00
|
|
|
;;
|
|
|
|
raw)
|
|
|
|
#checking raw disk writable
|
|
|
|
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
|
|
|
}
|
2013-06-26 09:52:40 +00:00
|
|
|
_praw=$(get_persistent_dev $config_val)
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
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
|
2012-06-26 09:21:53 +00:00
|
|
|
check_size ssh $config_val
|
2013-06-13 08:49:38 +00:00
|
|
|
mkdir_save_path_ssh $config_val
|
2012-04-28 10:01:18 +00:00
|
|
|
add_dracut_module "ssh-client"
|
|
|
|
add_dracut_sshkey "$SSH_KEY_LOCATION"
|
|
|
|
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)
|
|
|
|
add_dracut_arg $config_val
|
|
|
|
;;
|
2012-04-28 10:01:18 +00:00
|
|
|
*)
|
|
|
|
if [ -n $(echo $config_opt | grep "^#.*$") ]
|
|
|
|
then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done < $conf_file
|
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
|
2012-01-10 14:34:47 +00:00
|
|
|
add_dracut_arg "--add-drivers" "$extra_modules"
|
2010-06-13 19:20:48 +00:00
|
|
|
fi
|
|
|
|
|
2013-06-07 08:57:14 +00:00
|
|
|
dracut "${dracut_args[@]}" "$@"
|
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
|