94 lines
3.4 KiB
Diff
94 lines
3.4 KiB
Diff
|
From 90d96c4f6a44d895f8999da8c4721a04612e6379 Mon Sep 17 00:00:00 2001
|
||
|
From: Kairui Song <kasong@redhat.com>
|
||
|
Date: Tue, 29 Oct 2019 16:29:14 +0800
|
||
|
Subject: [PATCH] 90kernel-modules: don't install any block driver if not
|
||
|
needed
|
||
|
|
||
|
If hostonly mode is in use, and there isn't any block device included
|
||
|
as hostonly device, then the initramfs won't need any block driver.
|
||
|
|
||
|
Eg. for kdump built image, there could be only one nfs mount point,
|
||
|
or the initramfs may only execute some network operation then reboot.
|
||
|
|
||
|
In such case, skip block driver installation to save space and time.
|
||
|
|
||
|
Signed-off-by: Kairui Song <kasong@redhat.com>
|
||
|
(cherry picked from commit f4ad2e5c8964b6c7b50420299a0096bade6a40bd)
|
||
|
|
||
|
Resolves: #1776659
|
||
|
---
|
||
|
modules.d/90kernel-modules/module-setup.sh | 32 +++++++++++++++++++++++-------
|
||
|
1 file changed, 25 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
|
||
|
index 3dfceff0..c91ba10c 100755
|
||
|
--- a/modules.d/90kernel-modules/module-setup.sh
|
||
|
+++ b/modules.d/90kernel-modules/module-setup.sh
|
||
|
@@ -2,6 +2,8 @@
|
||
|
|
||
|
# called by dracut
|
||
|
installkernel() {
|
||
|
+ 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'
|
||
|
+
|
||
|
find_kernel_modules_external () {
|
||
|
local _OLDIFS
|
||
|
local external_pattern="^/"
|
||
|
@@ -16,11 +18,25 @@ installkernel() {
|
||
|
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'
|
||
|
+
|
||
|
+ is_block_dev() {
|
||
|
+ [ -e /sys/dev/block/$1 ] && return 0
|
||
|
+ return 1
|
||
|
+ }
|
||
|
+
|
||
|
+ install_block_modules () {
|
||
|
+ hostonly='' instmods sr_mod sd_mod scsi_dh ata_piix
|
||
|
+ instmods \
|
||
|
+ scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
|
||
|
+ =ide nvme vmd nfit \
|
||
|
+ virtio_blk
|
||
|
+
|
||
|
+ dracut_instmods -o -s "${_blockfuncs}" "=drivers"
|
||
|
+ }
|
||
|
|
||
|
if [[ -z $drivers ]]; then
|
||
|
hostonly='' instmods \
|
||
|
- sr_mod sd_mod scsi_dh ata_piix hid_generic unix \
|
||
|
+ hid_generic unix \
|
||
|
ehci-hcd ehci-pci ehci-platform \
|
||
|
ohci-hcd ohci-pci \
|
||
|
uhci-hcd \
|
||
|
@@ -38,10 +54,10 @@ installkernel() {
|
||
|
${NULL}
|
||
|
|
||
|
instmods \
|
||
|
- yenta_socket scsi_dh_rdac scsi_dh_emc scsi_dh_alua \
|
||
|
+ yenta_socket \
|
||
|
atkbd i8042 usbhid firewire-ohci pcmcia hv-vmbus \
|
||
|
- virtio virtio_blk virtio_ring virtio_pci virtio_scsi \
|
||
|
- "=drivers/pcmcia" =ide nvme vmd nfit
|
||
|
+ virtio virtio_ring virtio_pci virtio_scsi \
|
||
|
+ "=drivers/pcmcia"
|
||
|
|
||
|
if [[ "$(uname -m)" == arm* || "$(uname -m)" == aarch64 ]]; then
|
||
|
# arm/aarch64 specific modules
|
||
|
@@ -72,10 +88,12 @@ installkernel() {
|
||
|
${NULL}
|
||
|
fi
|
||
|
|
||
|
- dracut_instmods -o -s "${_blockfuncs}" "=drivers"
|
||
|
-
|
||
|
find_kernel_modules_external | instmods
|
||
|
|
||
|
+ if ! [[ $hostonly ]] || for_each_host_dev_and_slaves is_block_dev; then
|
||
|
+ install_block_modules
|
||
|
+ fi
|
||
|
+
|
||
|
# if not on hostonly mode, install all known filesystems,
|
||
|
# if the required list is not set via the filesystems variable
|
||
|
if ! [[ $hostonly ]]; then
|
||
|
|