kernel-modules/module-setup.sh: silently omit some filesystem drivers
[dracut.git] / modules.d / 90kernel-modules / module-setup.sh
blob0e7a9a12727a6f91e0dd177df441e2e9b044a643
1 #!/bin/bash
2 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3 # ex: ts=8 sw=4 sts=4 et filetype=sh
5 installkernel() {
6 if [[ -z $drivers ]]; then
7 block_module_filter() {
8 local _blockfuncs='ahci_init_controller|ata_scsi_ioctl|scsi_add_host|blk_init_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect'
9 # subfunctions inherit following FDs
10 local _merge=8 _side2=9
11 function bmf1() {
12 local _f
13 while read _f; do case "$_f" in
14 *.ko) [[ $(< $_f) =~ $_blockfuncs ]] && echo "$_f" ;;
15 *.ko.gz) [[ $(gzip -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
16 *.ko.xz) [[ $(xz -dc <$_f) =~ $_blockfuncs ]] && echo "$_f" ;;
17 esac
18 done
19 return 0
21 function rotor() {
22 local _f1 _f2
23 while read _f1; do
24 echo "$_f1"
25 if read _f2; then
26 echo "$_f2" 1>&${_side2}
28 done | bmf1 1>&${_merge}
29 return 0
31 # Use two parallel streams to filter alternating modules.
32 set +x
33 eval "( ( rotor ) ${_side2}>&1 | bmf1 ) ${_merge}>&1"
34 [[ $debug ]] && set -x
35 return 0
38 hostonly='' instmods sr_mod sd_mod scsi_dh ata_piix \
39 ehci-hcd ehci-pci ehci-platform ohci-hcd uhci-hcd xhci-hcd hid_generic \
40 unix
42 instmods yenta_socket scsi_dh_rdac scsi_dh_emc \
43 atkbd i8042 usbhid hid-apple hid-sunplus hid-cherry hid-logitech \
44 hid-logitech-dj hid-microsoft firewire-ohci \
45 pcmcia usb_storage nvme hid-hyperv hv-vmbus
47 if [[ "$(uname -p)" == arm* ]]; then
48 # arm specific modules
49 hostonly='' instmods sdhci_esdhc_imx mmci sdhci_tegra mvsdio omap omapdrm \
50 omap_hsmmc panel-tfp410 sdhci_dove ahci_platform pata_imx sata_mv \
51 ehci-tegra
54 # install virtual machine support
55 instmods virtio virtio_blk virtio_ring virtio_pci virtio_scsi \
56 "=drivers/pcmcia" =ide "=drivers/usb/storage"
58 find_kernel_modules | block_module_filter | instmods
60 # if not on hostonly mode, install all known filesystems,
61 # if the required list is not set via the filesystems variable
62 if ! [[ $hostonly ]]; then
63 if [[ -z $filesystems ]]; then
64 silent_omit_drivers="kernel/fs/nfs|kernel/fs/nfsd|kernel/fs/lockd" \
65 instmods '=fs'
67 else
68 for i in $(host_fs_all); do
69 hostonly='' instmods $i
70 done
76 install() {
77 dracut_install -o /lib/modprobe.d/*.conf
78 [[ $hostonly ]] && dracut_install -o /etc/modprobe.d/*.conf /etc/modprobe.conf
79 if ! dracut_module_included "systemd"; then
80 inst_hook cmdline 01 "$moddir/parse-kernel.sh"
82 inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh