Many components of the Linux kernel may be compiled as modules which the kernel can dynamically load and remove as required.
The modules for a particular kernel are stored in
/lib/modules/
kernel-version
The best components to modularise are ones not required at boot time, for example peripheral devices and supplementary file systems.
Kernel modules are controlled by utilities supplied by the modutils package
The following is a list of 'userspace' commands that can be used to control kernel modules. Notice that we will spend more time on the depmod,modprobe and modinfo commands below.
depmod. Many modules are dependent on the presence of other modules. A flat
file database of module dependencies
/lib/modules/
is generated by the depmod
command. This command is run at boot time (for example by the
rc.sysinit script).kernel-version/modules.dep
modprobe will load any module and
dependent modules listed in modules.dep
(or conf.modules
Search for example for modules that will be loaded at the same time
as tvaudio.
grep tvaudio /lib/modules/kernel-version/modules.dep /lib/modules/k-v/kernel/drivers/media/video/tvaudio.o: \ /lib/modules/k-v/kernel/drivers/i2c/i2c-core.o
This means that the module i2c-core.o will also
be loaded when using modprobe.
This dependency is also apparent when listing the module with
lsmod:
lsmod Module Size Used by Not tainted tvaudio 16796 0 (unused) i2c-core 19236 0 [tvaudio]
/etc/modules.conf is consulted for module
parameters (IRQ and IO ports) but most often contains a list of aliases.
These aliases allow applications to refer to a device using a common name.
For example the first ethernet device is always referred to as
eth0 and not by the name
of the particular driver.
![]() | 2.6 kernels |
|---|---|
With the latest 2.6 kernels the |
modinfo will give information about modules.
modinfo tvaudio filename: /lib/modules/k-v/kernel/drivers/media/video/tvaudio.o description: "device driver for i2c TV sound decoder \ audiomux chips" author: "Eric Sandeen, Steve VanDeBogart, Greg Alexander\ Gerd Knorr" license: "GPL" parm: debug int parm: probe short array (min =1, max =48), description \ "List of adapter,address pairs to scan additionally" parm: probe_range short array (min =1, max =48), \ description "List of additional adapter triples to scan" parm: ignore short array (min =1, max =48), description\ "List of adapter,address pairs not to scan" parm: ignore_range short array (min = 1, max = 48), \ description "List of adapter triples not to scan" parm: force short array (min =1, max =48), description\ "List of adapter,address pairs to boldly assume to be present" parm: tda9874a_SIF int parm: tda9874a_AMSEL int parm: tda9874a_STD int parm: tda8425 int parm: tda9840 int
To get information only about parameter option use
modinfo -p, to get
information about the license type use
modinfo -l, etc.
kmod
is a mechanism that allows the kernel
to automatically load modules as needed (one seldom needs to insert
modules manually). This
is in fact a statically compiled (resident) module that needs to be
configured before compiling the kernel.
The command used by the kernel to load the modules is defined in
/proc/sys/kernel/modprobe.