Skip to content

Commit f47a1c6

Browse files
committed
runtime: Add boot option to blacklist some kernel modules
Signed-off-by: Alexey Gladkov <[email protected]>
1 parent 4d7cff1 commit f47a1c6

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

Documentation/BootParameters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ The following parameters can be passed via kernel command line.
1313
- `debug` shows more messages.
1414
- `quiet` tries to be more quiet.
1515
- `rd-preload-modules` enables/disables loading a static list of modules before udev service.
16+
- `rd.driver.blacklist=<comma-separated list>` specifies the list of kernel
17+
module names that should be added to blacklist before loading any kernel modules.
1618

1719
Parameters responsible for mounting the root file system:
1820

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ register_parameter string ROOT
2222
register_parameter string ROOTFLAGS
2323
register_parameter string ROOTFSTYPE
2424
register_parameter string STOP
25+
register_array string RD_DRIVER_BLACKLIST

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,22 @@
1818
[ -z "${RD_DEPMOD-}" ] ||
1919
depmod -a
2020

21+
if [ "${RD_DRIVER_BLACKLIST:-0}" != 0 ]; then
22+
i=0
23+
while [ $i -lt ${RD_DRIVER_BLACKLIST:-0} ]; do
24+
eval "MODS=\"\$RD_DRIVER_BLACKLIST$i\""
25+
26+
modnames=()
27+
readarray -t -d, modnames <<<"$MODS,"
28+
29+
for modname in "${modnames[@]}"; do
30+
[ -n "$modname" ] && [ "$modname" != $'\n' ] ||
31+
continue
32+
printf 'blacklist %s\n' "$modname"
33+
done >> /etc/modprobe.d/initramfs-blacklist.conf
34+
done
35+
fi
36+
2137
[ -n "${RD_PRELOAD_MODULES-}" ] ||
2238
exit 0
2339

0 commit comments

Comments
 (0)