]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix: load more kernel modules in sloppy hostonly mode
authorJo Zzsi <jozzsicsataban@gmail.com>
Wed, 23 Apr 2025 23:21:59 +0000 (19:21 -0400)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Sun, 4 May 2025 21:52:56 +0000 (17:52 -0400)
When hostonly_mode is set to "sloppy" instmods consults the host for currently loaded kernel modules and
refuses to copy the Linux kernel module into the generated initramfs unless the kernel
module is already loaded on the host.

Let's set hostonly explicitly to a better default before calling instmods.

For compatibility, we should not change the default in the instmods function itself.

32 files changed:
man/dracut.modules.7.adoc
modules.d/00systemd/module-setup.sh
modules.d/01systemd-integritysetup/module-setup.sh
modules.d/01systemd-portabled/module-setup.sh
modules.d/01systemd-pstore/module-setup.sh
modules.d/01systemd-veritysetup/module-setup.sh
modules.d/04watchdog-modules/module-setup.sh
modules.d/35network-manager/module-setup.sh
modules.d/45drm/module-setup.sh
modules.d/45simpledrm/module-setup.sh
modules.d/62bluetooth/module-setup.sh
modules.d/90btrfs/module-setup.sh
modules.d/90crypt/module-setup.sh
modules.d/90dm/module-setup.sh
modules.d/90dmsquash-live-autooverlay/module-setup.sh
modules.d/90dmsquash-live/module-setup.sh
modules.d/90kernel-modules/module-setup.sh
modules.d/90kernel-network-modules/module-setup.sh
modules.d/90mdraid/module-setup.sh
modules.d/90pcmcia/module-setup.sh
modules.d/90ppcmac/module-setup.sh
modules.d/91tpm2-tss/module-setup.sh
modules.d/95cifs/module-setup.sh
modules.d/95fcoe/module-setup.sh
modules.d/95iscsi/module-setup.sh
modules.d/95nbd/module-setup.sh
modules.d/95nvmf/module-setup.sh
modules.d/95virtfs/module-setup.sh
modules.d/95virtiofs/module-setup.sh
modules.d/97masterkey/module-setup.sh
modules.d/98ecryptfs/module-setup.sh
modules.d/99fs-lib/module-setup.sh

index 7c2dbd9a03cedbad26c1dd44c087b62c8cbccb28..e1b2b5e08f639795499fc0d25f57a10cd487979d 100644 (file)
@@ -332,6 +332,15 @@ To install a kernel module regardless of the hostonly mode use the form:
 hostonly='' instmods <kernelmodule>
 ----
 
+a common pattern to call instmods is to use the following form:
+----
+`hostonly=$(optional_hostonly) instmods <kernelmodule>`
+----
+This statement installs the kernel module in either of the following conditions:
+* in non-hostonly mode (regardless of the host state)
+* in `sloppy` hostonly mode (regardless of the host state)
+* in hostonly mode if the kernel module is already loaded in the host
+
 options:
 
 -c:: check that kernel modules exists and can be installed (i.e., not optional).
