How to get a list of active drivers that are statically built into the linux kernel?

While I can use lsmod in order to show currently active kernel modules, how can I see which drivers are statically built into the kernel AND currently active?


You could do a cat /lib/modules/$(uname -r)/modules.builtin

From the Kernel Documentaton

modules.builtin

This file lists all modules that are built into the kernel. This is used by modprobe to not fail when trying to load something builtin.


If your linux has a /proc/config.gz

That has all the built modules. Copy it elsewhere and unzip it. Open the file everything with a "=M" is built as a module. Everything with a "=Y" is statically built.

hwinfo will list the "Driver:" check the above file to see if it is statically built.

FYI: All statically built drivers are always loaded into memory and ready for action. Without the corresponding hardware they will not do anything, but use memory.


The sysfs module area /sys/module is a view into all the modules visible to the running kernel. Each module directory has a set of sysfs interface files to view and manage the module via userspace. Generally speaking, the LKMs have a refcnt file, which will be greater than 0 if it is being used along with a holder directory of those modules using it. The builtin modules do not have this file (or many others like initstate and taint.)

Try find /sys/module -name refcnt -printf '\n%p: ' -exec cat {} \; to see which are being used.

Under many modules is a parameters directory containing the parameters that can be viewed and modified from user-space. In the source this is generally a call to a module_param macro. For example, see kernel/printk.c and the module /sys/module/printk/parameters for some useful printk tuning.

All entities under /sys/module are set in the kernel module framework. Some are hardware drivers, some are netfilter, some are filesystems, some debug, etc.


ls /sys/module

seems to contain all built-in and external modules.

But it also appears to contain some entries which are not actually modules: https://unix.stackexchange.com/questions/225706/are-modules-listed-under-sys-module-all-the-loaded-modules

TODO: read the source and understand more precisely what gets put there.

The advantage of this method is that you don't rely on being able to find the kernel config under /boot or /proc/config.gz.