mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Otherwise, dracut skips modules that are "not hostonly", i.e. not used /
loaded on the system when running dracut to build an initrd.
Without the fix, zdev device auto configuration only works for device
types for which a device driver happened to be loaded when building an
initrd. Likewise for specifying rd.* boot options.
Hostonly mode is often the default in Linux distributions.
Make zdev device auto configuration work nonetheless without users
having to know about and tweak dracut modes for initrd generation.
On the typical sloppy hostonly mode, the code disables hostonly for
installing kernel modules. This covers building regular initrds, where zdev
device auto configuration should even work for device types, for which
device drivers were not loaded when an initrd was generated. This can
happen when new devices of new types are configured for a DPM logical
partition. Also, users could want to start using dracut cmdline options
rd.{dasd,zfcp,znet} for a device type that was not used when the initrd was
built.
The special strict hostonly mode is used by some kdump implementations. In
that case, hostonly remains in effect intentionally because only support
for the really required devices as determined by dracut module 95zdev-kdump
should be included in a kdump initrd due to the memory-constrained kdump
environment. Cf. commit 73c46a3056 ("zdev/dracut: fix kdump by only
activating required devices"), which also provides more references on
strict hostonly mode. Even for non-kdump cases, let strict hostonly mode be
effective here in 95zdev in case some future use case appears for this
special mode beyond kdump.
Github-ID: https://github.com/ibm-s390-linux/s390-tools/pull/158
Reviewed-by: Alexander Egorenkov <egorenar@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>
102 lines
3.0 KiB
Bash
102 lines
3.0 KiB
Bash
#!/bin/bash
|
|
#
|
|
# 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.
|
|
#
|
|
#
|
|
# 95zdev/module_setup.sh
|
|
# This module installs configuration files (udev rules and modprobe.conf
|
|
# files) required to enable the root device on s390. It will only work when
|
|
# the root device was configured using the chzdev tool. In addition,
|
|
# a hook is installed to parse rd.zdev= kernel parameters.
|
|
#
|
|
|
|
# called by dracut
|
|
check() {
|
|
local _arch
|
|
_arch=$(uname -m)
|
|
|
|
# Ensure that we're running on s390
|
|
[ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ] || return 1
|
|
|
|
# shellcheck source=/dev/null
|
|
source "${moddir:?}/zdev-lib.sh"
|
|
|
|
# Leave kdump device configuration to module zdev-kdump to
|
|
# ensure a minimal device footprint
|
|
zdev_is_kdump && return 1
|
|
|
|
# Ensure that required tools are available
|
|
require_binaries chzdev lszdev /lib/s390-tools/zdev_id || return 1
|
|
|
|
return 0
|
|
}
|
|
|
|
# called by dracut
|
|
depends() {
|
|
return 0
|
|
}
|
|
|
|
# called by dracut
|
|
installkernel() {
|
|
# Add modules for all device types supported by chzdev (required for
|
|
# auto-configuration)
|
|
hostonly="$(optional_hostonly)" \
|
|
instmods ctcm lcs qeth qeth_l2 qeth_l3 dasd_mod dasd_eckd_mod dasd_fba_mod \
|
|
dasd_diag_mod zfcp
|
|
}
|
|
|
|
# called by dracut
|
|
install() {
|
|
local _tempfile
|
|
|
|
# Ensure that required tools are available
|
|
inst_multiple chzdev lszdev vmcp /lib/s390-tools/zdev_id
|
|
|
|
# Hook to parse zdev kernel parameter
|
|
inst_hook cmdline 95 "$moddir/parse-zdev.sh"
|
|
|
|
# Rule to automatically enable devices when running in DPM
|
|
inst_rules "81-dpm.rules"
|
|
|
|
# Obtain early + root device configuration
|
|
_tempfile=$(mktemp --tmpdir dracut-zdev.XXXXXX)
|
|
function check_zdev() {
|
|
local _dev=$1
|
|
local _devsysfs _bdevpath
|
|
_devsysfs=$(
|
|
cd -P /sys/dev/block/"$_dev" && echo "$PWD"
|
|
)
|
|
_bdevpath=/dev/${_devsysfs##*/}
|
|
chzdev --export - --persistent --by-node "$_bdevpath" --quiet \
|
|
--type 2>/dev/null >> "$_tempfile"
|
|
}
|
|
for_each_host_dev_and_slaves_all check_zdev
|
|
|
|
chzdev --export - --persistent --by-attrib "zdev:early=1" --quiet \
|
|
--type 2>/dev/null >> "$_tempfile"
|
|
|
|
# Obtain early device configuration for site-specific settings
|
|
for (( site=0; site<10; site++ ))
|
|
do
|
|
chzdev --export - --persistent --by-attrib "zdev:early=1" --site $site \
|
|
--quiet 2>/dev/null >> "$_tempfile"
|
|
done
|
|
|
|
# Apply via --import to prevent other devices from being configured
|
|
chzdev --import "$_tempfile" --persistent --base "/etc=${initdir:?}/etc" \
|
|
--yes --quiet --no-root-update --force >/dev/null
|
|
# Apply site-specific configurations via --import
|
|
for (( site=0; site<10; site++ ))
|
|
do
|
|
chzdev --import "$_tempfile" --persistent --base "/etc=$initdir/etc" \
|
|
--site $site --yes --quiet --no-root-update --force >/dev/null
|
|
done
|
|
|
|
rm -f "$_tempfile"
|
|
|
|
return 0
|
|
}
|