index 8f25475eeae8b89a8e090d0d7b6c7bbfa194b6cd..854a2f9b4d48a66ef2b82ed3fc7707fb4a53e3ce 100755 (executable)
@@ -16,7 +16,7 @@ check() {
 
 installkernel() {
     hostonly='' instmods autofs4 ipv6 dmi-sysfs
-    instmods -s efivarfs
+    hostonly=$(optional_hostonly) instmods -s efivarfs
 }
 
 # called by dracut
index dffc88acfd90444bdb8446f7b4b0ae4e1db5dc7f..ef32ad8d7560beb384c93662a7dadff679557237 100755 (executable)
@@ -28,7 +28,7 @@ depends() {
 
 # Install kernel module(s).
 installkernel() {
-    instmods dm-integrity
+    hostonly='' instmods dm-integrity
 }
 
 # Install the required file(s) and directories for the module in the initramfs.
index ccbc11f74a8854c3a64bd1e0c84089acf3479a62..5f12348fddd0c3aa6fe65c1944434552afdbc3fe 100755 (executable)
@@ -28,7 +28,7 @@ depends() {
 
 # Install kernel module(s).
 installkernel() {
-    instmods loop squashfs
+    hostonly=$(optional_hostonly) instmods loop squashfs
 }
 
 # Install the required file(s) and directories for the module in the initramfs.
index 5de5db4b65a305b0ecbc9600749d589feb40f9ef..6cfea8ab32032686feef91559f26b59a5c84dd96 100755 (executable)
@@ -25,7 +25,7 @@ depends() {
 
 # Install kernel module(s).
 installkernel() {
-    instmods efi-pstore
+    hostonly='' instmods efi-pstore
 }
 
 # Install the required file(s) and directories for the module in the initramfs.
index 9dad8d4f6259e3174cdc7c4a9e85ffa86c200be6..664aa0cc8f15dee1d34a4c863f62256dbdbd5110 100755 (executable)
@@ -28,7 +28,7 @@ depends() {
 
 # Install kernel module(s).
 installkernel() {
-    instmods dm-verity
+    hostonly='' instmods dm-verity
 }
 
 # Install the required file(s) and directories for the module in the initramfs.
index 108d969f76f258e2161f3d4dcf88a59bd3d7dc40..4dd47a03eb4ca96f15f5bf6284c04168d4b110ae 100755 (executable)
@@ -13,7 +13,7 @@ installkernel() {
         ! [ -e "$_wd" ] && continue
         _wdtdrv=$(get_dev_module "$_wd")
         if [[ $_wdtdrv ]]; then
-            instmods "$_wdtdrv"
+            hostonly=$(optional_hostonly) instmods "$_wdtdrv"
             for i in $_wdtdrv; do
                 _drivers[$i]=1
             done
index 1bc93935cace810d507feb3eb1b635ab75706bb2..f46dee331b88338a7ea826da23b847341ddd11e4 100755 (executable)
@@ -16,7 +16,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods nf_tables nfnetlink nft_fwd_netdev
+    hostonly=$(optional_hostonly) instmods nf_tables nfnetlink nft_fwd_netdev
 }
 
 # called by dracut
index 8e52f1113c4601350e410e68bd3ac0515658bdee..6bb4f8a890fa60f1fdaf2989012bc5c057e3014e 100755 (executable)
@@ -11,14 +11,14 @@ installkernel() {
 
     if [[ ${DRACUT_ARCH:-$(uname -m)} == arm* || ${DRACUT_ARCH:-$(uname -m)} == aarch64 ]]; then
         # arm/aarch64 specific modules needed by drm
-        instmods \
+        hostonly=$(optional_hostonly) instmods \
             "=drivers/gpu/drm/i2c" \
             "=drivers/gpu/drm/panel" \
             "=drivers/gpu/drm/bridge" \
             "=drivers/video/backlight"
     fi
 
-    instmods amdkfd hyperv_fb "=drivers/pwm"
+    hostonly=$(optional_hostonly) instmods amdkfd hyperv_fb "=drivers/pwm"
 
     # if the hardware is present, include module even if it is not currently loaded,
     # as we could e.g. be in the installer; nokmsboot boot parameter will disable
@@ -47,7 +47,7 @@ installkernel() {
             [[ -L $i ]] || continue
             modlink=$(readlink "$i")
             modname=$(basename "$modlink")
-            instmods "$modname"
+            hostonly=$(optional_hostonly) instmods "$modname"
         done
     else
         dracut_instmods -o -s "drm_crtc_init|drm_dev_register|drm_encoder_init" "=drivers/gpu/drm" "=drivers/staging"
index aa5fcd33e33e77b49ce2b2568d840f001daf048d..8ea917e49bca73efe13a60cf1d17e476a2ab7672 100755 (executable)
@@ -8,9 +8,9 @@ check() {
 # called by dracut
 installkernel() {
     # Include simple DRM driver
-    instmods simpledrm
+    hostonly='' instmods simpledrm
 
-    if [[ $hostonly ]]; then
+    if [[ $hostonly_mode == "strict" ]]; then
         # if there is a privacy screen then its driver must be loaded before the
         # kms driver will bind, otherwise its probe() will return -EPROBE_DEFER
         # note privacy screens always register, even with e.g. nokmsboot
@@ -18,7 +18,7 @@ installkernel() {
             [[ -L $i ]] || continue
             modlink=$(readlink "$i")
             modname=$(basename "$modlink")
-            instmods "$modname"
+            hostonly='' instmods "$modname"
         done
     else
         # include privacy screen providers (see above comment)
index 7d26990a3ac277a550500f87dc160a4a545cc730..f6d5612e3fb99bb8514aa4aeb2fc3819b6927bcc 100755 (executable)
@@ -29,7 +29,7 @@ depends() {
 }
 
 installkernel() {
-    instmods bluetooth btrtl btintel btbcm bnep ath3k btusb rfcomm hidp
+    hostonly=$(optional_hostonly) instmods bluetooth btrtl btintel btbcm bnep ath3k btusb rfcomm hidp
     inst_multiple -o \
         /lib/firmware/ar3k/AthrBT* \
         /lib/firmware/ar3k/ramps* \
index d0b84f22b4ef49d5a41e5b1af5a6609fd47aea74..c016d9e8aedee65707f72695e3a4360414bc0add 100755 (executable)
@@ -31,7 +31,7 @@ cmdline() {
 
 # called by dracut
 installkernel() {
-    instmods btrfs
+    hostonly='' instmods btrfs
     printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf"
 }
 
index aac7a209f773d54fd4faddc8eb12a96ef7a9b0b2..d93ae4ca197d74f11520c83653654a685ee60451 100755 (executable)
@@ -51,7 +51,7 @@ installkernel() {
             fi
         done
     else
-        instmods "=crypto"
+        hostonly='' instmods "=crypto"
     fi
     return 0
 }
index b96fb0dee0a7158d4461a64850667c7ef68613e7..6a2dcb29e2e8061ae5bbac87b0bfd82ebd287e2c 100755 (executable)
@@ -8,7 +8,7 @@ check() {
 
 # called by dracut
 installkernel() {
-    instmods '=drivers/md' dm_mod dm-cache dm-cache-mq dm-cache-cleaner
+    hostonly=$(optional_hostonly) instmods '=drivers/md' dm_mod dm-cache dm-cache-mq dm-cache-cleaner
 }
 
 # called by dracut
index a97ca5a19f77619ec36cb88943d5ee11a201ff06..7a2e9943dd4274880edfb5538b48c716c247dced 100755 (executable)
@@ -12,7 +12,7 @@ depends() {
 }
 
 installkernel() {
-    instmods btrfs ext4 xfs
+    hostonly='' instmods btrfs ext4 xfs
 }
 
 install() {
index 99d21143b9fd7e7439979130b2d7c7576358bb37..103f0c7d76ca28099caf8ba8f02ebbca5f0de788 100755 (executable)
@@ -17,7 +17,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods squashfs loop iso9660 erofs
+    hostonly='' instmods squashfs loop iso9660 erofs
 }
 
 # called by dracut
index 72fbc41f6853d50dd3bcddb1f7e278c8ae0ee34b..840c4fd8a747bc8402f27b56404d710271768f41 100755 (executable)
@@ -25,7 +25,7 @@ installkernel() {
     }
 
     install_block_modules() {
-        instmods \
+        hostonly=$(optional_hostonly) instmods \
             scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
             =drivers/usb/storage \
             =ide nvme vmd \
@@ -58,7 +58,7 @@ installkernel() {
             "=drivers/usb/typec" \
             "=drivers/watchdog"
 
-        instmods \
+        hostonly=$(optional_hostonly) instmods \
             yenta_socket intel_lpss_pci spi_pxa2xx_platform \
             atkbd i8042 firewire-ohci hv-vmbus \
             virtio virtio_ring virtio_pci pci_hyperv \
@@ -67,7 +67,7 @@ installkernel() {
         if [[ ${DRACUT_ARCH:-$(uname -m)} == arm* || ${DRACUT_ARCH:-$(uname -m)} == aarch64 || ${DRACUT_ARCH:-$(uname -m)} == riscv* ]]; then
             # arm/aarch64 specific modules
             _blockfuncs+='|dw_mc_probe|dw_mci_pltfm_register|nvme_init_ctrl'
-            instmods \
+            hostonly=$(optional_hostonly) instmods \
                 "=drivers/clk" \
                 "=drivers/devfreq" \
                 "=drivers/dma" \
@@ -138,7 +138,7 @@ installkernel() {
         [[ $arch == s390x ]] && arch=s390
         [[ $arch == aarch64 ]] && arch=arm64
         hostonly='' instmods "=crypto"
-        instmods "=arch/$arch/crypto" "=drivers/crypto"
+        hostonly=$(optional_hostonly) instmods "=arch/$arch/crypto" "=drivers/crypto"
     fi
 
     inst_multiple -o "$depmodd/*.conf"
index 04d001bfa67f574644f07daa7f42c26d969c3495..e3761c95f72689c21375d6dbc92021e612494dfa 100755 (executable)
@@ -31,7 +31,7 @@ installkernel() {
 
     dracut_instmods -o -P ".*${_unwanted_drivers}.*" -s "$_net_symbols" "=drivers/net"
     #instmods() will take care of hostonly
-    instmods \
+    hostonly=$(optional_hostonly) instmods \
         '=drivers/net/mdio' \
         '=drivers/net/phy' \
         '=drivers/net/team' \
index 7d196b31df6e096daf91581a5088d0fc74da5abf..0e1032c9f33cb1d0a8e7e02b9a369a4422407700 100755 (executable)
@@ -34,7 +34,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods '=drivers/md'
+    hostonly=$(optional_hostonly) instmods '=drivers/md'
 }
 
 # called by dracut
index 7191a1196f64660d9906f2e8b1ec511cb22e6de2..747e4f1fa4052269ed89de7a2e51595d756a6f39 100755 (executable)
@@ -13,7 +13,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods pcmcia \
+    hostonly=$(optional_hostonly) instmods pcmcia \
         "=drivers/pcmcia"
 }
 
index bd6e4c13955c817e55fc1dea43fe8ea6d1176b10..e9afa7ee42313a4a43a662354dae29a46d34ff58 100755 (executable)
@@ -33,16 +33,16 @@ installkernel() {
 
     # only PowerMac3,6 has a module, special case
     if [[ ${DRACUT_ARCH:-$(uname -m)} != ppc64* ]]; then
-        if ! [[ $hostonly ]] || [[ "$(pmac_model)" == "PowerMac3,6" ]]; then
-            instmods therm_windtunnel
+        if [[ $hostonly_mode != "strict" ]] || [[ $hostonly && "$(pmac_model)" == "PowerMac3,6" ]]; then
+            hostonly=$(optional_hostonly) instmods therm_windtunnel
         fi
         return 0
     fi
 
     windfarm_modules() {
-        if ! [[ $hostonly ]]; then
-            # include all drivers when not hostonly
-            instmods \
+        if [[ $hostonly_mode != "strict" ]]; then
+            # include all drivers when not hostonly or sloppy hostonly
+            hostonly='' instmods \
                 windfarm_pm72 windfarm_pm81 windfarm_pm91 windfarm_pm112 \
                 windfarm_pm121 windfarm_rm31
         else
index 4441f55283ec3e99d7470f97671240382406fdc3..4687fc90feeb677643c98df98f1dcf63fdea7b05 100755 (executable)
@@ -25,7 +25,7 @@ depends() {
 
 # Install kernel module(s).
 installkernel() {
-    instmods '=drivers/char/tpm'
+    hostonly=$(optional_hostonly) instmods '=drivers/char/tpm'
 }
 
 # Install the required file(s) and directories for the module in the initramfs.
index 34f91b95d28994544259a6a4b0bf253522fba9f1..6c5eb6241613c95b190906a4e2fa998ffa925484 100755 (executable)
@@ -23,13 +23,13 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods cifs ipv6
+    hostonly=$(optional_hostonly) instmods cifs ipv6
     # hash algos
-    instmods md4 md5 sha256 sha512
+    hostonly=$(optional_hostonly) instmods md4 md5 sha256 sha512
     # ciphers
-    instmods aes arc4 des ecb gcm aead2
+    hostonly=$(optional_hostonly) instmods aes arc4 des ecb gcm aead2
     # macs
-    instmods hmac cmac ccm
+    hostonly=$(optional_hostonly) instmods hmac cmac ccm
 }
 
 # called by dracut
index 75b36d566c326b0f521d35e5c5eb2380833645fb..144b71bf6695c9143cc6a7abf719c79c13b385df 100755 (executable)
@@ -23,7 +23,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods fcoe libfcoe 8021q edd bnx2fc
+    hostonly=$(optional_hostonly) instmods fcoe libfcoe 8021q edd bnx2fc
 }
 
 get_vlan_parent() {
index 2dd9644f48360680d5a700796b9802cf045d31f8..746171476cde5ba863e4427251a82127b04e219c 100755 (executable)
@@ -162,7 +162,7 @@ installkernel() {
     local _arch=${DRACUT_ARCH:-$(uname -m)}
     local _funcs='iscsi_register_transport'
 
-    instmods bnx2i qla4xxx cxgb3i cxgb4i be2iscsi qedi
+    hostonly=$(optional_hostonly) instmods bnx2i qla4xxx cxgb3i cxgb4i be2iscsi qedi
     hostonly="" instmods iscsi_tcp iscsi_ibft crc32c iscsi_boot_sysfs 8021q
 
     if [ "$_arch" = "s390" ] || [ "$_arch" = "s390x" ]; then
index 8783c2b11ca6fb7232228f90972ed9d24cd73808..bf2f0e06465472b908cc2b384bf3fde9292c6658 100755 (executable)
@@ -24,7 +24,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods nbd
+    hostonly='' instmods nbd
 }
 
 # called by dracut
index b9888a56e6d59cd4d45934e4381dc85a9d3287b3..00b181e789b483d4ec1144e7ade441bf7d90cbaf 100755 (executable)
@@ -69,7 +69,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods nvme_fc nvme_tcp nvme_rdma lpfc qla2xxx
+    hostonly=$(optional_hostonly) instmods nvme_fc nvme_tcp nvme_rdma lpfc qla2xxx
     # 802.1q VLAN may be set up in Firmware later. Include the module always.
     hostonly="" instmods 8021q
 }
index aaa270b14f3cc8e3424bb08046bde7d9134d495d..47a317f0b9bb06dc823204081d31e9a17db62a16 100755 (executable)
@@ -16,7 +16,7 @@ check() {
 
 # called by dracut
 installkernel() {
-    instmods 9p 9pnet_virtio virtio_pci
+    hostonly=$(optional_hostonly) instmods 9p 9pnet_virtio virtio_pci
 }
 
 # called by dracut
index 25283979c1041e9d7b07f56cb94fcc146c8875da..238e52bc1f9c93905bbad1e8f7ee7f8ad01d9cfa 100755 (executable)
@@ -21,7 +21,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods virtiofs virtio_pci
+    hostonly='' instmods virtiofs virtio_pci
 }
 
 # called by dracut
index b28476674990761c4b831520ccf16bb42bdc57d2..1b6afb154cda55476fea916ed95ec3be87e0ee3c 100755 (executable)
@@ -11,7 +11,7 @@ check() {
 
 # called by dracut
 installkernel() {
-    instmods trusted encrypted
+    hostonly=$(optional_hostonly) instmods trusted encrypted
 }
 
 # called by dracut
index 9328b51433ae9d10b25c7f9b18df27ca797bbffa..a6f5b901298ae036db12b02bedfa91a23bb75f7c 100755 (executable)
@@ -13,7 +13,7 @@ depends() {
 
 # called by dracut
 installkernel() {
-    instmods ecryptfs
+    hostonly='' instmods ecryptfs
 }
 
 # called by dracut
index 5db9fd0d88ab627f8488281ec30fbb8cd73f1afd..5308bd456643ce9a15a321dc535ec5558d54247f 100755 (executable)
@@ -40,7 +40,7 @@ installkernel() {
         for_each_host_dev_fs include_fs_helper_modules
         :
     else
-        instmods crc32c crc32
+        hostonly='' instmods crc32c crc32
     fi
 }