2021-12-29 16:26:41 -03:00
|
|
|
# Only include kdump if it is explicitly asked in the argument list
|
2023-03-31 15:34:26 -03:00
|
|
|
check() {
|
2022-12-22 19:02:05 -03:00
|
|
|
return 255
|
2023-03-31 15:34:26 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
installkernel() {
|
2023-03-22 20:08:47 -03:00
|
|
|
load_kdumpst_config
|
2022-12-28 13:15:36 -03:00
|
|
|
|
|
|
|
|
# First clear all unnecessary firmwares/drivers added by drm in order
|
|
|
|
|
# to reduce the size of the minimal initramfs being created - kdump
|
|
|
|
|
# is an non-graphical environment. This should have been already done
|
|
|
|
|
# via dracut cmdline arguments, but play safe and delete here as well.
|
2022-12-21 13:17:29 -03:00
|
|
|
# Our list includes the most common FWs/drivers (amd, i915, nvidia).
|
2022-12-28 13:15:36 -03:00
|
|
|
rm -rf "$initdir"/usr/lib/firmware/{amdgpu,i915,nvidia,radeon}
|
|
|
|
|
rm -rf "$initdir"/usr/lib/modules/*/kernel/drivers/gpu/drm/{amd,i915,nouveau,radeon}
|
|
|
|
|
|
|
|
|
|
FSMOD="$(findmnt -n -o FSTYPE --target "${MOUNT_FOLDER}")"
|
|
|
|
|
if [ -z "${FSMOD}" ]; then
|
2023-03-22 20:08:47 -03:00
|
|
|
logger "kdumpst: error on filesystem discovery"
|
2022-12-28 13:15:36 -03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2022-12-21 13:17:29 -03:00
|
|
|
instmods "${FSMOD}"
|
|
|
|
|
|
|
|
|
|
# We try here to be comprehensive and include the most common
|
|
|
|
|
# block modules to allow mounting the target device - notice
|
|
|
|
|
# that since we use hostonly, only the ones that make sense would
|
|
|
|
|
# get added, hence this list won't bloat the minimal image!
|
|
|
|
|
instmods aacraid
|
|
|
|
|
instmods ahci
|
|
|
|
|
instmods hpsa
|
|
|
|
|
instmods megaraid_sas
|
|
|
|
|
instmods mpt3sas
|
|
|
|
|
instmods nvme
|
|
|
|
|
instmods virtio_blk
|
|
|
|
|
instmods virtio-scsi
|
2023-03-31 15:34:26 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
install() {
|
2022-12-22 19:02:05 -03:00
|
|
|
# A valid makedumpfile is essential for the kdump initrd creation.
|
2022-12-21 13:17:29 -03:00
|
|
|
if ! command -v makedumpfile 1>/dev/null; then
|
2023-03-22 20:08:47 -03:00
|
|
|
logger "kdumpst: failed to create dracut initrd, makedumpfile is missing"
|
2022-12-22 19:02:05 -03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2022-02-22 19:02:08 -03:00
|
|
|
|
2023-03-22 20:08:47 -03:00
|
|
|
load_kdumpst_config
|
2022-11-24 19:29:18 -03:00
|
|
|
|
2022-12-22 19:02:05 -03:00
|
|
|
# Install necessary binaries
|
|
|
|
|
inst date
|
|
|
|
|
inst sync
|
|
|
|
|
inst makedumpfile
|
2022-11-25 17:07:13 -03:00
|
|
|
|
2023-03-22 20:08:47 -03:00
|
|
|
# Copying kdumpst config/lib files is essential for a functional kdump.
|
|
|
|
|
cp -LR --preserve=all /usr/share/kdumpst.d/ "$initdir"/usr/share/
|
|
|
|
|
cp -LR --preserve=all /usr/lib/kdumpst/ "$initdir"/usr/lib/
|
2022-02-22 19:02:08 -03:00
|
|
|
|
2022-12-28 13:15:36 -03:00
|
|
|
# Finally, we need to derive the proper place to save the dump from the
|
|
|
|
|
# config files, in a way that makes possible to mount it in early boot.
|
|
|
|
|
DEVNODE="$(findmnt -n -o SOURCE --target "${MOUNT_FOLDER}")"
|
|
|
|
|
if [ -z "${DEVNODE}" ]; then
|
2023-03-22 20:08:47 -03:00
|
|
|
logger "kdumpst: error on devnode discovery"
|
2022-12-28 13:15:36 -03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
2023-03-22 20:08:47 -03:00
|
|
|
echo "${DEVNODE}" > "$initdir"/usr/lib/kdumpst/kdump.mnt
|
2022-02-22 19:02:08 -03:00
|
|
|
|
2022-12-28 13:15:36 -03:00
|
|
|
TGT="$(findmnt -n -o TARGET --target "${MOUNT_FOLDER}")"
|
|
|
|
|
if [ -z "${TGT}" ]; then
|
2023-03-22 20:08:47 -03:00
|
|
|
logger "kdumpst: error on base folder discovery"
|
2022-12-28 13:15:36 -03:00
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
BASE_FLD="${MOUNT_FOLDER#*$TGT}"
|
2023-03-22 20:08:47 -03:00
|
|
|
echo "${BASE_FLD}" > "$initdir"/usr/lib/kdumpst/kdump.dir
|
2023-03-31 15:34:26 -03:00
|
|
|
|
2022-12-22 19:02:05 -03:00
|
|
|
inst_hook pre-mount 01 "$moddir/kdump-collect.sh"
|
2023-03-31 15:34:26 -03:00
|
|
|
}
|