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.
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).
installkernel() {
hostonly='' instmods autofs4 ipv6 dmi-sysfs
- instmods -s efivarfs
+ hostonly=$(optional_hostonly) instmods -s efivarfs
}
# called by dracut
# 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.
# 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.
# 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.
# 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.
! [ -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
# called by dracut
installkernel() {
- instmods nf_tables nfnetlink nft_fwd_netdev
+ hostonly=$(optional_hostonly) instmods nf_tables nfnetlink nft_fwd_netdev
}
# called by dracut
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
[[ -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"
# 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
[[ -L $i ]] || continue
modlink=$(readlink "$i")
modname=$(basename "$modlink")
- instmods "$modname"
+ hostonly='' instmods "$modname"
done
else
# include privacy screen providers (see above comment)
}
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* \
# called by dracut
installkernel() {
- instmods btrfs
+ hostonly='' instmods btrfs
printf "%s\n" "$(cmdline)" > "${initdir}/etc/cmdline.d/00-btrfs.conf"
}
fi
done
else
- instmods "=crypto"
+ hostonly='' instmods "=crypto"
fi
return 0
}
# 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
}
installkernel() {
- instmods btrfs ext4 xfs
+ hostonly='' instmods btrfs ext4 xfs
}
install() {
# called by dracut
installkernel() {
- instmods squashfs loop iso9660 erofs
+ hostonly='' instmods squashfs loop iso9660 erofs
}
# called by dracut
}
install_block_modules() {
- instmods \
+ hostonly=$(optional_hostonly) instmods \
scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
=drivers/usb/storage \
=ide nvme vmd \
"=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 \
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" \
[[ $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"
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' \
# called by dracut
installkernel() {
- instmods '=drivers/md'
+ hostonly=$(optional_hostonly) instmods '=drivers/md'
}
# called by dracut
# called by dracut
installkernel() {
- instmods pcmcia \
+ hostonly=$(optional_hostonly) instmods pcmcia \
"=drivers/pcmcia"
}
# 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
# 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.
# 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
# called by dracut
installkernel() {
- instmods fcoe libfcoe 8021q edd bnx2fc
+ hostonly=$(optional_hostonly) instmods fcoe libfcoe 8021q edd bnx2fc
}
get_vlan_parent() {
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
# called by dracut
installkernel() {
- instmods nbd
+ hostonly='' instmods nbd
}
# called by dracut
# 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
}
# called by dracut
installkernel() {
- instmods 9p 9pnet_virtio virtio_pci
+ hostonly=$(optional_hostonly) instmods 9p 9pnet_virtio virtio_pci
}
# called by dracut
# called by dracut
installkernel() {
- instmods virtiofs virtio_pci
+ hostonly='' instmods virtiofs virtio_pci
}
# called by dracut
# called by dracut
installkernel() {
- instmods trusted encrypted
+ hostonly=$(optional_hostonly) instmods trusted encrypted
}
# called by dracut
# called by dracut
installkernel() {
- instmods ecryptfs
+ hostonly='' instmods ecryptfs
}
# called by dracut
for_each_host_dev_fs include_fs_helper_modules
:
else
- instmods crc32c crc32
+ hostonly='' instmods crc32c crc32
fi
}