How to list all loadable kernel modules?

I’m looking for a few kernel modules to load i2c-dev and i2c-bcm2708. But the modprobe command returns:

sudo modprobe i2c-dev
modprobe: module i2c-dev not found in modules.dep

How do I list all the available modules in the system? In which directory are they located?

Asked By: UserK

||
  • By default modprobe loads modules from kernel subdirectories located in the /lib/modules/$(uname -r) directory. Usually all files have extension .ko, so you can list them with

    find /lib/modules/$(uname -r) -type f -name '*.ko'
    

    or, taking into account compressed files:

    find /lib/modules/$(uname -r) -type f -name '*.ko*'
    
  • Each module can be also loaded by referring to its aliases, stored in the /lib/modules/$(uname -r)/modules.alias (and modules.alias.bin).

  • However, to load a modules successfully modprobe needs their dependencies listed in the file /lib/modules/$(uname -r)/modules.dep (and a corresponding binary version modules.dep.bin). If some module is present on the system, but is not on the list, then you should run a command depmod which will generate such dependencies and automatically include your module to modules.dep and modules.dep.bin.

  • Additionally, if the module is successfully loaded it will be listed in the file /proc/modules (also accessed via command lsmod).

Answered By: jimmij

Type modprobe and press tab, the autocomplete list should contain all the loadable modules

Answered By: Martin Hansen

There is lsmod command of kmod package in Arch Linux what lists and shows the status of Linux kernel modules that contains other useful commands such as modinfo, rmmod modprobe too.

To list all binaries provided by the package you can type:

pacman -Ql kmod | grep /bin/ --color=always

, and you can also check for the owner package of a binary with pacman -Qo lsmod.


Q switch is to query locally installed packages (unlike S to synchronize, ie. to check remotely).

Answered By: user86041

I prefer to use depmod. With the command: depmod -av|grep MOD_NAME, your system will generate the modules.dep/map files and grep through it.
The -v parameter is important for verbosity and -a to ensure that all possible modules from /lib/modules/ are used for the modules.dep file.

This way it’s possible to ensure, that a requested kernel module is mapped to the kernel as loadable. When the desire kernel module is not listed in the output, you know that the kernel won’t find it.

Answered By: Akendo

You can check how autocompletion does it:

$ complete -p modprobe
complete -F _modprobe modprobe
declare -f _modprobe
_modprobe () 
{ 
...

In that function there’s an internal _installed_modules

$ declare -f _installed_modules
_installed_modules () 
{ 
    COMPREPLY=($(compgen -W "$(PATH="$PATH:/sbin" lsmod |
        awk '{if (NR != 1) print $1}')" -- "$1"))
}

So lsmod | awk '{if (NR != 1) print $1}' should show you the list of modules

Answered By: albfan
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.