Skip to content

Commit 3b8828e

Browse files
committed
runtime: Add boot option to preload kernel modules
Signed-off-by: Alexey Gladkov <[email protected]>
1 parent f47a1c6 commit 3b8828e

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

Documentation/BootParameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ The following parameters can be passed via kernel command line.
1515
- `rd-preload-modules` enables/disables loading a static list of modules before udev service.
1616
- `rd.driver.blacklist=<comma-separated list>` specifies the list of kernel
1717
module names that should be added to blacklist before loading any kernel modules.
18+
- `rd.driver.pre=<comma-separated list>` specifies the list of kernel module
19+
names that should be preloaded.
1820

1921
Parameters responsible for mounting the root file system:
2022

features/runtime/data/etc/initrd/cmdline.d/base

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ register_parameter string ROOTFLAGS
2323
register_parameter string ROOTFSTYPE
2424
register_parameter string STOP
2525
register_array string RD_DRIVER_BLACKLIST
26+
register_array string RD_DRIVER_PRE

features/runtime/data/etc/rc.d/init.d/modules

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,25 @@ fi
4242
preload_modules()
4343
{
4444
local check conf modname rc=0
45+
46+
if [ "${RD_DRIVER_PRE:-0}" != 0 ]; then
47+
local i modnames MODS
48+
49+
i=0
50+
while [ $i -lt ${RD_DRIVER_PRE:-0} ]; do
51+
eval "MODS=\"\$RD_DRIVER_PRE$i\""
52+
53+
modnames=()
54+
readarray -t -d, modnames <<<"$MODS,"
55+
56+
for modname in "${modnames[@]}"; do
57+
[ -n "$modname" ] && [ "$modname" != $'\n' ] ||
58+
continue
59+
modprobe "$modname" || rc=1
60+
done
61+
done
62+
fi 2>"/var/log/preload-modules.log"
63+
4564
for conf in /etc/modules-load.d/*.conf /run/modules-load.d/*.conf /lib/modules-load.d/*.conf /etc/initrd/modules-preudev; do
4665
# shellcheck disable=SC2162
4766
[ ! -e "$conf" ] ||
@@ -53,7 +72,7 @@ preload_modules()
5372
continue
5473
modprobe "$modname" $args || rc=1
5574
done < "$conf"
56-
done 2>"/var/log/preload-modules.log"
75+
done 2>>"/var/log/preload-modules.log"
5776
return $rc
5877
}
5978

0 commit comments

Comments
 (0)