I am trying to find Linux kernel modules on my nitrogen board. I have unpacked kernel config from /proc/config.gz and I see kernel was compiled with a lot of modules. I see only one in /vendor/lib/modules, zero in /system/lib/modules.

Can somebody explain where modules installed, what is procedure to install modules?

  • In theory they could be in a startup ramdisk. It's also possible to build modules but not packaged them (in which case they would not be usable, but stranger things have happened). If there is a particular goal you have you should edit that into your question - ie, are you trying to find a module you think is available, but which has not been loaded? – Chris Stratton Mar 27 '19 at 15:38

There are two ways Linux kernel modules are built: 1. as a part of kernel executable binary (compressed image) i.e. with CONFIG_*=y options at build time, or 2. as separate kernel object (.ko) files that can be loaded and unloaded with some conditions i.e. built with CONFIG_*=m options.
In second case the .ko files are placed on some standard location(s), usually /lib/modules/ on Linux and its equivalent on Android /system/lib/modules/ or /vendor/lib/modules/. These paths are hard-coded in binaries that load them e.g. insmod, modprobe.

On pre-Pie releases (1), by-default Android kernel is built without option CONFIG_MODULES=y, so there are no kernel modules built as .ko files which can be loaded or unloaded with insmod, modprobe or rmmod as is the case with standard Linux distros. Nor they are exposed through /proc/modules from where lsmod reads information. However each kernel component that can be built as a module has an entry in /sys/module.

Now those modules which are compiled and loaded as .ko file has a corresponding /sys/module/<module>/initstate file, others don't have. You can confirm this way if there are any loaded modules:

~$ ls /sys/module/*/initstate
|improve this answer|||||
  • Though default Android might not use loadable modules, many actual devices have for years. – Chris Stratton Mar 27 '19 at 15:26
  • Yes, I do have 20+ modules on my device. – Irfan Latif Mar 27 '19 at 15:32

Kernel modules is a piece of code which load into kernel memory. It consists of at least two functions like int, cleanup. If you want to see which modules are loaded into kernel memory, just type the commands: lsmod or cat /proc/modules. If you want to find kernel modules in whole memory of system partition: find / -name "*.ko".

Load kernel module into memory

insmod hello.ko

Remove kernel module

rmmod hello.ko

for more see dmesg log .

|improve this answer|||||

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.