]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix: improve hostonly sloppy mode
authorJo Zzsi <jozzsicsataban@gmail.com>
Tue, 22 Apr 2025 22:04:18 +0000 (18:04 -0400)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 23 Apr 2025 11:40:17 +0000 (07:40 -0400)
Sloppy mode is the original hostonly mode.

Strict mode was newly introduced much later in 2018 (v048) as a non-default
opt-in special optimization mode to allow modules to ignore more drivers
or do some extra job to save memory and disk space, while making the image less portable.

This PR includes more dracut modules (and with that more kernel modules) in sloppy mode.

20 files changed:
modules.d/01systemd-cryptsetup/module-setup.sh
modules.d/90btrfs/module-setup.sh
modules.d/90crypt/module-setup.sh
modules.d/90dmraid/module-setup.sh
modules.d/90kernel-modules/module-setup.sh
modules.d/90lvm/module-setup.sh
modules.d/90mdraid/module-setup.sh
modules.d/90multipath/module-setup.sh
modules.d/90qemu-net/module-setup.sh
modules.d/90qemu/module-setup.sh
modules.d/95cifs/module-setup.sh
modules.d/95fcoe-uefi/module-setup.sh
modules.d/95fcoe/module-setup.sh
modules.d/95iscsi/module-setup.sh
modules.d/95lunmask/module-setup.sh
modules.d/95nbd/module-setup.sh
modules.d/95nfs/module-setup.sh
modules.d/95nvmf/module-setup.sh
modules.d/95virtiofs/module-setup.sh
modules.d/99fs-lib/module-setup.sh

