|Lesson 3|| Working with kernel modules |
|Objective||List available kernel modules.|
Working with Linux Kernel Modules and compiling the Linux Kernel
You can load modules, which are simply object files
into your modular kernel at any time.
You might need to load a module when, for example, you add new hardware or want to support a new kind of filesystem.
Linux stores its modules in
, under a directory named for the running kernel's version.
This arrangement allows your system to support modules for multiple kernel versions.
To determine the running kernel's version, use
uname -r or
Within each version directory there are various subdirectories that separate modules according to their type.
For example, all network modules are in the
net directory and all SCSI modules are in the scsi directory.
Listing currently loaded modules
lsmod command lists the modules currently resident in the kernel.
lsmod's output in the following MouseOver.
The Linux kernel is modular, which means it can extend its capabilities through the use of dynamically-loaded kernel modules. A kernel module can provide:
- a device driver which adds support for new hardware; or,
- support for a file system such as btrfs or NFS.
Like the kernel itself, modules can take parameters that customize their behavior, though the default parameters work well in most cases.
User-space tools can
- list the modules currently loaded into a running kernel,
- query all available modules for available parameters and module-specific information, and
- load or unload (remove) modules dynamically into or from a running kernel.
Many of these utilities, which are provided by the module-init-tools package, take module dependencies into account when performing operations so that manual dependency-tracking is rarely necessary.
On modern systems, kernel modules are automatically loaded by various mechanisms when the conditions call for it. However, there are occasions when it is necessary to load and/or unload modules manually,
such as when a module provides optional functionality, one module should be preferred over another although either could provide basic functionality,
or when a module is misbehaving, among other situations.
Compiled source code (such as C or C++).