5

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?

1
  • 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? Mar 27, 2019 at 15:38

2 Answers 2

5

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
5
  • Though default Android might not use loadable modules, many actual devices have for years. Mar 27, 2019 at 15:26
  • Yes, I do have 20+ modules on my device. Mar 27, 2019 at 15:32
  • @IrfanLatif I have been trying to locate the *.ko files on my emulator, but can't seem to find them anywhere. It is an API 30 emulator, and I can see the modules loaded (in /proc/modules), and the appropriate file exists for /sys/module/*/initstate, but no *.ko files exist (looked with find / -name "*.ko". Any idea where else they could be? Nov 20, 2020 at 15:46
  • 1
    @WilliamReed OEMs / ROM developers might name the loadable module files differently. You may look into init configuration files (*.rc) in /system and /vendor to see how and from where modules are loaded on boot. grep -riI <mod_name> /system /vendor /odm /product or find /system /vendor /odm /product -iname '*<mod_name>*' (don't append .ko) should lead to some conclusion. Nov 20, 2020 at 16:08
  • Official guidance for placing .ko files in fs: source.android.com/devices/architecture/kernel/…
    – sergey.n
    Jul 15, 2021 at 12:15
1

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 .

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .