mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
zipl: Add initramfs-tools module for NGDump
The NGDump initramfs-tools module is required to build an initramfs image to be used with NGDump stand-alone dump. NGDump stand-alone dump does not use a pre-built initramfs image in contrast to SCSI stand-alone dump. Instead, an initramfs image is built with initramfs-tools if NGDump stand-alone dump is installed on a NVMe partition. The NGDump initramfs-tools module ensures that all necessary tools are present within the built initramfs and a dump of /proc/vmcore is initiated to the chosen NVMe partition when the installed dumper is IPLed. The NGDump intramfs-tools module installs a configuration file and a dump script into dumper initramfs. This dump script starts at boot shortly after the initialization of the dump target device. It reads the aforementioned configuration file that contains the name of a dump partition to store a dump on. The dump script reads the configuration file, mounts then the dump target device, creates a copy of /proc/vmcore with the makedumpfile tool on it, and then shuts down the system. Ubuntu and Debian are the main Linux distributions targeted by this initramfs-tools module. Signed-off-by: Alexander Egorenkov <egorenar@linux.ibm.com> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Tested-by: Alexander Gordeev <agordeev@linux.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
85c9a49e63
commit
c1d08e1380
@@ -9,6 +9,7 @@ install: all
|
||||
$(MAKE) -C src install
|
||||
$(MAKE) -C man install
|
||||
$(MAKE) -C dracut install
|
||||
$(MAKE) -C initramfs-tools install
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 doc/zipl.conf.minimal $(DESTDIR)$(TOOLS_LIBDIR)/zipl.conf
|
||||
ifeq ($(wildcard $(DESTDIR)$(SYSCONFDIR)/ziplenv),)
|
||||
$(INSTALL) -g $(GROUP) -o $(OWNER) -m 644 doc/ziplenv.minimal $(DESTDIR)$(SYSCONFDIR)/ziplenv
|
||||
|
||||
24
zipl/initramfs-tools/Makefile
Normal file
24
zipl/initramfs-tools/Makefile
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
include ../../common.mak
|
||||
|
||||
INITRAMFSTOOLSDIR := /usr/share/initramfs-tools
|
||||
HOOKSDIR := $(INITRAMFSTOOLSDIR)/hooks
|
||||
INITPREMOUNTDIR := $(INITRAMFSTOOLSDIR)/scripts/init-premount
|
||||
|
||||
# HAVE_INITRAMFS
|
||||
#
|
||||
# This install time parameter determines whether the ngdump initramfs-tools
|
||||
# support is installed (HAVE_INITRAMFS=1) or not (default). When installed,
|
||||
# the module performs the following functions when mkinitramfs is run:
|
||||
#
|
||||
# - install the configuration file containing the name of a dump partition
|
||||
# - install the dump script that is run at boot
|
||||
#
|
||||
ifeq ($(HAVE_INITRAMFS),1)
|
||||
install:
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(HOOKSDIR)
|
||||
$(INSTALL) -m 755 -d $(DESTDIR)$(INITPREMOUNTDIR)
|
||||
$(INSTALL) -m 755 hooks/ngdump $(DESTDIR)$(HOOKSDIR)/
|
||||
$(INSTALL) -m 755 scripts/init-premount/ngdump \
|
||||
$(DESTDIR)$(INITPREMOUNTDIR)
|
||||
endif
|
||||
50
zipl/initramfs-tools/hooks/ngdump
Executable file
50
zipl/initramfs-tools/hooks/ngdump
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2021
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
|
||||
OPTION=NGDUMP
|
||||
PREREQ=""
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "$PREREQ"
|
||||
}
|
||||
|
||||
case "${1}" in
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /usr/share/initramfs-tools/hook-functions
|
||||
|
||||
#
|
||||
# Install required kernel modules
|
||||
#
|
||||
manual_add_modules nvme ext4
|
||||
block_dev_mod_add "$NGDUMP_DEVICE"
|
||||
|
||||
#
|
||||
# Installs required tools
|
||||
#
|
||||
for tool in logsave findmnt sha256sum makedumpfile; do
|
||||
path=$(command -v "$tool")
|
||||
if [ ! -e "$path" ]; then
|
||||
echo "$tool not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
copy_exec $path
|
||||
done
|
||||
|
||||
force_load nvme
|
||||
|
||||
#
|
||||
# Store the dump partition in a config file within initramfs.
|
||||
# The config file will be included by the dump script.
|
||||
#
|
||||
echo "NGDUMP_DEVICE=${NGDUMP_DEVICE}" > "${DESTDIR}/conf/conf.d/ngdump"
|
||||
108
zipl/initramfs-tools/scripts/init-premount/ngdump
Executable file
108
zipl/initramfs-tools/scripts/init-premount/ngdump
Executable file
@@ -0,0 +1,108 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright IBM Corp. 2021
|
||||
#
|
||||
# s390-tools is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the MIT license. See LICENSE for details.
|
||||
#
|
||||
|
||||
OPTION=NGDUMP
|
||||
PREREQ="udev"
|
||||
|
||||
prereqs()
|
||||
{
|
||||
echo "${PREREQ}"
|
||||
}
|
||||
|
||||
case "${1}" in
|
||||
prereqs)
|
||||
prereqs
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
. /scripts/functions
|
||||
. /conf/conf.d/ngdump
|
||||
|
||||
MNTDIR="/ngdump"
|
||||
DUMP="dump.elf"
|
||||
META="ngdump.meta"
|
||||
VMCORE="/proc/vmcore"
|
||||
|
||||
is_dump_part_ok()
|
||||
{
|
||||
findmnt "$MNTDIR" >/dev/null 2>&1 && [ -e "$MNTDIR/$META" ]
|
||||
}
|
||||
|
||||
save_logs()
|
||||
{
|
||||
is_dump_part_ok || return
|
||||
[ -e "$VMCORE" ] && makedumpfile -f --dump-dmesg "$VMCORE" "$MNTDIR/crash.log"
|
||||
dmesg >"$MNTDIR/boot.log"
|
||||
}
|
||||
|
||||
#
|
||||
# The following steps make the firmware IPL the production system again.
|
||||
# Otherwise, the firmware will boot the dumper again.
|
||||
#
|
||||
reipl()
|
||||
{
|
||||
dir=$(findmnt -n -o TARGET debugfs)
|
||||
if [ -z "$dir" ]; then
|
||||
dir=/sys/kernel/debug
|
||||
mount -t debugfs none "$dir"
|
||||
fi
|
||||
echo 1 > "$dir/zcore/reipl"
|
||||
sleep 5 # To give console enough time to display last messages
|
||||
halt
|
||||
}
|
||||
|
||||
quit()
|
||||
{
|
||||
log_end_msg
|
||||
sync
|
||||
umount "$MNTDIR"
|
||||
reipl
|
||||
}
|
||||
|
||||
bail_out()
|
||||
{
|
||||
log_failure_msg "$1"
|
||||
save_logs
|
||||
quit
|
||||
}
|
||||
|
||||
save_meta()
|
||||
{
|
||||
local hash=$(sha256sum "$MNTDIR/$DUMP" | cut -f1 -d ' ')
|
||||
|
||||
cat >"$MNTDIR/$META" <<EOF
|
||||
version=1
|
||||
file=$DUMP
|
||||
sha256sum=$hash
|
||||
EOF
|
||||
}
|
||||
|
||||
log_begin_msg "NGDump"
|
||||
|
||||
[ -e "$NGDUMP_DEVICE" ] ||
|
||||
{ bail_out "Dump partition device '$NGDUMP_DEVICE' not found"; }
|
||||
|
||||
mkdir "$MNTDIR" && mount -t ext4 "$NGDUMP_DEVICE" "$MNTDIR"
|
||||
|
||||
is_dump_part_ok || { bail_out "Dump partition not found"; }
|
||||
|
||||
#
|
||||
# We must save the dump as ELF format, because
|
||||
# kdump compressed format is not supported by zgetdump yet
|
||||
#
|
||||
logsave "$MNTDIR/makedumpfile.log" makedumpfile -f -E --message-level 7 -d 31 "$VMCORE" "$MNTDIR/$DUMP"
|
||||
|
||||
[ $? -eq 0 ] || { bail_out "makedumpfile failed"; }
|
||||
|
||||
#
|
||||
# Create a file containing meta information for zgetdump
|
||||
#
|
||||
save_meta
|
||||
|
||||
quit
|
||||
Reference in New Issue
Block a user