dracut: scan and install external kernel modules

since kmod-25 keyword "external" was implemented in order to avoid
additional actions(like weak-modules) when kernel was updated, which
makes it more simple while kernels' kabi were compatible.

but if move some special modules such as megaraid_sas, mpt3sas and
so on, to a external path like /opt/modules, these modules will not
be install to initramfs by default, which make the initramfs can't
be used to boot for disk detection failure.

according to kmod's document, you must specify a absolute path with
"external" keyword, so scan the lines in modules.dep that begin with
"/" and install them, to make sure necessary modules in external path
can be installed to initramfs too.

Signed-off-by: Hui Wang <john.wanghui@huawei.com>
master
Hui Wang 2018-06-19 12:07:46 -07:00 committed by Harald Hoyer
parent 4f55387829
commit a73ba9a8ef
1 changed files with 18 additions and 2 deletions

View File

@ -2,6 +2,20 @@

# called by dracut
installkernel() {
find_kernel_modules_external () {
local _OLDIFS
local external_pattern="^/"

[[ -f "$srcmods/modules.dep" ]] || return 0

_OLDIFS=$IFS
IFS=:
while read a rest; do
[[ $a =~ $external_pattern ]] || continue
printf "%s\n" "$a"
done < "$srcmods/modules.dep"
IFS=$_OLDIFS
}
local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma'

if [[ -z $drivers ]]; then
@ -26,7 +40,7 @@ installkernel() {
virtio virtio_blk virtio_ring virtio_pci virtio_scsi \
"=drivers/pcmcia" =ide nvme vmd

if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]; then
if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]; then
# arm/aarch64 specific modules
_blockfuncs+='|dw_mc_probe|dw_mci_pltfm_register'
instmods \
@ -50,12 +64,14 @@ installkernel() {
"=drivers/usb/misc" \
"=drivers/usb/musb" \
"=drivers/usb/phy" \
"=drivers/scsi/hisi_sas" \
"=drivers/scsi/hisi_sas" \
${NULL}
fi

dracut_instmods -o -s "${_blockfuncs}" "=drivers"

find_kernel_modules_external | instmods

# if not on hostonly mode, install all known filesystems,
# if the required list is not set via the filesystems variable
if ! [[ $hostonly ]]; then