index dd8618a24e870df0c082e691f563439631afa276..c7298831a6ad34f9970b42e74a6c8bef85b51794 100755 (executable)
@@ -6,7 +6,7 @@ check() {
     # if cryptsetup is not installed, then we cannot support encrypted devices.
     require_binaries "$systemdutildir"/systemd-cryptsetup || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
             [[ $fs == "crypto_LUKS" ]] && return 0
         done
index fbf3c1db58f452b19319becef485d61bffa705d4..d0b84f22b4ef49d5a41e5b1af5a6609fd47aea74 100755 (executable)
@@ -6,7 +6,7 @@ check() {
     # no point in trying to support it in the initramfs.
     require_binaries btrfs || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
             [[ $fs == "btrfs" ]] && return 0
         done
index 40018b979282bf8ecf3d689fd50f77aa4b7c314f..aac7a209f773d54fd4faddc8eb12a96ef7a9b0b2 100755 (executable)
@@ -6,7 +6,7 @@ check() {
     # if cryptsetup is not installed, then we cannot support encrypted devices.
     require_any_binary "$systemdutildir"/systemd-cryptsetup cryptsetup || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
             [[ $fs == "crypto_LUKS" ]] && return 0
         done
@@ -34,7 +34,7 @@ installkernel() {
     # in case some of the crypto modules moved from compiled in
     # to module based, try to install those modules
     # best guess
-    if [[ $hostonly ]] || [[ $mount_needs ]]; then
+    if [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]]; then
         # dmsetup returns s.th. like
         # cryptvol: 0 2064384 crypt aes-xts-plain64 :64:logon:cryptsetup:....
         dmsetup table | while read -r name _ _ is_crypt cipher _; do
index e7c6be60dbcdf9dba541620c4a3b12f875db2e0e..1d2ab77b572fbaae51db018eb27137b3a4079943 100755 (executable)
@@ -10,7 +10,7 @@ check() {
     require_binaries dmraid || return 1
     require_binaries kpartx || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for dev in "${!host_fs_types[@]}"; do
             [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue
 
index 1ac91d02bb632e0117a411e335000c66dcd181fb..72fbc41f6853d50dd3bcddb1f7e278c8ae0ee34b 100755 (executable)
@@ -120,9 +120,9 @@ installkernel() {
             fi
         fi
 
-        # if not on hostonly mode, install all known filesystems,
+        # if not on strict hostonly mode, install all known filesystems,
         # if the required list is not set via the filesystems variable
-        if ! [[ $hostonly ]]; then
+        if [[ $hostonly_mode != "strict" ]]; then
             if [[ -z $filesystems ]]; then
                 dracut_instmods -o -P ".*/(kernel/fs/nfs|kernel/fs/nfsd|kernel/fs/lockd)/.*" '=fs'
             fi
index 7ba4c69b30c56c960d4d52d697e314a835293434..27f255f059e91e2e7134961c614d96c3a1a36433 100755 (executable)
@@ -5,7 +5,7 @@ check() {
     # No point trying to support lvm if the binaries are missing
     require_binaries lvm grep || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
             [[ $fs == LVM*_member ]] && return 0
         done
index 0d0a57f6649b88bd612b77020bfd907cd5967b1e..7d196b31df6e096daf91581a5088d0fc74da5abf 100755 (executable)
@@ -7,7 +7,7 @@ check() {
     # No mdadm?  No mdraid support.
     require_binaries mdadm expr || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for dev in "${!host_fs_types[@]}"; do
             [[ ${host_fs_types[$dev]} != *_raid_member ]] && continue
 
index a16313c0a8e8439bcf0ca97f283b301408ac461a..0b05e5af0f49da491f5df080275fa37c3c48e483 100755 (executable)
@@ -25,7 +25,7 @@ check() {
     require_binaries multipath || return 1
     require_binaries kpartx || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for_each_host_dev_and_slaves is_mpath || return 255
     }
 
index bf64ad9ca5cabd43e10d15a247eb906c5d54cee0..a05f5428fcee390af7e720765b4d8314cc754886 100755 (executable)
@@ -4,7 +4,7 @@
 check() {
     is_qemu_virtualized && return 0
 
-    if [[ $hostonly ]] || [[ $mount_needs ]]; then
+    if [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]]; then
         return 255
     fi
 
index 06f4dcbbfafc6a91fefa4df6ec68a521892f61fa..fecaca6107b9bae431bb72476014cf282ec74a45 100755 (executable)
@@ -4,7 +4,7 @@
 check() {
     is_qemu_virtualized && return 0
 
-    if [[ $hostonly ]] || [[ $mount_needs ]]; then
+    if [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]]; then
         return 255
     fi
 
index 6abc4752e69a2af81a9ddf30f716def92ff6851b..34f91b95d28994544259a6a4b0bf253522fba9f1 100755 (executable)
@@ -5,7 +5,7 @@ check() {
     # If our prerequisites are not met, fail anyways.
     require_binaries mount.cifs || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
             [[ $fs == "cifs" ]] && return 0
         done
index 24acf998afddf08776f0c5a16d37c4392e38231d..5a9aa8342ffb28fcd2aac59233849558662a18ee 100755 (executable)
@@ -7,7 +7,7 @@ check() {
         block_is_fcoe "$1" || return 1
     }
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for_each_host_dev_and_slaves is_fcoe || return 255
         [ -d /sys/firmware/efi ] || return 255
     }
index ecebbda0127912d3bef4363bbde5d7bb3f5dbdfa..75b36d566c326b0f521d35e5c5eb2380833645fb 100755 (executable)
@@ -7,7 +7,7 @@ check() {
         block_is_fcoe "$1" || return 1
     }
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         for_each_host_dev_and_slaves is_fcoe || return 255
     }
 
index ba57dbbe63f151df5a0400214534f890ff3b78e1..2dd9644f48360680d5a700796b9802cf045d31f8 100755 (executable)
@@ -6,9 +6,9 @@ check() {
     require_binaries iscsi-iname iscsiadm iscsid || return 1
     require_kernel_modules iscsi_tcp || return 1
 
-    # If hostonly was requested, fail the check if we are not actually
+    # If hostonly strict was requested, fail the check if we are not actually
     # booting from root.
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         pushd . > /dev/null
         for_each_host_dev_and_slaves block_is_iscsi
         local _is_iscsi=$?
index 8ec61f60bdfa34a27fb099cff8dbc8b19d1e24b1..563891c9c9b34539583b775eae4786ffbc218651 100755 (executable)
@@ -45,7 +45,7 @@ cmdline() {
 
 # called by dracut
 check() {
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         [ -w /sys/module/scsi_mod/parameters/scan ] || return 255
         read -r scan_type < /sys/module/scsi_mod/parameters/scan
         [ "$scan_type" = "manual" ] && return 0
index aa3570a875b8221dd97bf033ad4d0cba56d62f1c..8783c2b11ca6fb7232228f90972ed9d24cd73808 100755 (executable)
@@ -6,7 +6,7 @@ check() {
 
     # if an nbd device is not somewhere in the chain of devices root is
     # mounted on, fail the hostonly check.
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         _rootdev=$(find_root_block_device)
         [[ -b /dev/block/$_rootdev ]] || return 1
         check_block_and_slaves block_is_nbd "$_rootdev" || return 255
index b34c75c009a75629ca26b95229302d4b289f6bf1..3ca2d69c6b023a4bbcd649e1a67716b246a57b36 100755 (executable)
@@ -23,7 +23,7 @@ check() {
     require_any_binary rpcbind portmap || return 1
     require_binaries rpc.statd mount.nfs mount.nfs4 umount sed chmod chown || return 1
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         [[ "$(get_nfs_type)" ]] && return 0
         return 255
     }
index c10c2f5c8d0047f8aa3fddb24489db3ad18dcb79..b9888a56e6d59cd4d45934e4381dc85a9d3287b3 100755 (executable)
@@ -42,7 +42,7 @@ check() {
         [[ $found ]]
     }
 
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         [ -f /etc/nvme/hostnqn ] || return 255
         [ -f /etc/nvme/hostid ] || return 255
         pushd . > /dev/null
index 176482b07e52da0d8fa455655aa26d450f40036b..25283979c1041e9d7b07f56cb94fcc146c8875da 100755 (executable)
@@ -2,7 +2,7 @@
 
 # called by dracut
 check() {
-    [[ $hostonly ]] || [[ $mount_needs ]] && {
+    [[ $hostonly_mode == "strict" ]] || [[ $mount_needs ]] && {
         is_qemu_virtualized && return 0
 
         for fs in "${host_fs_types[@]}"; do
index 0e611a21b27e49e1158a3b4bcbae38c602abb13f..5db9fd0d88ab627f8488281ec30fbb8cd73f1afd 100755 (executable)
@@ -36,7 +36,7 @@ include_fs_helper_modules() {
 # called by dracut
 installkernel() {
     # xfs/btrfs/ext4 need crc32c, f2fs needs crc32
-    if [[ $hostonly ]]; then
+    if [[ $hostonly_mode == "strict" ]]; then
         for_each_host_dev_fs include_fs_helper_modules
         :
     else
@@ -59,7 +59,7 @@ install() {
             xfs_db xfs_check xfs_repair xfs_metadump
             e2fsck jfs_fsck btrfsck
         )
-        if [[ $hostonly ]]; then
+        if [[ $hostonly_mode == "strict" ]]; then
             read -r -a _helpers < <(for_each_host_dev_fs echo_fs_helper)
         fi
     else