Thanks to Emil (@xexaxo) suggestion, we hereby implement a less fragile
way of obtaining the "/home" mount point. Emil suggested that instead of
using device name directly, we could use the generic link, as in:
"/dev/disk/by-partsets/shared/home".
In principle the change would be simple, but it proved to be a bit tricky
due to the early boot stage kdump executes - in such point we don't have
this link available, so we need to rely in the full device name directly
on kdump collection. We achieve that by saving this information in the
kdump initrd - this is not completely safe, see the CAVEAT below.
Also, we improved kdump loading script by using "findmnt", a less
fragile / more elegant way of getting the "/home" mount point.
CAVEAT: NVMe multipathing introduced a "randomness" level to device
naming on Linux, so "nvme0n1" could be "nvme1n1" in some boots, if we
have more than one device. There is a kernel parameter to avoid that
("nvme_core.multipath=0"), see [0] for more information.
Due to this reason, we could in theory have different NVMe device
names between regular kernel boot and the kdump one, hence causing a
failure in kdump collection.
But this is pretty much safe since we don't have multiple NVMe
devices, also we could disable multipath in kernel config
(CONFIG_NVME_MULTIPATH) or use the above cmdline.
[0] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1792660/
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
48 lines
1.2 KiB
Bash
48 lines
1.2 KiB
Bash
#!/bin/sh
|
|
#
|
|
# SPDX-License-Identifier: LGPL-2.1+
|
|
#
|
|
# Copyright (c) 2021 Valve.
|
|
#
|
|
# Kdump script that should effectively collect the core dump/dmesg from
|
|
# within a Dracut-generated initramfs on SteamOS kdump.
|
|
# The most fail-prone operations are guarded with conditionals to bail
|
|
# in case we indeed fail - worst thing here would be to have a bad condition
|
|
# and get stuck in this minimal initramfs with no output for the user.
|
|
#
|
|
|
|
. /usr/lib/kdump/kdump.etc
|
|
|
|
VMCORE="/proc/vmcore"
|
|
KDUMP_TIMESTAMP=$(date -u +"%Y%m%d%H%M")
|
|
KDUMP_FOLDER="/kdump_path/${KDUMP_FOLDER}/crash/${KDUMP_TIMESTAMP}"
|
|
|
|
# Bail out in case we don't have a vmcore, i.e. either we're not kdumping
|
|
# or something is pretty wrong and we wouldn't be able to progress.
|
|
#
|
|
if [ ! -f $VMCORE ]; then
|
|
reboot -f
|
|
fi
|
|
|
|
DEVN="$(cat /usr/lib/kdump/kdump.devnode)"
|
|
mkdir -p "/kdump_path"
|
|
|
|
if ! mount "${DEVN}" /kdump_path; then
|
|
reboot -f
|
|
fi
|
|
|
|
mkdir -p "${KDUMP_FOLDER}"
|
|
|
|
/usr/bin/makedumpfile ${MAKEDUMPFILE_DMESG_CMD} $VMCORE "${KDUMP_FOLDER}/dmesg.txt"
|
|
sync "${KDUMP_FOLDER}/dmesg.txt"
|
|
|
|
if [ "${FULL_COREDUMP}" -ne 0 ]; then
|
|
/usr/bin/makedumpfile ${MAKEDUMPFILE_COREDUMP_CMD} $VMCORE "${KDUMP_FOLDER}/vmcore.compressed"
|
|
sync "${KDUMP_FOLDER}/vmcore.compressed"
|
|
fi
|
|
|
|
umount "${DEVN}"
|
|
sync
|
|
|
|
reboot -f
|