2023-01-12 15:31:01 +00:00
|
|
|
#! /bin/bash
|
2018-05-22 10:15:08 +00:00
|
|
|
|
|
|
|
KEXEC=/sbin/kexec
|
|
|
|
standard_kexec_args="-p"
|
|
|
|
|
|
|
|
EARLY_KDUMP_INITRD=""
|
|
|
|
EARLY_KDUMP_KERNEL=""
|
|
|
|
EARLY_KDUMP_CMDLINE=""
|
|
|
|
EARLY_KEXEC_ARGS=""
|
|
|
|
|
|
|
|
. /etc/sysconfig/kdump
|
|
|
|
. /lib/dracut-lib.sh
|
|
|
|
. /lib/kdump-lib.sh
|
2021-01-19 12:10:28 +00:00
|
|
|
. /lib/kdump-logger.sh
|
2018-05-22 10:15:08 +00:00
|
|
|
|
2021-09-13 08:40:25 +00:00
|
|
|
# initiate the kdump logger
|
|
|
|
if ! dlog_init; then
|
2020-10-27 09:04:22 +00:00
|
|
|
echo "failed to initiate the kdump logger."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-05-22 10:15:08 +00:00
|
|
|
prepare_parameters()
|
|
|
|
{
|
|
|
|
EARLY_KDUMP_CMDLINE=$(prepare_cmdline "${KDUMP_COMMANDLINE}" "${KDUMP_COMMANDLINE_REMOVE}" "${KDUMP_COMMANDLINE_APPEND}")
|
2020-07-26 17:37:19 +00:00
|
|
|
EARLY_KDUMP_KERNEL="/boot/kernel-earlykdump"
|
|
|
|
EARLY_KDUMP_INITRD="/boot/initramfs-earlykdump"
|
2018-05-22 10:15:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
early_kdump_load()
|
|
|
|
{
|
2021-09-13 08:40:25 +00:00
|
|
|
if ! check_kdump_feasibility; then
|
2018-05-22 10:15:08 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if is_fadump_capable; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dwarn "WARNING: early kdump doesn't support fadump."
|
2018-05-22 10:15:08 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
2023-01-12 15:31:02 +00:00
|
|
|
if is_kernel_loaded "kdump"; then
|
2018-05-22 10:15:08 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
prepare_parameters
|
|
|
|
|
|
|
|
EARLY_KEXEC_ARGS=$(prepare_kexec_args "${KEXEC_ARGS}")
|
|
|
|
|
2020-06-29 13:13:54 +00:00
|
|
|
if is_secure_boot_enforced; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dinfo "Secure Boot is enabled. Using kexec file based syscall."
|
2018-05-22 10:15:08 +00:00
|
|
|
EARLY_KEXEC_ARGS="$EARLY_KEXEC_ARGS -s"
|
|
|
|
fi
|
|
|
|
|
2020-10-29 02:21:09 +00:00
|
|
|
# Here, only output the messages, but do not save these messages
|
|
|
|
# to a file because the target disk may not be mounted yet, the
|
|
|
|
# earlykdump is too early.
|
2020-10-27 09:04:22 +00:00
|
|
|
ddebug "earlykdump: $KEXEC ${EARLY_KEXEC_ARGS} $standard_kexec_args \
|
|
|
|
--command-line=$EARLY_KDUMP_CMDLINE --initrd=$EARLY_KDUMP_INITRD \
|
|
|
|
$EARLY_KDUMP_KERNEL"
|
|
|
|
|
2023-01-12 15:31:00 +00:00
|
|
|
# shellcheck disable=SC2086
|
2021-09-13 08:40:25 +00:00
|
|
|
if $KEXEC $EARLY_KEXEC_ARGS $standard_kexec_args \
|
2018-05-22 10:15:08 +00:00
|
|
|
--command-line="$EARLY_KDUMP_CMDLINE" \
|
2021-09-13 08:40:25 +00:00
|
|
|
--initrd=$EARLY_KDUMP_INITRD $EARLY_KDUMP_KERNEL; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dinfo "kexec: loaded early-kdump kernel"
|
2018-05-22 10:15:08 +00:00
|
|
|
return 0
|
|
|
|
else
|
2020-10-27 09:04:22 +00:00
|
|
|
derror "kexec: failed to load early-kdump kernel"
|
2018-05-22 10:15:08 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
set_early_kdump()
|
|
|
|
{
|
|
|
|
if getargbool 0 rd.earlykdump; then
|
2020-10-27 09:04:22 +00:00
|
|
|
dinfo "early-kdump is enabled."
|
2018-05-22 10:15:08 +00:00
|
|
|
early_kdump_load
|
|
|
|
else
|
2020-10-27 09:04:22 +00:00
|
|
|
dinfo "early-kdump is disabled."
|
2018-05-22 10:15:08 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
set_early_kdump
|