Chapter 38. Kernel Modules
The Linux kernel has a modular design. At boot time, only a minimal
resident kernel is loaded into memory. Thereafter, whenever a user
requests a feature that is not present in the resident kernel, a
kernel module, sometimes referred to as a
driver, is dynamically loaded into memory.
During installation, the hardware on the system is probed. Based on this
probing and the information provided by the user, the installation program
decides which modules need to be loaded at boot time. The installation
program sets up the dynamic loading mechanism to work transparently.
If new hardware is added after installation and the hardware requires a
kernel module, the system must be configured to load the proper kernel
module for the new hardware. When the system is booted with the new
hardware, the Kudzu program runs, detects the
new hardware if it is supported, and configures the module for it. The
module can also be specified manually by editing the module configuration
Video card modules used to display the X Window System interface are
part of the xorg-X11 packages, not the kernel; thus,
this chapter does not apply to them.
For example, if a system included an SMC EtherPower 10 PCI network adapter,
the module configuration file contains the following line:
If a second network card is added to the system and is identical to the
first card, add the following line to
Refer to the Red Hat Enterprise Linux Reference Guide for an alphabetical list of
kernel modules and supported hardware for those modules.
A group of commands for managing kernel modules is available if the
module-init-tools package is installed. Use these
commands to determine if a module has been loaded successfully or when
trying different modules for a piece of new hardware.
The command /sbin/lsmod displays a list of currently
loaded modules. For example:
Module Size Used by
nfs 218437 1
lockd 63977 2 nfs
parport_pc 24705 1
lp 12077 0
parport 37129 2 parport_pc,lp
autofs4 23237 2
i2c_dev 11329 0
i2c_core 22081 1 i2c_dev
sunrpc 157093 5 nfs,lockd
button 6481 0
battery 8901 0
ac 4805 0
md5 4033 1
ipv6 232833 16
ohci_hcd 21713 0
e100 39493 0
mii 4673 1 e100
floppy 58481 0
sg 33377 0
dm_snapshot 17029 0
dm_zero 2369 0
dm_mirror 22957 2
ext3 116809 2
jbd 71257 1 ext3
dm_mod 54741 6 dm_snapshot,dm_zero,dm_mirror
ips 46173 2
aic7xxx 148121 0
sd_mod 17217 3
scsi_mod 121421 4 sg,ips,aic7xxx,sd_mod
For each line, the first column is the name of the module, the second
column is the size of the module, and the third column is the use count.
The /sbin/lsmod output is less verbose and easier to
read than the output from viewing /proc/modules.
To load a kernel module, use the /sbin/modprobe
command followed by the kernel module name. By default,
modprobe attempts to load the module from the
subdirectories. There is a subdirectory for each type of module, such as
the net/ subdirectory for network interface
drivers. Some kernel modules have module dependencies, meaning that
other modules must be loaded first for it to load. The
/sbin/modprobe command checks for these dependencies
and loads the module dependencies before loading the specified module.
For example, the command
loads any module dependencies and then the e100
To print to the screen all commands as /sbin/modprobe
executes them, use the -v option. For example:
Output similar to the following is displayed:
Symbol version prefix 'smp_'
The /sbin/insmod command also exists to load kernel
modules; however, it does not resolve dependencies. Thus, it is
recommended that the /sbin/modprobe command be used.
To unload kernel modules, use the /sbin/rmmod command
followed by the module name. The rmmod utility only
unloads modules that are not in use and that are not a dependency of
other modules in use.
For example, the command
unloads the e100 kernel module.
Another useful kernel module utility is modinfo. Use
the command /sbin/modinfo to display information
about a kernel module. The general syntax is:
/sbin/modinfo [options] <module>
Options include -d, which displays a brief description
of the module, and -p, which lists the parameters the
module supports. For a complete list of options, refer to the
modinfo man page (man modinfo).