此内容没有您所选择的语言版本。
Chapter 31. Working with Kernel Modules
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
orNFS
.
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.
This chapter explains how to:
- use the user-space module-init-tools package to display, query, load and unload kernel modules and their dependencies;
- set module parameters both dynamically on the command line and permanently so that you can customize the behavior of your kernel modules; and,
- load modules at boot time.
Note
In order to use the kernel module utilities described in this chapter, first ensure the module-init-tools package is installed on your system by running, as root:
yum install module-init-tools
~]# yum install module-init-tools
For more information on installing packages with Yum, see Section 8.2.4, “Installing Packages”.
31.1. Listing Currently-Loaded Modules 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
You can list all kernel modules that are currently loaded into the kernel by running the
lsmod
command:
Each row of
lsmod
output specifies:
- the name of a kernel module currently loaded in memory;
- the amount of memory it uses; and,
- the sum total of processes that are using the module and other modules which depend on it, followed by a list of the names of those modules, if there are any. Using this list, you can first unload all the modules depending the module you want to unload. For more information, see Section 31.4, “Unloading a Module”.
Finally, note that
lsmod
output is less verbose and considerably easier to read than the content of the /proc/modules
pseudo-file.