Stop the kernel from auto-loading modules you never asked for
By Saket Jain Published Linux/Unix
Stop the kernel from auto-loading modules you never asked for
Technical Briefing | 11/28/2026
We have all been there. You run lsmod and see a mountain of modules loaded that have zero relevance to your actual workload. Maybe it is a legacy filesystem driver or an obscure network protocol module that someone thought would be useful five years ago. These things bloat your kernel memory and, more importantly, create an unnecessary attack surface that you did not explicitly opt into.
Why kmod keeps forcing your hand
The culprit is almost always kmod and the udev subsystem working in tandem. When you plug in hardware or even just initialize certain network stacks, the kernel triggers an event. Udev sees that event, checks the alias map, and tells the kernel to pull in a driver. It is a nice feature for desktop users, but on a hardened production server, it is a liability. I have seen systems pull in firewire modules on headless cloud instances just because the bus scan touched the wrong device node.
echo install firewire-core /bin/true > /etc/modprobe.d/block-firewire.conf
- Using install with /bin/true tells modprobe to do absolutely nothing when a request for that module arrives.
- The modprobe utility reads these config files in /etc/modprobe.d/ alphabetically, so name your files carefully.
- This method is persistent and survives kernel upgrades because it hooks directly into the loader logic.
When to reach for the blacklist instead
People often confuse blacklisting with the install override. A blacklist entry just prevents modprobe from loading a module automatically. However, if another module specifically requests the blacklisted one as a dependency, the kernel will load it anyway. That is why the /bin/true override is the only way to actually kill the request. If you find your module still showing up after a reboot, you are dealing with a hard dependency, not an auto-load event.
Take twenty minutes to audit your lsmod output against your actual hardware needs. If you find drivers for hardware you do not have or filesystems you are not mounting, neuter them now. It is a small change that makes your kernel footprint significantly tighter and keeps the logs a little quieter during boot.
