]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
dracut: scan and install external kernel modules
authorHui Wang <john.wanghui@huawei.com>
Tue, 19 Jun 2018 19:07:46 +0000 (12:07 -0700)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 2 Jul 2018 09:40:42 +0000 (11:40 +0200)
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>
modules.d/90kernel-modules/module-setup.sh

index 35b4af7fca89ff8c0145f252f019e70a1d2e1d84..a197a606062945512054e45f4b8b2660fef04f45 100755 (executable)
@@ -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