dbginfo.sh: collect file list and config files from initrd-s

For each initrd, collect verbose content listing as well as
the content of files matching the file glob patterns in $CONFIGFILES.
For dracut-squash such as RHEL kdump, this includes squashfs content.

Code is intentionally compatible with dash, so no bashisms.

Ubuntu initramfs has zdev persistent device configuration udev rules under
/lib/udev/rules.d/ (as opposed to /etc/udev/rules.d/).
Ubuntu initramfs stores configuration under /conf/.
Ubuntu kdump-tools have initrds under /var/lib/kdump/.

SLES auxiliary boot stage with grub2-s390x-emu has initrds under /boot/zipl/.

Dracut initramfs stores configuration under /etc/cmdline.d/ and /etc/conf.d/.
Dracut kdump have initrds under /boot/.

Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158
Reviewed-by: Fedor Loshakov <loshakov@linux.ibm.com>
Acked-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Acked-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Steffen Maier <maier@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Steffen Maier
2023-01-20 19:31:22 +01:00
committed by Jan Höppner
parent 647ad51423
commit f8592be43d

View File

@@ -274,6 +274,7 @@ ALL_STEPS="\
collect_sysfs\
collect_procfs\
collect_configfiles\
collect_initrd_configfiles\
collect_cmdsout\
collect_hyptop\
collect_vmcmdsout\
@@ -381,11 +382,15 @@ CONFIGFILES="\
/boot/loader/entries/*.conf\
/boot/zipl/active_devices.txt\
/boot/zipl/config\
/conf/\
/etc/*.conf\
/etc/*release\
/etc/anacrontab\
/etc/apparmor.d\
/etc/auto.*\
/etc/cmdline\
/etc/cmdline.d\
/etc/conf.d\
/etc/cron.*\
/etc/crontab\
/etc/crypttab\
@@ -432,9 +437,10 @@ CONFIGFILES="\
/lib/modprobe.d\
$(find /lib/modules -name modules.dep 2>/dev/null)\
/lib/systemd/system/docker.service\
/lib/udev/rules.d\
/usr/lib/modprobe.d\
/usr/lib/modules-load.d/*.conf\
/usr/lib/systemd/system\
/usr/lib/systemd/system/\
/usr/local/lib/modprobe.d\
/usr/local/lib/modules-load.d/*.conf\
/run/modprobe.d\
@@ -905,6 +911,89 @@ collect_configfiles() {
done
}
########################################
collect_initrd_configfiles() {
local file_name
local rd rdbase rdreldir rdextract mypopd noglob mycat patterns=""
pr_collect "initrd config files"
cd "${WORKPATH}" || return
mypopd="$OLDPWD" # (pushd alternative)
# prevent expansion of glob special characters such as '*'
noglob=$(set +o | grep -F noglob)
set -o noglob
# prepare relative configfiles paths
for file_name in ${CONFIGFILES}; do
# strip leading slash to make path relative as in initrd
file_name=${file_name#/}
# in contrast to call_collect_file(), cpio extract with patterns
# does not recurse, but cpio wildcards match slash, so add suffix;
# otherwise e.g. /lib/udev/rules.d or /etc/multipath only extracts
# just that directory without any of its content
file_name="${file_name}*"
patterns="$patterns ${file_name}"
done
patterns="$patterns squash-root.img"
$noglob
# iterate over initrds
for rd in /boot/initr* /boot/zipl/initr* /var/lib/kdump/initr*; do
[ -f "$rd" ] || continue # (nullglob alternative)
rdbase=${rd##*/} # basename
rdreldir=${rd%/*} # dirname
rdreldir=${rdreldir#/} # strip leading slash to make path relative
mkdir -p "${rdreldir}"
cd "${rdreldir}" || break # (pushd alternative)
if type lsinitrd >/dev/null 2>&1; then
lsinitrd "${rd}" > "${rdbase}.lsinitrd"
fi
if type lsinitramfs >/dev/null 2>&1; then
lsinitramfs -l "${rd}" > "${rdbase}.lsinitramfs"
fi
cd - || break # change to $OLDPWD (popd alternative)
rdextract=${rd#/}
mkdir -p "${rdextract}"
cd "${rdextract}" || break # (pushd alternative)
case $(file "${rd}") in
*cpio*) mycat="cat" ;;
*gzip*) mycat="zcat" ;;
*XZ*) mycat="xzcat" ;;
*Zstandard*) mycat="zstdcat" ;;
*bzip2*) mycat="bzcat" ;;
*LZMA*) mycat="lzcat" ;;
*)
# change to $OLDPWD (popd alternative)
cd - || { cd "$mypopd" || return; return; }
continue
;;
esac
# prevent expansion of glob special characters such as '*'
noglob=$(set +o | grep -F noglob)
set -o noglob
# we expect no early-initrd stuff on s390 so extract directly.
# globbing is turned off and we want word split on $patterns:
# shellcheck disable=SC2086
"$mycat" "${rd}" | cpio --extract --no-absolute-filenames \
--make-directories \
--preserve-modification-time $patterns
$noglob
if [ ! -f "squash-root.img" ]; then
cd - || break # change to $OLDPWD (popd alternative)
continue
fi
# prevent expansion of glob special characters such as '*'
noglob=$(set +o | grep -F noglob)
set -o noglob
# globbing is turned off and we want word split on $patterns:
# shellcheck disable=SC2086
unsquashfs -no-progress -dest "squashfs-root" "squash-root.img" \
$patterns
$noglob
rm -f "squash-root.img"
cd - || break # change to $OLDPWD (popd alternative)
done
cd "$mypopd" || return
}
########################################
collect_osaoat() {
local network_devices