|
|
温文尔雅的砖头 · 姚钢- 上海交通大学电气工程系· 1 年前 · |
|
|
气宇轩昂的红金鱼 · 教育部社科司关于2025年度教育部人文社会科 ...· 1 年前 · |
|
|
逆袭的电梯 · UChicago Medicine: ...· 1 年前 · |
|
|
坚韧的闹钟 · 分辨天然乳膠、合成乳膠、人造(科技)乳膠的7個方法· 1 年前 · |
|
|
老实的弓箭 · 兰飞鸿- 高清图片,堆糖,美图壁纸兴趣社区· 1 年前 · |
Increase visibility into IT operations to detect and resolve technical issues before they impact your business.
Learn More Go to InsightsEngage with our Red Hat Product Security team, access security updates, and ensure your environments are not exposed to any known security vulnerabilities. Product Security Center
Keep your systems secure with Red Hat's specialized responses to security vulnerabilities. View Responses
Abstract
The
Kernel Administration Guide
describes working with the kernel and shows several practical tasks. Beginning with information on using kernel modules, the guide then covers interaction with the
sysfs
facility, manual upgrade of the kernel and using kpatch. The guide also introduces the crash dump mechanism, which steps through the process of setting up and testing
vmcore
collection in the event of a kernel failure.
The
Kernel Administration Guide
also covers selected use cases of managing the kernel and includes reference material about command line options, kernel tunables (also known as switches), and a brief discussion of kernel features.
This Chapter explains: What is a kernel module. How to use the kmod utilities to manage modules and their dependencies. How to configure module parameters to control behavior of the kernel modules. How to load modules at boot time. In order to use the kernel module utilities described in this chapter, first ensure the kmod package is installed on your system by running, as root:
# yum install kmod
The Linux kernel is monolithic by design. However, it is compiled with optional or additional modules as required by each use case. This means that you can extend the kernel’s capabilities through the use of dynamically-loaded
kernel modules
. A kernel module can provide:
A device driver which adds support for new hardware.
Support for a file system such as
GFS2
or
NFS
.
Like the kernel itself, modules can take parameters that customize their behavior. Though the default parameters work well in most cases. In relation to kernel modules, user-space tools can do the following operations:
Listing modules currently loaded into a running kernel.
Querying all available modules for available parameters and module-specific information.
Loading or unloading (removing) modules dynamically into or from a running kernel.
Many of these utilities, which are provided by the
kmod
package, take module dependencies into account when performing operations. As a result, manual dependency-tracking is rarely necessary.
On modern systems, kernel modules are automatically loaded by various mechanisms when needed. However, there are occasions when it is necessary to load or unload modules manually. For example, when one module is preferred over another although either is able to provide basic functionality, or when a module performs unexpectedly.
Certain kernel modules sometimes depend on one or more other kernel modules. The
/lib/modules/<KERNEL_VERSION>/modules.dep
file contains a complete list of kernel module dependencies for the respective kernel version.
The dependency file is generated by the
depmod
program, which is a part of the
kmod
package. Many of the utilities provided by
kmod
take module dependencies into account when performing operations so that
manual
dependency-tracking is rarely necessary.
The code of kernel modules is executed in kernel-space in the unrestricted mode. Because of this, you should be mindful of what modules you are loading.
Additional resources
/lib/modules/<KERNEL_VERSION>/modules.dep
, refer to the
modules.dep(5)
manual page.
For further details including the synopsis and options of
depmod
, see the
depmod(8)
manual page.
You can list all kernel modules that are currently loaded into the kernel by running the
lsmod
command, for example:
# lsmod Module Size Used by tcp_lp 12663 0 bnep 19704 2 bluetooth 372662 7 bnep rfkill 26536 3 bluetooth fuse 87661 3 ebtable_broute 12731 0 bridge 110196 1 ebtable_broute stp 12976 1 bridge llc 14552 2 stp,bridge ebtable_filter 12827 0 ebtables 30913 3 ebtable_broute,ebtable_nat,ebtable_filter ip6table_nat 13015 1 nf_nat_ipv6 13279 1 ip6table_nat iptable_nat 13011 1 nf_conntrack_ipv4 14862 4 nf_defrag_ipv4 12729 1 nf_conntrack_ipv4 nf_nat_ipv4 13263 1 iptable_nat nf_nat 21798 4 nf_nat_ipv4,nf_nat_ipv6,ip6table_nat,iptable_nat [output truncated]
The
lsmod
output specifies three columns:
Module
The name of a kernel module currently loaded in memory.
The amount of memory the kernel module uses in kilobytes.
Used by
A decimal number representing how many dependencies there are on the
Module
field.
A comma separated string of dependent
Module
names. Using this list, you can first unload all the modules depending on the module you want to unload.
Finally, note that
lsmod
output is less verbose and considerably easier to read than the content of the
/proc/modules
pseudo-file.
You can display detailed information about a kernel module using the
modinfo
<MODULE_NAME>
command.
When entering the name of a kernel module as an argument to one of the
kmod
utilities, do not append a
.ko
extension to the end of the name. Kernel module names do not have extensions; their corresponding files do.
Example 1.1. Listing information about a kernel module with lsmod
To display information about the
e1000e
module, which is the Intel PRO/1000 network driver, enter the following command as
root
:
# modinfo e1000e
filename: /lib/modules/3.10.0-121.el7.x86_64/kernel/drivers/net/ethernet/intel/e1000e/e1000e.ko
version: 2.3.2-k
license: GPL
description: Intel(R) PRO/1000 Network Driver
author: Intel Corporation,
The optimal way to expand the functionality of the Linux kernel is by loading kernel modules. The following procedure describes how to use the
modprobe
command to find and load a kernel module into the currently running kernel.
Prerequisites
kmod
package is installed.
The respective kernel module is not loaded. To ensure this is the case, see
Listing Currently Loaded Modules
.
Procedure
Select a kernel module you want to load.
The modules are located in the
/lib/modules/$(uname -r)/kernel/<SUBSYSTEM>/
directory.
Load the relevant kernel module:
# modprobe <MODULE_NAME>
When entering the name of a kernel module, do not append the
.ko.xz
extension to the end of the name. Kernel module names do not have extensions; their corresponding files do.
Optionally, verify the relevant module was loaded:
$ lsmod | grep <MODULE_NAME>
If the module was loaded correctly, this command displays the relevant kernel module. For example:
$ lsmod | grep serio_raw
serio_raw 16384 0
The changes described in this procedure will not persist after rebooting the system. For information on how to load kernel modules to persist across system reboots, see Loading kernel modules automatically at system boot time .
Additional resources
modprobe
, see the
modprobe(8)
manual page.
At times, you find that you need to unload certain kernel modules from the running kernel. The following procedure describes how to use the
modprobe
command to find and unload a kernel module at system runtime from the currently loaded kernel.
Prerequisites
kmod
package is installed.
Procedure
Execute the
lsmod
command and select a kernel module you want to unload.
If a kernel module has dependencies, unload those prior to unloading the kernel module. For details on identifying modules with dependencies, see
Listing Currently Loaded Modules
and
Kernel module dependencies
.
Unload the relevant kernel module:
# modprobe -r <MODULE_NAME>
When entering the name of a kernel module, do not append the
.ko.xz
extension to the end of the name. Kernel module names do not have extensions; their corresponding files do.
Do not unload kernel modules when they are used by the running system. Doing so can lead to an unstable or non-operational system. Optionally, verify the relevant module was unloaded:
$ lsmod | grep <MODULE_NAME>
If the module was unloaded successfully, this command does not display any output.
After finishing this procedure, the kernel modules that are defined to be automatically loaded on boot, will not stay unloaded after rebooting the system. For information on how to counter this outcome, see Preventing kernel modules from being automatically loaded at system boot time .
Additional resources
modprobe
, see the
modprobe(8)
manual page.
The following procedure describes how to configure a kernel module so that it is loaded automatically during the boot process.
Prerequisites
kmod
package is installed.
Procedure
Select a kernel module you want to load during the boot process.
The modules are located in the
/lib/modules/$(uname -r)/kernel/<SUBSYSTEM>/
directory.
Create a configuration file for the module:
# echo <MODULE_NAME> > /etc/modules-load.d/<MODULE_NAME>.conf
When entering the name of a kernel module, do not append the
.ko.xz
extension to the end of the name. Kernel module names do not have extensions; their corresponding files do.
Optionally, after reboot, verify the relevant module was loaded:
$ lsmod | grep <MODULE_NAME>
The example command above should succeed and display the relevant kernel module.
The changes described in this procedure will persist after rebooting the system.
Additional resources
modules-load.d(5)
manual page.
The following procedure describes how to add a kernel module to a denylist so that it will not be automatically loaded during the boot process.
Prerequisites
kmod
package is installed.
Ensure that a kernel module in a denylist is not vital for your current system configuration.
Procedure
Select a kernel module that you want to put in a denylist:
$ lsmod Module Size Used by fuse 126976 3 xt_CHECKSUM 16384 1 ipt_MASQUERADE 16384 1 uinput 20480 1 xt_conntrack 16384 1 Thelsmodcommand displays a list of modules loaded to the currently running kernel. Alternatively, identify an unloaded kernel module you want to prevent from potentially loading. All kernel modules are located in the/lib/modules/<KERNEL_VERSION>/kernel/<SUBSYSTEM>/directory. Create a configuration file for a denylist:# vim /etc/modprobe.d/blacklist.conf # Blacklists <KERNEL_MODULE_1> blacklist <MODULE_NAME_1> install <MODULE_NAME_1> /bin/false # Blacklists <KERNEL_MODULE_2> blacklist <MODULE_NAME_2> install <MODULE_NAME_2> /bin/false # Blacklists <KERNEL_MODULE_n> blacklist <MODULE_NAME_n> install <MODULE_NAME_n> /bin/false The example shows the contents of theblacklist.conffile, edited by thevimeditor. Theblacklistline ensures that the relevant kernel module will not be automatically loaded during the boot process. Theblacklistcommand, however, does not prevent the module from being loaded as a dependency for another kernel module that is not in a denylist. Therefore theinstallline causes the/bin/falseto run instead of installing a module. The lines starting with a hash sign are comments to make the file more readable. When entering the name of a kernel module, do not append the.ko.xzextension to the end of the name. Kernel module names do not have extensions; their corresponding files do. Create a backup copy of the current initial ramdisk image before rebuilding:# cp /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).bak.$(date +%m-%d-%H%M%S).imgThe command above creates a backup
initramfsimage in case the new version has an unexpected problem. Alternatively, create a backup copy of other initial ramdisk image which corresponds to the kernel version for which you want to put kernel modules in a denylist:# cp /boot/initramfs-<SOME_VERSION>.img /boot/initramfs-<SOME_VERSION>.img.bak.$(date +%m-%d-%H%M%S)
Generate a new initial ramdisk image to reflect the changes:
# dracut -f -v
If you are building an initial ramdisk image for a different kernel version than you are currently booted into, specify both target
initramfs
and kernel version:
# dracut -f -v /boot/initramfs-<TARGET_VERSION>.img <CORRESPONDING_TARGET_KERNEL_VERSION>
Reboot the system:
$ reboot
The changes described in this procedure will take effect and persist after rebooting the system. If you improperly put a key kernel module in a denylist, you can face an unstable or non-operational system.
Additional resources
dracut
utility, refer to the
dracut(8)
manual page.
For more information on preventing automatic loading of kernel modules at system boot time on Red Hat Enterprise Linux 8 and earlier versions, see
How do I prevent a kernel module from loading automatically?
Red Hat Enterprise Linux 7 includes support for the UEFI Secure Boot feature, which means that Red Hat Enterprise Linux 7 can be installed and run on systems where UEFI Secure Boot is enabled. Note that Red Hat Enterprise Linux 7 does not require the use of Secure Boot on UEFI systems. If Secure Boot is enabled, the UEFI operating system boot loaders, the Red Hat Enterprise Linux kernel, and all kernel modules must be signed with a private key and authenticated with the corresponding public key. If they are not signed and authenticated, the system will not be allowed to finish the booting process. The Red Hat Enterprise Linux 7 distribution includes: Signed boot loaders Signed kernels Signed kernel modules In addition, the signed first-stage boot loader and the signed kernel include embedded Red Hat public keys. These signed executable binaries and embedded keys enable Red Hat Enterprise Linux 7 to install, boot, and run with the Microsoft UEFI Secure Boot Certification Authority keys that are provided by the UEFI firmware on systems that support UEFI Secure Boot. Not all UEFI-based systems include support for Secure Boot. The information provided in the following sections describes the steps to self-sign privately built kernel modules for use with Red Hat Enterprise Linux 7 on UEFI-based build systems where Secure Boot is enabled. These sections also provide an overview of available options for importing your public key into a target system where you want to deploy your kernel modules. To sign and load kernel modules, you need to: Have the relevant utilities installed on your system . Authenticate a kernel module . Generate a public and private key pair . Import the public key on the target system . Sign the kernel module with the private key . Load the signed kernel module .
To be able to sign externally built kernel modules, install the utilities listed in the following table on the build system.
Table 1.1. Required utilities
| Utility | Provided by package | Used on | Purpose | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
1.9.2. Kernel module authenticationIn Red Hat Enterprise Linux 7, when a kernel module is loaded, the module’s signature is checked using the public X.509 keys on the kernel’s system key ring, excluding keys on the kernel’s system black-list key ring. The following sections provide an overview of sources of keys/keyrings, examples of loaded keys from different sources in the system. Also, the user can see what it takes to authenticate a kernel module. 1.9.2.1. Sources for public keys used to authenticate kernel modulesDuring boot, the kernel loads X.509 keys into the system key ring or the system black-list key ring from a set of persistent key stores as shown in the table below. Table 1.2. Sources for system key rings
|