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
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.
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
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
lsmodModule Size Used by xfs 803635 1 exportfs 3424 1 xfs vfat 8216 1 fat 43410 1 vfat tun 13014 2 fuse 54749 2 ip6table_filter 2743 0 ip6_tables 16558 1 ip6table_filter ebtable_nat 1895 0 ebtables 15186 1 ebtable_nat ipt_MASQUERADE 2208 6 iptable_nat 5420 1 nf_nat 19059 2 ipt_MASQUERADE,iptable_nat rfcomm 65122 4 ipv6 267017 33 sco 16204 2 bridge 45753 0 stp 1887 1 bridge llc 4557 2 bridge,stp bnep 15121 2 l2cap 45185 16 rfcomm,bnep cpufreq_ondemand 8420 2 acpi_cpufreq 7493 1 freq_table 3851 2 cpufreq_ondemand,acpi_cpufreq usb_storage 44536 1 sha256_generic 10023 2 aes_x86_64 7654 5 aes_generic 27012 1 aes_x86_64 cbc 2793 1 dm_crypt 10930 1 kvm_intel 40311 0 kvm 253162 1 kvm_intel [output truncated]
Each row of
- 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
lsmodoutput is less verbose and considerably easier to read than the content of the