|
Petr Šabata |
f5bf49 |
#!/bin/bash
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
. $dracutfunctions
|
|
Petr Šabata |
f5bf49 |
. /lib/kdump/kdump-lib.sh
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if ! [[ -d "${initdir}/tmp" ]]; then
|
|
Petr Šabata |
f5bf49 |
mkdir -p "${initdir}/tmp"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
check() {
|
|
Petr Šabata |
f5bf49 |
[[ $debug ]] && set -x
|
|
Petr Šabata |
f5bf49 |
#kdumpctl sets this explicitly
|
|
Petr Šabata |
f5bf49 |
if [ -z "$IN_KDUMP" ] || [ ! -f /etc/kdump.conf ]
|
|
Petr Šabata |
f5bf49 |
then
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
return 0
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
depends() {
|
|
Petr Šabata |
f5bf49 |
local _dep="base shutdown"
|
|
Petr Šabata |
f5bf49 |
|
|
DistroBaker |
17a515 |
add_opt_module() {
|
|
DistroBaker |
17a515 |
[[ " $omit_dracutmodules " != *\ $1\ * ]] && _dep="$_dep $1"
|
|
DistroBaker |
17a515 |
}
|
|
DistroBaker |
17a515 |
|
|
Petr Šabata |
f5bf49 |
is_squash_available() {
|
|
Petr Šabata |
f5bf49 |
for kmodule in squashfs overlay loop; do
|
|
Petr Šabata |
f5bf49 |
if [ -z "$KDUMP_KERNELVER" ]; then
|
|
Petr Šabata |
f5bf49 |
modprobe --dry-run $kmodule &>/dev/null || return 1
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
modprobe -S $KDUMP_KERNELVER --dry-run $kmodule &>/dev/null || return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_squash_available && ! is_fadump_capable; then
|
|
DistroBaker |
17a515 |
add_opt_module squash
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
dwarning "Required modules to build a squashed kdump image is missing!"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
DistroBaker |
17a515 |
if is_wdt_active; then
|
|
DistroBaker |
17a515 |
add_opt_module watchdog
|
|
DistroBaker |
17a515 |
fi
|
|
DistroBaker |
17a515 |
|
|
DistroBaker |
17a515 |
if is_ssh_dump_target; then
|
|
DistroBaker |
17a515 |
_dep="$_dep ssh-client"
|
|
DistroBaker |
17a515 |
fi
|
|
DistroBaker |
17a515 |
|
|
DistroBaker |
17a515 |
if [ "$(uname -m)" = "s390x" ]; then
|
|
DistroBaker |
17a515 |
_dep="$_dep znet"
|
|
DistroBaker |
17a515 |
fi
|
|
DistroBaker |
17a515 |
|
|
Petr Šabata |
f5bf49 |
if [ -n "$( find /sys/devices -name drm )" ] || [ -d /sys/module/hyperv_fb ]; then
|
|
DistroBaker |
17a515 |
add_opt_module drm
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_generic_fence_kdump || is_pcs_fence_kdump; then
|
|
Petr Šabata |
f5bf49 |
_dep="$_dep network"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $_dep
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_is_bridge() {
|
|
Petr Šabata |
f5bf49 |
[ -d /sys/class/net/"$1"/bridge ]
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_is_bond() {
|
|
Petr Šabata |
f5bf49 |
[ -d /sys/class/net/"$1"/bonding ]
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_is_team() {
|
|
Petr Šabata |
f5bf49 |
[ -f /usr/bin/teamnl ] && teamnl $1 ports &> /dev/null
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_is_vlan() {
|
|
Petr Šabata |
f5bf49 |
[ -f /proc/net/vlan/"$1" ]
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# $1: netdev name
|
|
Petr Šabata |
f5bf49 |
source_ifcfg_file() {
|
|
Petr Šabata |
f5bf49 |
local ifcfg_file
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
ifcfg_file=$(get_ifcfg_filename $1)
|
|
Petr Šabata |
f5bf49 |
if [ -f "${ifcfg_file}" ]; then
|
|
Petr Šabata |
f5bf49 |
. ${ifcfg_file}
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
dwarning "The ifcfg file of $1 is not found!"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# $1: netdev name
|
|
Petr Šabata |
f5bf49 |
kdump_setup_dns() {
|
|
Petr Šabata |
f5bf49 |
local _nameserver _dns
|
|
Petr Šabata |
f5bf49 |
local _dnsfile=${initdir}/etc/cmdline.d/42dns.conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
source_ifcfg_file $1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[ -n "$DNS1" ] && echo "nameserver=$DNS1" > "$_dnsfile"
|
|
Petr Šabata |
f5bf49 |
[ -n "$DNS2" ] && echo "nameserver=$DNS2" >> "$_dnsfile"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
while read content;
|
|
Petr Šabata |
f5bf49 |
do
|
|
Petr Šabata |
f5bf49 |
_nameserver=$(echo $content | grep ^nameserver)
|
|
Petr Šabata |
f5bf49 |
[ -z "$_nameserver" ] && continue
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_dns=$(echo $_nameserver | cut -d' ' -f2)
|
|
Petr Šabata |
f5bf49 |
[ -z "$_dns" ] && continue
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ ! -f $_dnsfile ] || [ ! $(cat $_dnsfile | grep -q $_dns) ]; then
|
|
Petr Šabata |
f5bf49 |
echo "nameserver=$_dns" >> "$_dnsfile"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done < "/etc/resolv.conf"
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
#$1: netdev name
|
|
Petr Šabata |
f5bf49 |
#$2: srcaddr
|
|
Petr Šabata |
f5bf49 |
#if it use static ip echo it, or echo null
|
|
Petr Šabata |
f5bf49 |
kdump_static_ip() {
|
|
Petr Šabata |
f5bf49 |
local _netdev="$1" _srcaddr="$2" _ipv6_flag
|
|
Petr Šabata |
f5bf49 |
local _netmask _gateway _ipaddr _target _nexthop
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_ipaddr=$(ip addr show dev $_netdev permanent | awk "/ $_srcaddr\/.* /{print \$2}")
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_ipv6_address $_srcaddr; then
|
|
Petr Šabata |
f5bf49 |
_ipv6_flag="-6"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ -n "$_ipaddr" ]; then
|
|
Petr Šabata |
f5bf49 |
_gateway=$(ip $_ipv6_flag route list dev $_netdev | \
|
|
Petr Šabata |
f5bf49 |
awk '/^default /{print $3}' | head -n 1)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ "x" != "x"$_ipv6_flag ]; then
|
|
Petr Šabata |
f5bf49 |
# _ipaddr="2002::56ff:feb6:56d5/64", _netmask is the number after "/"
|
|
Petr Šabata |
f5bf49 |
_netmask=${_ipaddr#*\/}
|
|
Petr Šabata |
f5bf49 |
_srcaddr="[$_srcaddr]"
|
|
Petr Šabata |
f5bf49 |
_gateway="[$_gateway]"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_netmask=$(ipcalc -m $_ipaddr | cut -d'=' -f2)
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
echo -n "${_srcaddr}::${_gateway}:${_netmask}::"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
/sbin/ip $_ipv6_flag route show | grep -v default |\
|
|
Petr Šabata |
f5bf49 |
grep ".*via.* $_netdev " | grep -v "^[[:space:]]*nexthop" |\
|
|
Petr Šabata |
f5bf49 |
while read _route; do
|
|
Petr Šabata |
f5bf49 |
_target=`echo $_route | cut -d ' ' -f1`
|
|
Petr Šabata |
f5bf49 |
_nexthop=`echo $_route | cut -d ' ' -f3`
|
|
Petr Šabata |
f5bf49 |
if [ "x" != "x"$_ipv6_flag ]; then
|
|
Petr Šabata |
f5bf49 |
_target="[$_target]"
|
|
Petr Šabata |
f5bf49 |
_nexthop="[$_nexthop]"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
echo "rd.route=$_target:$_nexthop:$_netdev"
|
|
Petr Šabata |
f5bf49 |
done >> ${initdir}/etc/cmdline.d/45route-static.conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_handle_mulitpath_route $_netdev $_srcaddr
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_handle_mulitpath_route() {
|
|
Petr Šabata |
f5bf49 |
local _netdev="$1" _srcaddr="$2" _ipv6_flag
|
|
Petr Šabata |
f5bf49 |
local _target _nexthop _route _weight _max_weight _rule
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_ipv6_address $_srcaddr; then
|
|
Petr Šabata |
f5bf49 |
_ipv6_flag="-6"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
while IFS="" read _route; do
|
|
Petr Šabata |
f5bf49 |
if [[ "$_route" =~ [[:space:]]+nexthop ]]; then
|
|
Petr Šabata |
f5bf49 |
_route=$(echo "$_route" | sed -e 's/^[[:space:]]*//')
|
|
Petr Šabata |
f5bf49 |
# Parse multipath route, using previous _target
|
|
Petr Šabata |
f5bf49 |
[[ "$_target" == 'default' ]] && continue
|
|
Petr Šabata |
f5bf49 |
[[ "$_route" =~ .*via.*\ $_netdev ]] || continue
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_weight=`echo "$_route" | cut -d ' ' -f7`
|
|
Petr Šabata |
f5bf49 |
if [[ "$_weight" -gt "$_max_weight" ]]; then
|
|
Petr Šabata |
f5bf49 |
_nexthop=`echo "$_route" | cut -d ' ' -f3`
|
|
Petr Šabata |
f5bf49 |
_max_weight=$_weight
|
|
Petr Šabata |
f5bf49 |
if [ "x" != "x"$_ipv6_flag ]; then
|
|
Petr Šabata |
f5bf49 |
_rule="rd.route=[$_target]:[$_nexthop]:$_netdev"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_rule="rd.route=$_target:$_nexthop:$_netdev"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
[[ -n "$_rule" ]] && echo "$_rule"
|
|
Petr Šabata |
f5bf49 |
_target=`echo "$_route" | cut -d ' ' -f1`
|
|
Petr Šabata |
f5bf49 |
_rule="" _max_weight=0 _weight=0
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done >> ${initdir}/etc/cmdline.d/45route-static.conf\
|
|
Petr Šabata |
f5bf49 |
<<< "$(/sbin/ip $_ipv6_flag route show)"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[[ -n $_rule ]] && echo $_rule >> ${initdir}/etc/cmdline.d/45route-static.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_get_mac_addr() {
|
|
Petr Šabata |
f5bf49 |
cat /sys/class/net/$1/address
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
#Bonding or team master modifies the mac address
|
|
Petr Šabata |
f5bf49 |
#of its slaves, we should use perm address
|
|
Petr Šabata |
f5bf49 |
kdump_get_perm_addr() {
|
|
Petr Šabata |
f5bf49 |
local addr=$(ethtool -P $1 | sed -e 's/Permanent address: //')
|
|
Petr Šabata |
f5bf49 |
if [ -z "$addr" ] || [ "$addr" = "00:00:00:00:00:00" ]
|
|
Petr Šabata |
f5bf49 |
then
|
|
Petr Šabata |
f5bf49 |
derror "Can't get the permanent address of $1"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
echo "$addr"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Prefix kernel assigned names with "kdump-". EX: eth0 -> kdump-eth0
|
|
Petr Šabata |
f5bf49 |
# Because kernel assigned names are not persistent between 1st and 2nd
|
|
Petr Šabata |
f5bf49 |
# kernel. We could probably end up with eth0 being eth1, eth0 being
|
|
Petr Šabata |
f5bf49 |
# eth1, and naming conflict happens.
|
|
Petr Šabata |
f5bf49 |
kdump_setup_ifname() {
|
|
Petr Šabata |
f5bf49 |
local _ifname
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# If ifname already has 'kdump-' prefix, we must be switching from
|
|
Petr Šabata |
f5bf49 |
# fadump to kdump. Skip prefixing 'kdump-' in this case as adding
|
|
Petr Šabata |
f5bf49 |
# another prefix may truncate the ifname. Since an ifname with
|
|
Petr Šabata |
f5bf49 |
# 'kdump-' is already persistent, this should be fine.
|
|
Petr Šabata |
f5bf49 |
if [[ $1 =~ eth* ]] && [[ ! $1 =~ ^kdump-* ]]; then
|
|
Petr Šabata |
f5bf49 |
_ifname="kdump-$1"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_ifname="$1"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo "$_ifname"
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bridge() {
|
|
Petr Šabata |
f5bf49 |
local _netdev=$1
|
|
Petr Šabata |
f5bf49 |
local _brif _dev _mac _kdumpdev
|
|
Petr Šabata |
f5bf49 |
for _dev in `ls /sys/class/net/$_netdev/brif/`; do
|
|
Petr Šabata |
f5bf49 |
_kdumpdev=$_dev
|
|
Petr Šabata |
f5bf49 |
if kdump_is_bond "$_dev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bond "$_dev"
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_team "$_dev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_team "$_dev"
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_vlan "$_dev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_vlan "$_dev"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_mac=$(kdump_get_mac_addr $_dev)
|
|
Petr Šabata |
f5bf49 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
Petr Šabata |
f5bf49 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/41bridge.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
_brif+="$_kdumpdev,"
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
echo " bridge=$_netdev:$(echo $_brif | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/41bridge.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bond() {
|
|
Petr Šabata |
f5bf49 |
local _netdev=$1
|
|
Petr Šabata |
f5bf49 |
local _dev _mac _slaves _kdumpdev
|
|
Petr Šabata |
f5bf49 |
for _dev in `cat /sys/class/net/$_netdev/bonding/slaves`; do
|
|
Petr Šabata |
f5bf49 |
_mac=$(kdump_get_perm_addr $_dev)
|
|
Petr Šabata |
f5bf49 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
Petr Šabata |
f5bf49 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
Petr Šabata |
f5bf49 |
_slaves+="$_kdumpdev,"
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
echo -n " bond=$_netdev:$(echo $_slaves | sed 's/,$//')" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
Petr Šabata |
f5bf49 |
# Get bond options specified in ifcfg
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
source_ifcfg_file $_netdev
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
bondoptions=":$(echo $BONDING_OPTS | xargs echo | tr " " ",")"
|
|
Petr Šabata |
f5bf49 |
echo "$bondoptions" >> ${initdir}/etc/cmdline.d/42bond.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_team() {
|
|
Petr Šabata |
f5bf49 |
local _netdev=$1
|
|
Petr Šabata |
f5bf49 |
local _dev _mac _slaves _kdumpdev
|
|
Petr Šabata |
f5bf49 |
for _dev in `teamnl $_netdev ports | awk -F':' '{print $2}'`; do
|
|
Petr Šabata |
f5bf49 |
_mac=$(kdump_get_perm_addr $_dev)
|
|
Petr Šabata |
f5bf49 |
_kdumpdev=$(kdump_setup_ifname $_dev)
|
|
Petr Šabata |
f5bf49 |
echo -n " ifname=$_kdumpdev:$_mac" >> ${initdir}/etc/cmdline.d/44team.conf
|
|
Petr Šabata |
f5bf49 |
_slaves+="$_kdumpdev,"
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
echo " team=$_netdev:$(echo $_slaves | sed -e 's/,$//')" >> ${initdir}/etc/cmdline.d/44team.conf
|
|
Petr Šabata |
f5bf49 |
#Buggy version teamdctl outputs to stderr!
|
|
Petr Šabata |
f5bf49 |
#Try to use the latest version of teamd.
|
|
Petr Šabata |
f5bf49 |
teamdctl "$_netdev" config dump > ${initdir}/tmp/$$-$_netdev.conf
|
|
Petr Šabata |
f5bf49 |
if [ $? -ne 0 ]
|
|
Petr Šabata |
f5bf49 |
then
|
|
Petr Šabata |
f5bf49 |
derror "teamdctl failed."
|
|
Petr Šabata |
f5bf49 |
exit 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
inst_dir /etc/teamd
|
|
Petr Šabata |
f5bf49 |
inst_simple ${initdir}/tmp/$$-$_netdev.conf "/etc/teamd/$_netdev.conf"
|
|
Petr Šabata |
f5bf49 |
rm -f ${initdir}/tmp/$$-$_netdev.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_vlan() {
|
|
Petr Šabata |
f5bf49 |
local _netdev=$1
|
|
Petr Šabata |
f5bf49 |
local _phydev="$(awk '/^Device:/{print $2}' /proc/net/vlan/"$_netdev")"
|
|
Petr Šabata |
f5bf49 |
local _netmac="$(kdump_get_mac_addr $_phydev)"
|
|
Petr Šabata |
f5bf49 |
local _kdumpdev
|
|
Petr Šabata |
f5bf49 |
|
|
DistroBaker |
a10140 |
#Just support vlan over bond and team
|
|
Petr Šabata |
f5bf49 |
if kdump_is_bridge "$_phydev"; then
|
|
Petr Šabata |
f5bf49 |
derror "Vlan over bridge is not supported!"
|
|
Petr Šabata |
f5bf49 |
exit 1
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_bond "$_phydev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bond "$_phydev"
|
|
Petr Šabata |
f5bf49 |
echo " vlan=$(kdump_setup_ifname $_netdev):$_phydev" > ${initdir}/etc/cmdline.d/43vlan.conf
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_kdumpdev="$(kdump_setup_ifname $_phydev)"
|
|
Petr Šabata |
f5bf49 |
echo " vlan=$(kdump_setup_ifname $_netdev):$_kdumpdev ifname=$_kdumpdev:$_netmac" > ${initdir}/etc/cmdline.d/43vlan.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# setup s390 znet cmdline
|
|
Petr Šabata |
f5bf49 |
# $1: netdev name
|
|
Petr Šabata |
f5bf49 |
kdump_setup_znet() {
|
|
Petr Šabata |
f5bf49 |
local _options=""
|
|
Petr Šabata |
f5bf49 |
local _netdev=$1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
source_ifcfg_file $_netdev
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
for i in $OPTIONS; do
|
|
Petr Šabata |
f5bf49 |
_options=${_options},$i
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
echo rd.znet=${NETTYPE},${SUBCHANNELS}${_options} rd.znet_ifname=$_netdev:${SUBCHANNELS} > ${initdir}/etc/cmdline.d/30znet.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_get_ip_route()
|
|
Petr Šabata |
f5bf49 |
{
|
|
Petr Šabata |
f5bf49 |
local _route=$(/sbin/ip -o route get to $1 2>&1)
|
|
Petr Šabata |
f5bf49 |
[ $? != 0 ] && die "Bad kdump network destination: $1"
|
|
Petr Šabata |
f5bf49 |
echo $_route
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_get_ip_route_field()
|
|
Petr Šabata |
f5bf49 |
{
|
|
Petr Šabata |
f5bf49 |
if `echo $1 | grep -q $2`; then
|
|
Petr Šabata |
f5bf49 |
echo ${1##*$2} | cut -d ' ' -f1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_get_remote_ip()
|
|
Petr Šabata |
f5bf49 |
{
|
|
Petr Šabata |
f5bf49 |
local _remote=$(get_remote_host $1) _remote_temp
|
|
Petr Šabata |
f5bf49 |
if is_hostname $_remote; then
|
|
Petr Šabata |
f5bf49 |
_remote_temp=`getent ahosts $_remote | grep -v : | head -n 1`
|
|
Petr Šabata |
f5bf49 |
if [ -z "$_remote_temp" ]; then
|
|
Petr Šabata |
f5bf49 |
_remote_temp=`getent ahosts $_remote | head -n 1`
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
_remote=`echo $_remote_temp | cut -d' ' -f1`
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
echo $_remote
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Setup dracut to bring up network interface that enable
|
|
Petr Šabata |
f5bf49 |
# initramfs accessing giving destination
|
|
Petr Šabata |
f5bf49 |
# $1: destination host
|
|
Petr Šabata |
f5bf49 |
kdump_install_net() {
|
|
Petr Šabata |
f5bf49 |
local _destaddr _srcaddr _route _netdev
|
|
Petr Šabata |
f5bf49 |
local _static _proto _ip_conf _ip_opts _ifname_opts
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_destaddr=$(kdump_get_remote_ip $1)
|
|
Petr Šabata |
f5bf49 |
_route=$(kdump_get_ip_route $_destaddr)
|
|
Petr Šabata |
f5bf49 |
_srcaddr=$(kdump_get_ip_route_field "$_route" "src")
|
|
Petr Šabata |
f5bf49 |
_netdev=$(kdump_get_ip_route_field "$_route" "dev")
|
|
Petr Šabata |
f5bf49 |
_netmac=$(kdump_get_mac_addr $_netdev)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ "$(uname -m)" = "s390x" ]; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_znet $_netdev
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_static=$(kdump_static_ip $_netdev $_srcaddr)
|
|
Petr Šabata |
f5bf49 |
if [ -n "$_static" ]; then
|
|
Petr Šabata |
f5bf49 |
_proto=none
|
|
Petr Šabata |
f5bf49 |
elif is_ipv6_address $_srcaddr; then
|
|
DistroBaker |
7d0122 |
_proto=auto6
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_proto=dhcp
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_ip_conf="${initdir}/etc/cmdline.d/40ip.conf"
|
|
Petr Šabata |
f5bf49 |
_ip_opts=" ip=${_static}$(kdump_setup_ifname $_netdev):${_proto}"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# dracut doesn't allow duplicated configuration for same NIC, even they're exactly the same.
|
|
Petr Šabata |
f5bf49 |
# so we have to avoid adding duplicates
|
|
Petr Šabata |
f5bf49 |
# We should also check /proc/cmdline for existing ip=xx arg.
|
|
Petr Šabata |
f5bf49 |
# For example, iscsi boot will specify ip=xxx arg in cmdline.
|
|
Petr Šabata |
f5bf49 |
if [ ! -f $_ip_conf ] || ! grep -q $_ip_opts $_ip_conf &&\
|
|
Petr Šabata |
f5bf49 |
! grep -q "ip=[^[:space:]]*$_netdev" /proc/cmdline; then
|
|
Petr Šabata |
f5bf49 |
echo "$_ip_opts" >> $_ip_conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if kdump_is_bridge "$_netdev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bridge "$_netdev"
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_bond "$_netdev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_bond "$_netdev"
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_team "$_netdev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_team "$_netdev"
|
|
Petr Šabata |
f5bf49 |
elif kdump_is_vlan "$_netdev"; then
|
|
Petr Šabata |
f5bf49 |
kdump_setup_vlan "$_netdev"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_ifname_opts=" ifname=$(kdump_setup_ifname $_netdev):$_netmac"
|
|
Petr Šabata |
f5bf49 |
echo "$_ifname_opts" >> $_ip_conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_dns "$_netdev"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ ! -f ${initdir}/etc/cmdline.d/50neednet.conf ]; then
|
|
Petr Šabata |
f5bf49 |
# network-manager module needs this parameter
|
|
Petr Šabata |
f5bf49 |
echo "rd.neednet" >> ${initdir}/etc/cmdline.d/50neednet.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Save netdev used for kdump as cmdline
|
|
Petr Šabata |
f5bf49 |
# Whoever calling kdump_install_net() is setting up the default gateway,
|
|
Petr Šabata |
f5bf49 |
# ie. bootdev/kdumpnic. So don't override the setting if calling
|
|
Petr Šabata |
f5bf49 |
# kdump_install_net() for another time. For example, after setting eth0 as
|
|
Petr Šabata |
f5bf49 |
# the default gate way for network dump, eth1 in the fence kdump path will
|
|
Petr Šabata |
f5bf49 |
# call kdump_install_net again and we don't want eth1 to be the default
|
|
Petr Šabata |
f5bf49 |
# gateway.
|
|
Petr Šabata |
f5bf49 |
if [ ! -f ${initdir}/etc/cmdline.d/60kdumpnic.conf ] &&
|
|
Petr Šabata |
f5bf49 |
[ ! -f ${initdir}/etc/cmdline.d/70bootdev.conf ]; then
|
|
Petr Šabata |
f5bf49 |
echo "kdumpnic=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/60kdumpnic.conf
|
|
Petr Šabata |
f5bf49 |
echo "bootdev=$(kdump_setup_ifname $_netdev)" > ${initdir}/etc/cmdline.d/70bootdev.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# install etc/kdump/pre.d and /etc/kdump/post.d
|
|
Petr Šabata |
f5bf49 |
kdump_install_pre_post_conf() {
|
|
Petr Šabata |
f5bf49 |
if [ -d /etc/kdump/pre.d ]; then
|
|
Petr Šabata |
f5bf49 |
for file in /etc/kdump/pre.d/*; do
|
|
Petr Šabata |
f5bf49 |
if [ -x "$file" ]; then
|
|
Petr Šabata |
f5bf49 |
dracut_install $file
|
|
Petr Šabata |
f5bf49 |
elif [ $file != "/etc/kdump/pre.d/*" ]; then
|
|
Petr Šabata |
f5bf49 |
echo "$file is not executable"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ -d /etc/kdump/post.d ]; then
|
|
Petr Šabata |
f5bf49 |
for file in /etc/kdump/post.d/*; do
|
|
Petr Šabata |
f5bf49 |
if [ -x "$file" ]; then
|
|
Petr Šabata |
f5bf49 |
dracut_install $file
|
|
Petr Šabata |
f5bf49 |
elif [ $file != "/etc/kdump/post.d/*" ]; then
|
|
Petr Šabata |
f5bf49 |
echo "$file is not executable"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
default_dump_target_install_conf()
|
|
Petr Šabata |
f5bf49 |
{
|
|
Petr Šabata |
f5bf49 |
local _target _fstype
|
|
Petr Šabata |
f5bf49 |
local _mntpoint _save_path
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
is_user_configured_dump_target && return
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_save_path=$(get_bind_mount_source $(get_save_path))
|
|
Petr Šabata |
f5bf49 |
_target=$(get_target_from_path $_save_path)
|
|
Petr Šabata |
f5bf49 |
_mntpoint=$(get_mntpoint_from_target $_target)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
_fstype=$(get_fs_type_from_target $_target)
|
|
Petr Šabata |
f5bf49 |
if is_fs_type_nfs $_fstype; then
|
|
Petr Šabata |
f5bf49 |
kdump_install_net "$_target"
|
|
Petr Šabata |
f5bf49 |
_fstype="nfs"
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
_target=$(kdump_get_persistent_dev $_target)
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# don't touch the path under root mount
|
|
Petr Šabata |
f5bf49 |
if [ "$_mntpoint" != "/" ]; then
|
|
Petr Šabata |
f5bf49 |
_save_path=${_save_path##"$_mntpoint"}
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
#erase the old path line, then insert the parsed path
|
|
Petr Šabata |
f5bf49 |
sed -i "/^path/d" ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
echo "path $_save_path" >> ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
#install kdump.conf and what user specifies in kdump.conf
|
|
Petr Šabata |
f5bf49 |
kdump_install_conf() {
|
|
Petr Šabata |
f5bf49 |
local _opt _val _pdev
|
|
Petr Šabata |
f5bf49 |
(read_strip_comments /etc/kdump.conf) > ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
while read _opt _val;
|
|
Petr Šabata |
f5bf49 |
do
|
|
Petr Šabata |
f5bf49 |
# remove inline comments after the end of a directive.
|
|
Petr Šabata |
f5bf49 |
case "$_opt" in
|
|
Petr Šabata |
f5bf49 |
raw)
|
|
Petr Šabata |
f5bf49 |
_pdev=$(persistent_policy="by-id" kdump_get_persistent_dev $_val)
|
|
Petr Šabata |
f5bf49 |
sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
ext[234]|xfs|btrfs|minix)
|
|
Petr Šabata |
f5bf49 |
_pdev=$(kdump_get_persistent_dev $_val)
|
|
Petr Šabata |
f5bf49 |
sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#" ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
ssh|nfs)
|
|
Petr Šabata |
f5bf49 |
kdump_install_net "$_val"
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
dracut_args)
|
|
Petr Šabata |
f5bf49 |
if [[ $(get_dracut_args_fstype "$_val") = nfs* ]] ; then
|
|
Petr Šabata |
f5bf49 |
kdump_install_net "$(get_dracut_args_target "$_val")"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
kdump_pre|kdump_post|extra_bins)
|
|
Petr Šabata |
f5bf49 |
dracut_install $_val
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
core_collector)
|
|
Petr Šabata |
f5bf49 |
dracut_install "${_val%%[[:blank:]]*}"
|
|
Petr Šabata |
f5bf49 |
;;
|
|
Petr Šabata |
f5bf49 |
esac
|
|
Petr Šabata |
f5bf49 |
done <<< "$(read_strip_comments /etc/kdump.conf)"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_install_pre_post_conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
default_dump_target_install_conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_configure_fence_kdump "${initdir}/tmp/$$-kdump.conf"
|
|
Petr Šabata |
f5bf49 |
inst "${initdir}/tmp/$$-kdump.conf" "/etc/kdump.conf"
|
|
Petr Šabata |
f5bf49 |
rm -f ${initdir}/tmp/$$-kdump.conf
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Remove user custom configurations sysctl.conf & sysctl.d/*
|
|
Petr Šabata |
f5bf49 |
# and apply some optimization for kdump
|
|
Petr Šabata |
f5bf49 |
overwrite_sysctl_conf() {
|
|
Petr Šabata |
f5bf49 |
# As custom configurations like vm.min_free_kbytes can lead
|
|
Petr Šabata |
f5bf49 |
# to OOM issues in kdump kernel, avoid them
|
|
Petr Šabata |
f5bf49 |
rm -f "${initdir}/etc/sysctl.conf"
|
|
Petr Šabata |
f5bf49 |
rm -rf "${initdir}/etc/sysctl.d"
|
|
Petr Šabata |
f5bf49 |
rm -rf "${initdir}/run/sysctl.d"
|
|
Petr Šabata |
f5bf49 |
rm -rf "${initdir}/usr/lib/sysctl.d"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
mkdir -p "${initdir}/etc/sysctl.d"
|
|
Petr Šabata |
f5bf49 |
echo "vm.zone_reclaim_mode = 3" > "${initdir}/etc/sysctl.d/99-zone-reclaim.conf"
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_iscsi_get_rec_val() {
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
local result
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# The open-iscsi 742 release changed to using flat files in
|
|
Petr Šabata |
f5bf49 |
# /var/lib/iscsi.
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
result=$(/sbin/iscsiadm --show -m session -r ${1} | grep "^${2} = ")
|
|
Petr Šabata |
f5bf49 |
result=${result##* = }
|
|
Petr Šabata |
f5bf49 |
echo $result
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_get_iscsi_initiator() {
|
|
Petr Šabata |
f5bf49 |
local _initiator
|
|
Petr Šabata |
f5bf49 |
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[ -f "$initiator_conf" ] || return 1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
while read _initiator; do
|
|
Petr Šabata |
f5bf49 |
[ -z "${_initiator%%#*}" ] && continue # Skip comment lines
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
case $_initiator in
|
|
Petr Šabata |
f5bf49 |
InitiatorName=*)
|
|
Petr Šabata |
f5bf49 |
initiator=${_initiator#InitiatorName=}
|
|
Petr Šabata |
f5bf49 |
echo "rd.iscsi.initiator=${initiator}"
|
|
Petr Šabata |
f5bf49 |
return 0;;
|
|
Petr Šabata |
f5bf49 |
*) ;;
|
|
Petr Šabata |
f5bf49 |
esac
|
|
Petr Šabata |
f5bf49 |
done < ${initiator_conf}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Figure out iBFT session according to session type
|
|
Petr Šabata |
f5bf49 |
is_ibft() {
|
|
Petr Šabata |
f5bf49 |
[ "$(kdump_iscsi_get_rec_val $1 "node.discovery_type")" = fw ]
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_setup_iscsi_device() {
|
|
Petr Šabata |
f5bf49 |
local path=$1
|
|
Petr Šabata |
f5bf49 |
local tgt_name; local tgt_ipaddr;
|
|
Petr Šabata |
f5bf49 |
local username; local password; local userpwd_str;
|
|
Petr Šabata |
f5bf49 |
local username_in; local password_in; local userpwd_in_str;
|
|
Petr Šabata |
f5bf49 |
local netroot_str ; local initiator_str;
|
|
Petr Šabata |
f5bf49 |
local netroot_conf="${initdir}/etc/cmdline.d/50iscsi.conf"
|
|
Petr Šabata |
f5bf49 |
local initiator_conf="/etc/iscsi/initiatorname.iscsi"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
dinfo "Found iscsi component $1"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Check once before getting explicit values, so we can bail out early,
|
|
Petr Šabata |
f5bf49 |
# e.g. in case of pure-hardware(all-offload) iscsi.
|
|
Petr Šabata |
f5bf49 |
if ! /sbin/iscsiadm -m session -r ${path} &>/dev/null ; then
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_ibft ${path}; then
|
|
Petr Šabata |
f5bf49 |
return
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Remove software iscsi cmdline generated by 95iscsi,
|
|
Petr Šabata |
f5bf49 |
# and let kdump regenerate here.
|
|
Petr Šabata |
f5bf49 |
rm -f ${initdir}/etc/cmdline.d/95iscsi.conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
tgt_name=$(kdump_iscsi_get_rec_val ${path} "node.name")
|
|
Petr Šabata |
f5bf49 |
tgt_ipaddr=$(kdump_iscsi_get_rec_val ${path} "node.conn\[0\].address")
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# get and set username and password details
|
|
Petr Šabata |
f5bf49 |
username=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username")
|
|
Petr Šabata |
f5bf49 |
[ "$username" == "<empty>" ] && username=""
|
|
Petr Šabata |
f5bf49 |
password=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password")
|
|
Petr Šabata |
f5bf49 |
[ "$password" == "<empty>" ] && password=""
|
|
Petr Šabata |
f5bf49 |
username_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.username_in")
|
|
Petr Šabata |
f5bf49 |
[ -n "$username" ] && userpwd_str="$username:$password"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# get and set incoming username and password details
|
|
Petr Šabata |
f5bf49 |
[ "$username_in" == "<empty>" ] && username_in=""
|
|
Petr Šabata |
f5bf49 |
password_in=$(kdump_iscsi_get_rec_val ${path} "node.session.auth.password_in")
|
|
Petr Šabata |
f5bf49 |
[ "$password_in" == "<empty>" ] && password_in=""
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[ -n "$username_in" ] && userpwd_in_str=":$username_in:$password_in"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_install_net "$tgt_ipaddr"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# prepare netroot= command line
|
|
Petr Šabata |
f5bf49 |
# FIXME: Do we need to parse and set other parameters like protocol, port
|
|
Petr Šabata |
f5bf49 |
# iscsi_iface_name, netdev_name, LUN etc.
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_ipv6_address $tgt_ipaddr; then
|
|
Petr Šabata |
f5bf49 |
tgt_ipaddr="[$tgt_ipaddr]"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
netroot_str="netroot=iscsi:${userpwd_str}${userpwd_in_str}@$tgt_ipaddr::::$tgt_name"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[[ -f $netroot_conf ]] || touch $netroot_conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# If netroot target does not exist already, append.
|
|
Petr Šabata |
f5bf49 |
if ! grep -q $netroot_str $netroot_conf; then
|
|
Petr Šabata |
f5bf49 |
echo $netroot_str >> $netroot_conf
|
|
Petr Šabata |
f5bf49 |
dinfo "Appended $netroot_str to $netroot_conf"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Setup initator
|
|
Petr Šabata |
f5bf49 |
initiator_str=$(kdump_get_iscsi_initiator)
|
|
Petr Šabata |
f5bf49 |
[ $? -ne "0" ] && derror "Failed to get initiator name" && return 1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# If initiator details do not exist already, append.
|
|
Petr Šabata |
f5bf49 |
if ! grep -q "$initiator_str" $netroot_conf; then
|
|
Petr Šabata |
f5bf49 |
echo "$initiator_str" >> $netroot_conf
|
|
Petr Šabata |
f5bf49 |
dinfo "Appended "$initiator_str" to $netroot_conf"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_check_iscsi_targets () {
|
|
Petr Šabata |
f5bf49 |
# If our prerequisites are not met, fail anyways.
|
|
Petr Šabata |
f5bf49 |
type -P iscsistart >/dev/null || return 1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_check_setup_iscsi() (
|
|
Petr Šabata |
f5bf49 |
local _dev
|
|
Petr Šabata |
f5bf49 |
_dev=$1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[[ -L /sys/dev/block/$_dev ]] || return
|
|
Petr Šabata |
f5bf49 |
cd "$(readlink -f /sys/dev/block/$_dev)"
|
|
Petr Šabata |
f5bf49 |
until [[ -d sys || -d iscsi_session ]]; do
|
|
Petr Šabata |
f5bf49 |
cd ..
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
[[ -d iscsi_session ]] && kdump_setup_iscsi_device "$PWD"
|
|
Petr Šabata |
f5bf49 |
)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
[[ $hostonly ]] || [[ $mount_needs ]] && {
|
|
Petr Šabata |
f5bf49 |
for_each_host_dev_and_slaves_all kdump_check_setup_iscsi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# hostname -a is deprecated, do it by ourself
|
|
Petr Šabata |
f5bf49 |
get_alias() {
|
|
Petr Šabata |
f5bf49 |
local ips
|
|
Petr Šabata |
f5bf49 |
local entries
|
|
Petr Šabata |
f5bf49 |
local alias_set
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
ips=$(hostname -I)
|
|
Petr Šabata |
f5bf49 |
for ip in $ips
|
|
Petr Šabata |
f5bf49 |
do
|
|
Petr Šabata |
f5bf49 |
# in /etc/hosts, alias can come at the 2nd column
|
|
Petr Šabata |
f5bf49 |
entries=$(grep $ip /etc/hosts | awk '{ $1=""; print $0 }')
|
|
Petr Šabata |
f5bf49 |
if [ $? -eq 0 ]; then
|
|
Petr Šabata |
f5bf49 |
alias_set="$alias_set $entries"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $alias_set
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
is_localhost() {
|
|
Petr Šabata |
f5bf49 |
local hostnames=$(hostname -A)
|
|
Petr Šabata |
f5bf49 |
local shortnames=$(hostname -A -s)
|
|
Petr Šabata |
f5bf49 |
local aliasname=$(get_alias)
|
|
Petr Šabata |
f5bf49 |
local nodename=$1
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
hostnames="$hostnames $shortnames $aliasname"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
for name in ${hostnames}; do
|
|
Petr Šabata |
f5bf49 |
if [ "$name" == "$nodename" ]; then
|
|
Petr Šabata |
f5bf49 |
return 0
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# retrieves fence_kdump nodes from Pacemaker cluster configuration
|
|
Petr Šabata |
f5bf49 |
get_pcs_fence_kdump_nodes() {
|
|
Petr Šabata |
f5bf49 |
local nodes
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
pcs cluster sync > /dev/null 2>&1 && pcs cluster cib-upgrade > /dev/null 2>&1
|
|
Petr Šabata |
f5bf49 |
# get cluster nodes from cluster cib, get interface and ip address
|
|
Petr Šabata |
f5bf49 |
nodelist=`pcs cluster cib | xmllint --xpath "/cib/status/node_state/@uname" -`
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# nodelist is formed as 'uname="node1" uname="node2" ... uname="nodeX"'
|
|
Petr Šabata |
f5bf49 |
# we need to convert each to node1, node2 ... nodeX in each iteration
|
|
Petr Šabata |
f5bf49 |
for node in ${nodelist}; do
|
|
Petr Šabata |
f5bf49 |
# convert $node from 'uname="nodeX"' to 'nodeX'
|
|
Petr Šabata |
f5bf49 |
eval $node
|
|
Petr Šabata |
f5bf49 |
nodename=$uname
|
|
Petr Šabata |
f5bf49 |
# Skip its own node name
|
|
Petr Šabata |
f5bf49 |
if is_localhost $nodename; then
|
|
Petr Šabata |
f5bf49 |
continue
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
nodes="$nodes $nodename"
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
echo $nodes
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# retrieves fence_kdump args from config file
|
|
Petr Šabata |
f5bf49 |
get_pcs_fence_kdump_args() {
|
|
Petr Šabata |
f5bf49 |
if [ -f $FENCE_KDUMP_CONFIG_FILE ]; then
|
|
Petr Šabata |
f5bf49 |
. $FENCE_KDUMP_CONFIG_FILE
|
|
Petr Šabata |
f5bf49 |
echo $FENCE_KDUMP_OPTS
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
get_generic_fence_kdump_nodes() {
|
|
Petr Šabata |
f5bf49 |
local filtered
|
|
Petr Šabata |
f5bf49 |
local nodes
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
nodes=$(get_option_value "fence_kdump_nodes")
|
|
Petr Šabata |
f5bf49 |
for node in ${nodes}; do
|
|
Petr Šabata |
f5bf49 |
# Skip its own node name
|
|
Petr Šabata |
f5bf49 |
if is_localhost $node; then
|
|
Petr Šabata |
f5bf49 |
continue
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
filtered="$filtered $node"
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
echo $filtered
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# setup fence_kdump in cluster
|
|
Petr Šabata |
f5bf49 |
# setup proper network and install needed files
|
|
Petr Šabata |
f5bf49 |
kdump_configure_fence_kdump () {
|
|
Petr Šabata |
f5bf49 |
local kdump_cfg_file=$1
|
|
Petr Šabata |
f5bf49 |
local nodes
|
|
Petr Šabata |
f5bf49 |
local args
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_generic_fence_kdump; then
|
|
Petr Šabata |
f5bf49 |
nodes=$(get_generic_fence_kdump_nodes)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
elif is_pcs_fence_kdump; then
|
|
Petr Šabata |
f5bf49 |
nodes=$(get_pcs_fence_kdump_nodes)
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# set appropriate options in kdump.conf
|
|
Petr Šabata |
f5bf49 |
echo "fence_kdump_nodes $nodes" >> ${kdump_cfg_file}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
args=$(get_pcs_fence_kdump_args)
|
|
Petr Šabata |
f5bf49 |
if [ -n "$args" ]; then
|
|
Petr Šabata |
f5bf49 |
echo "fence_kdump_args $args" >> ${kdump_cfg_file}
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
else
|
|
Petr Šabata |
f5bf49 |
# fence_kdump not configured
|
|
Petr Šabata |
f5bf49 |
return 1
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# setup network for each node
|
|
Petr Šabata |
f5bf49 |
for node in ${nodes}; do
|
|
Petr Šabata |
f5bf49 |
kdump_install_net $node
|
|
Petr Šabata |
f5bf49 |
done
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
dracut_install /etc/hosts
|
|
Petr Šabata |
f5bf49 |
dracut_install /etc/nsswitch.conf
|
|
Petr Šabata |
f5bf49 |
dracut_install $FENCE_KDUMP_SEND
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Install a random seed used to feed /dev/urandom
|
|
Petr Šabata |
f5bf49 |
# By the time kdump service starts, /dev/uramdom is already fed by systemd
|
|
Petr Šabata |
f5bf49 |
kdump_install_random_seed() {
|
|
Petr Šabata |
f5bf49 |
local poolsize=`cat /proc/sys/kernel/random/poolsize`
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if [ ! -d ${initdir}/var/lib/ ]; then
|
|
Petr Šabata |
f5bf49 |
mkdir -p ${initdir}/var/lib/
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
dd if=/dev/urandom of=${initdir}/var/lib/random-seed \
|
|
Petr Šabata |
f5bf49 |
bs=$poolsize count=1 2> /dev/null
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_install_systemd_conf() {
|
|
Petr Šabata |
f5bf49 |
local failure_action=$(get_option_value "failure_action")
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Kdump turns out to require longer default systemd mount timeout
|
|
Petr Šabata |
f5bf49 |
# than 1st kernel(90s by default), we use default 300s for kdump.
|
|
Petr Šabata |
f5bf49 |
grep -r "^[[:space:]]*DefaultTimeoutStartSec=" ${initdir}/etc/systemd/system.conf* &>/dev/null
|
|
Petr Šabata |
f5bf49 |
if [ $? -ne 0 ]; then
|
|
Petr Šabata |
f5bf49 |
mkdir -p ${initdir}/etc/systemd/system.conf.d
|
|
Petr Šabata |
f5bf49 |
echo "[Manager]" > ${initdir}/etc/systemd/system.conf.d/kdump.conf
|
|
Petr Šabata |
f5bf49 |
echo "DefaultTimeoutStartSec=300s" >> ${initdir}/etc/systemd/system.conf.d/kdump.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
DistroBaker |
5cac7c |
# Forward logs to console directly, and don't read Kmsg, this avoids
|
|
DistroBaker |
5cac7c |
# unneccessary memory consumption and make console output more useful.
|
|
Petr Šabata |
f5bf49 |
# Only do so for non fadump image.
|
|
DistroBaker |
5cac7c |
if ! is_fadump_capable; then
|
|
Petr Šabata |
f5bf49 |
mkdir -p ${initdir}/etc/systemd/journald.conf.d
|
|
Petr Šabata |
f5bf49 |
echo "[Journal]" > ${initdir}/etc/systemd/journald.conf.d/kdump.conf
|
|
DistroBaker |
5cac7c |
echo "Storage=volatile" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
|
|
DistroBaker |
5cac7c |
echo "ReadKMsg=no" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
|
|
Petr Šabata |
f5bf49 |
echo "ForwardToConsole=yes" >> ${initdir}/etc/systemd/journald.conf.d/kdump.conf
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
install() {
|
|
Petr Šabata |
f5bf49 |
kdump_install_conf
|
|
Petr Šabata |
f5bf49 |
overwrite_sysctl_conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
if is_ssh_dump_target; then
|
|
Petr Šabata |
f5bf49 |
kdump_install_random_seed
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
dracut_install -o /etc/adjtime /etc/localtime
|
|
Petr Šabata |
f5bf49 |
inst "$moddir/monitor_dd_progress" "/kdumpscripts/monitor_dd_progress"
|
|
Petr Šabata |
f5bf49 |
chmod +x ${initdir}/kdumpscripts/monitor_dd_progress
|
|
Petr Šabata |
f5bf49 |
inst "/bin/dd" "/bin/dd"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/tail" "/bin/tail"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/date" "/bin/date"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/sync" "/bin/sync"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/cut" "/bin/cut"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/head" "/bin/head"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/awk" "/bin/awk"
|
|
Petr Šabata |
f5bf49 |
inst "/bin/sed" "/bin/sed"
|
|
Petr Šabata |
f5bf49 |
inst "/sbin/makedumpfile" "/sbin/makedumpfile"
|
|
Petr Šabata |
f5bf49 |
inst "/sbin/vmcore-dmesg" "/sbin/vmcore-dmesg"
|
|
DistroBaker |
5cac7c |
inst "/usr/bin/printf" "/sbin/printf"
|
|
DistroBaker |
5cac7c |
inst "/usr/bin/logger" "/sbin/logger"
|
|
Petr Šabata |
f5bf49 |
inst "/lib/kdump/kdump-lib.sh" "/lib/kdump-lib.sh"
|
|
Petr Šabata |
f5bf49 |
inst "/lib/kdump/kdump-lib-initramfs.sh" "/lib/kdump-lib-initramfs.sh"
|
|
DistroBaker |
5cac7c |
inst "/lib/kdump/kdump-logger.sh" "/lib/kdump-logger.sh"
|
|
Petr Šabata |
f5bf49 |
inst "$moddir/kdump.sh" "/usr/bin/kdump.sh"
|
|
Petr Šabata |
f5bf49 |
inst "$moddir/kdump-capture.service" "$systemdsystemunitdir/kdump-capture.service"
|
|
DistroBaker |
7d0122 |
systemctl -q --root "$initdir" add-wants initrd.target kdump-capture.service
|
|
Petr Šabata |
f5bf49 |
inst "$moddir/kdump-error-handler.sh" "/usr/bin/kdump-error-handler.sh"
|
|
Petr Šabata |
f5bf49 |
inst "$moddir/kdump-error-handler.service" "$systemdsystemunitdir/kdump-error-handler.service"
|
|
Petr Šabata |
f5bf49 |
# Replace existing emergency service and emergency target
|
|
Petr Šabata |
f5bf49 |
cp "$moddir/kdump-emergency.service" "$initdir/$systemdsystemunitdir/emergency.service"
|
|
Petr Šabata |
f5bf49 |
cp "$moddir/kdump-emergency.target" "$initdir/$systemdsystemunitdir/emergency.target"
|
|
Petr Šabata |
f5bf49 |
# Also redirect dracut-emergency to kdump error handler
|
|
Petr Šabata |
f5bf49 |
ln_r "$systemdsystemunitdir/emergency.service" "$systemdsystemunitdir/dracut-emergency.service"
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Check for all the devices and if any device is iscsi, bring up iscsi
|
|
Petr Šabata |
f5bf49 |
# target. Ideally all this should be pushed into dracut iscsi module
|
|
Petr Šabata |
f5bf49 |
# at some point of time.
|
|
Petr Šabata |
f5bf49 |
kdump_check_iscsi_targets
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
kdump_install_systemd_conf
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# nfs/ssh dump will need to get host ip in second kernel and need to call 'ip' tool, see get_host_ip for more detail
|
|
Petr Šabata |
f5bf49 |
if is_nfs_dump_target || is_ssh_dump_target; then
|
|
Petr Šabata |
f5bf49 |
inst "ip"
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# For the lvm type target under kdump, in /etc/lvm/lvm.conf we can
|
|
Petr Šabata |
f5bf49 |
# safely replace "reserved_memory=XXXX"(default value is 8192) with
|
|
Petr Šabata |
f5bf49 |
# "reserved_memory=1024" to lower memory pressure under kdump. We do
|
|
Petr Šabata |
f5bf49 |
# it unconditionally here, if "/etc/lvm/lvm.conf" doesn't exist, it
|
|
Petr Šabata |
f5bf49 |
# actually does nothing.
|
|
Petr Šabata |
f5bf49 |
sed -i -e \
|
|
Petr Šabata |
f5bf49 |
's/\(^[[:space:]]*reserved_memory[[:space:]]*=\)[[:space:]]*[[:digit:]]*/\1 1024/' \
|
|
Petr Šabata |
f5bf49 |
${initdir}/etc/lvm/lvm.conf &>/dev/null
|
|
Petr Šabata |
f5bf49 |
|
|
Petr Šabata |
f5bf49 |
# Save more memory by dropping switch root capability
|
|
Petr Šabata |
f5bf49 |
if ! is_fadump_capable; then
|
|
Petr Šabata |
f5bf49 |
dracut_no_switch_root
|
|
Petr Šabata |
f5bf49 |
fi
|
|
Petr Šabata |
f5bf49 |
}
|