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 can I list all the available modules in the system? In which directory are they located?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
-
By default
modprobeloads modules from kernel subdirectories located in the/lib/modules/$(uname -r)directory. Usually all files have extension.ko, so you can list them withfind /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(andmodules.alias.bin). -
However, to load a modules successfully
modprobeneeds their dependencies listed in the file/lib/modules/$(uname -r)/modules.dep(and a corresponding binary versionmodules.dep.bin). If some module is present on the system, but is not on the list, then you should run a commanddepmodwhich will generate such dependencies and automatically include your module tomodules.depandmodules.dep.bin. -
Additionally, if the module is successfully loaded it will be listed in the file
/proc/modules(also accessed via commandlsmod).
Method 2
Type modprobe and press tab, the autocomplete list should contain all the loadable modules
Method 3
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).
Method 4
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.
Method 5
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
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0