Files
s390-tools/zdev/initramfs/hooks/s390-tools-zdev
Peter Oberparleiter 6dd671f24e zdev: Make initramfs root configuration more robust
zdev's initramfs hook does not add directives for enabling the root
device to the initrd if the root device is only configured in the
active configuration. As a result, a reboot using the new initrd fails
because the root device cannot be found.

This situation can occur for example when the zdev initramfs hook is
called from within an installer, where devices are only enabled in the
active configuration.

Address this situation by considering both the active and persistent
configuration of the root device during initramfs configuration. In case
the device is configured in both configurations, the persistent
configuration takes precedence.

Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
2025-05-06 13:40:36 +02:00

62 lines
1.7 KiB
Bash

#!/bin/sh
#
# Copyright IBM Corp. 2016, 2017
#
# s390-tools is free software; you can redistribute it and/or modify
# it under the terms of the MIT license. See LICENSE for details.
#
# hooks/s390-tools-zdev
# This hook script adds files required to apply firmware-provided I/O
# configuration data during boot.
#
# Needs to run after udev or resulting udev rules could be overwritten
PREREQ="udev"
prereqs()
{
echo "$PREREQ"
}
case $1 in
prereqs)
prereqs
exit 0
;;
esac
. /usr/share/initramfs-tools/hook-functions
# Add modules for all device types supported by chzdev (required for
# auto-configuration)
zdev_modules="lcs qeth qeth_l2 qeth_l3 dasd_mod dasd_eckd_mod dasd_fba_mod dasd_diag_mod zfcp"
for x in $zdev_modules ; do
manual_add_modules ${x}
done
copy_exec /sbin/chzdev
copy_exec /sbin/lszdev
copy_exec /sbin/vmcp
copy_exec /lib/s390-tools/zdev_id
cp -p /usr/lib/udev/rules.d/81-dpm.rules "$DESTDIR/usr/lib/udev/rules.d/"
_tempfile=$(mktemp --tmpdir initramfs-zdev.XXXXXX)
# Obtain early + root device configuration
chzdev --export - --active --by-path / --quiet 2>/dev/null |
sed -e 's/active/persistent/g' > "$_tempfile"
chzdev --export - --persistent --by-path / --by-attrib "zdev:early=1" \
--quiet --type 2>/dev/null >>"$_tempfile"
# Apply via --import to prevent other devices from being configured.
# Rename the resulting cio-ignore rule to ensure that it does not override
# the one copied by the initramfs udev hook to /lib/udev.
chzdev --import "$_tempfile" --persistent \
--base "/etc/udev/rules.d/41-cio-ignore.rules=$DESTDIR/etc/udev/rules.d/41-cio-ignore-root.rules" \
--base "/etc=$DESTDIR/etc" --yes --quiet --no-root-update --force \
>/dev/null
rm -f "$_tempfile"