Saturday, November 7, 2015

How to find information about built-in kernel modules on Linux

http://ask.xmodulo.com/find-information-builtin-kernel-modules-linux.html

Question: I would like to know what modules are built into the kernel of my Linux system, and what parameters are available in each module. Is there a way to get a list of all built-in kernel modules and device drivers, and find detailed information about them?
The modern Linux kernel has been growing significantly over the years to support a wide variety of hardware devices, file systems and networking functions. During this time, "loadable kernel modules (LKM)" came into being in order to keep the kernel from getting bloated, while flexibly extending its capabilities and hardware support under different environments, without having to rebuild it.
The Linux kernel shipped with the latest Linux distributions comes with relatively a small number of "built-in modules", while the rest of hardware-specific drivers or custom capabilities exist as "loadable modules" which you can selectively load or unload.
The built-in modules are statically compiled into the kernel. Unlike loadable kernel modules which can be dynamically loaded, unloaded, looked up or listed using commands like modprobe, insmod, rmmod, modinfo or lsmod, built-in kernel modules are always loaded in the kernel upon boot-up, and cannot be managed with these commands.

Find a List of Built-in Kernel Modules

To get a list of all built-in modules, run the following command.
$ cat /lib/modules/$(uname -r)/modules.builtin

You can also get a hint on what modules are built-in by running:

Find Parameters of Built-in Kernel Modules

Each kernel module, whether it's built-in or loadable, comes with a set of parameters. For loadable kernel modules, the modinfo command will show parameter information about them. However, this command will not work with built-in modules. You will simply get the following error.
modinfo: ERROR: Module XXXXXX not found.
If you want to check what parameters are available in a given built-in module, and what their values are, you can instead examine the content in /sys/module directory.
Under /sys/module directory, you will find sub-directories named after existing kernel modules (both built-in and loadable). Then in each module directory, there is a directory named "parameters", which lists all available parameters for the module.
For example, let's say you want to find out parameters of a built-in module called tcp_cubic (the default TCP implementation of the kernel). Then you can do this:
$ ls /sys/module/tcp_cubic/parameters
And check the value of each parameter by reading a corresponding file.
$ cat /sys/module/tcp_cubic/parameters/tcp_friendliness

No comments:

Post a Comment