60

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?

  • 1
    The kernel didnt compile this i2c-dev. You didnt find this module.The kernel modules located /lib/modules/'kernel-version'/drivers. When you are looking for linux drivers. – supriady Jan 18 '17 at 8:26
  • You can check on /boot/config-'kernel-version' and read this config file.You should know which linux modules are loaded or modulars or during compiling kernel didnt enable i2c-dev module. – supriady Jan 18 '17 at 8:33
69
  • By default modprobe loads modules from 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*'
    
  • However, to load a module successfully modprobe needs its 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).

  • 3
    Redhat 7 modules files are compressed in .xz (not sure if it is because of kernel version or OS version.. if someone can clarify it to me?) so I think you might not find them with jimmij's find command. Use instead find /lib/modules/$(uname -r) -type f -name *.ko* – Pozinux Oct 5 '17 at 13:14
  • 1
    @Pozinux Discovered the same thing here on Arch linux at 4.13.10, which have the ending .gz – Johann Nov 3 '17 at 17:12
  • 1
    @posinux: beware : the shell may expand your *.ko* if you happen to have in your current dir some file matching it. better to escape it between single quotes: find /lib/modules/$(uname -r) -type f -name '*.ko*' – Olivier Dulac Nov 21 '17 at 17:01
9

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

  • Actually, his answer is a little better than mine since it's easier to use a tool like grep on the output. – Martin Hansen Sep 16 '15 at 18:18
  • 9
    it doesn't work for some systems – avtomaton Feb 17 '16 at 22:19
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).

  • 2
    Where it's important to highlight that lsmod only shows already loaded modules. The Author of this thread had the problem to load a module that wasn't in the map of the loadable kernel modules. Besides, this solution only applies to archlinux. Which might be not the distribution of the Author and might not solve the problem for others. – Akendo Feb 6 '18 at 13:52
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.