In some x86_64 platforms such as Intel Elkhartlake, an issue of missing
necessary modules due to udevadm drivers field unmatch the real kernel module
name is found:
$ udevadm info -a /dev/block/179:1
looking at parent device '/devices/pci0000:00/0000:00:1a.0/mmc_host/mmc0/mmc0:0001':
KERNELS=="mmc0:0001"
SUBSYSTEMS=="mmc"
DRIVERS=="mmcblk"
....
The DRIVERS field, aka mmcblk will be given to instmods to install the
corresponding mmc_block.ko kernel module. However mmc_block.ko cannot be
selected by string mmcblk, as a result, mmc_block.ko cannot be installed
in hostonly-mode strict, which will fail to bootup the machine such as in
kdump cases:
$ /usr/lib/dracut/dracut-install -D /var/tmp --kerneldir /lib/modules/$(uname -r)/ -m mmcblk
dracut-install: Failed to find module 'mmcblk'
In this patch, we will convert the string mmcblk to mmc_block, so the
kernel module can be successfully loaded.
Signed-off-by: Tao Liu <ltao@redhat.com>
block_is_nbd "$1" || block_is_iscsi "$1" || block_is_fcoe "$1"
}
+# convert the driver name given by udevadm to the corresponding kernel module name
+get_module_name() {
+ local dev_driver
+ while read -r dev_driver; do
+ case "$dev_driver" in
+ mmcblk)
+ echo "mmc_block"
+ ;;
+ *)
+ echo "$dev_driver"
+ ;;
+ esac
+ done
+}
+
# get the corresponding kernel modules of a /sys/class/*/* or/dev/* device
get_dev_module() {
local dev_attr_walk
local dev_drivers
local dev_paths
dev_attr_walk=$(udevadm info -a "$1")
- dev_drivers=$(echo "$dev_attr_walk" | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p')
+ dev_drivers=$(echo "$dev_attr_walk" \
+ | sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \
+ | get_module_name)
# also return modalias info from sysfs paths parsed by udevadm
dev_paths=$(echo "$dev_attr_walk" | sed -n 's/.*\(\/devices\/.*\)'\'':/\1/p')
[[ -n $dev_drivers && ${dev_drivers: -1} != $'\n' ]] && dev_drivers+=$'\n'
dev_drivers+=$(udevadm info -a "$dev_vpath/$dev_link" \
| sed -n 's/\s*DRIVERS=="\(\S\+\)"/\1/p' \
+ | get_module_name \
| grep -v -e pcieport)
done
fi