RHEL8-Managing Monitoring and Updating The Kernel
RHEL8-Managing Monitoring and Updating The Kernel
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at
http://creativecommons.org/licenses/by-sa/3.0/
. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must
provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,
Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,
Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States
and other countries.
Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and
other countries.
Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the
official Joyent Node.js open source or commercial project.
The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks
or trademarks/service marks of the OpenStack Foundation, in the United States and other
countries and are used with the OpenStack Foundation's permission. We are not affiliated with,
endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
Abstract
This document provides the users and administrators with necessary information about configuring
their workstations on the Linux kernel level. Such adjustments bring performance enhancements,
easier troubleshooting or optimized system.
Table of Contents
Table of Contents
. . . . . . . . . . . . . FEEDBACK
PROVIDING . . . . . . . . . . . . ON
. . . .RED
. . . . .HAT
. . . . .DOCUMENTATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . . . . . .
.CHAPTER
. . . . . . . . . . 1.. .THE
. . . . .LINUX
. . . . . . .KERNEL
. . . . . . . . .RPM
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . . . . . . .
1.1. WHAT AN RPM IS 6
Types of RPM packages 6
1.2. THE LINUX KERNEL RPM PACKAGE OVERVIEW 6
1.3. DISPLAYING CONTENTS OF THE KERNEL PACKAGE 7
.CHAPTER
. . . . . . . . . . 2.
. . UPDATING
. . . . . . . . . . . . KERNEL
. . . . . . . . . WITH
. . . . . . YUM
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9. . . . . . . . . . . . .
2.1. WHAT IS THE KERNEL 9
2.2. WHAT IS YUM 9
2.3. UPDATING THE KERNEL 9
2.4. INSTALLING THE KERNEL 10
.CHAPTER
. . . . . . . . . . 3.
. . MANAGING
. . . . . . . . . . . . . KERNEL
. . . . . . . . . MODULES
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11. . . . . . . . . . . . .
3.1. INTRODUCTION TO KERNEL MODULES 11
3.2. INTRODUCTION TO BOOTLOADER SPECIFICATION 11
3.3. KERNEL MODULE DEPENDENCIES 12
3.4. LISTING CURRENTLY LOADED KERNEL MODULES 12
3.5. LISTING ALL INSTALLED KERNELS 13
3.6. SETTING A KERNEL AS DEFAULT 13
3.7. DISPLAYING INFORMATION ABOUT KERNEL MODULES 14
3.8. LOADING KERNEL MODULES AT SYSTEM RUNTIME 15
3.9. UNLOADING KERNEL MODULES AT SYSTEM RUNTIME 16
3.10. LOADING KERNEL MODULES AUTOMATICALLY AT SYSTEM BOOT TIME 17
3.11. PREVENTING KERNEL MODULES FROM BEING AUTOMATICALLY LOADED AT SYSTEM BOOT TIME 18
3.12. SIGNING KERNEL MODULES FOR SECURE BOOT 20
3.12.1. Authenticating kernel modules with X.509 keys 21
3.12.1.1. Authentication requirements 21
3.12.1.2. Sources for public keys 22
3.12.1.3. Generating a public and private key pair 23
3.12.2. Enrolling public key on target system 25
3.12.2.1. Factory firmware image including public key 25
3.12.2.2. Manually adding public key to the MOK list 25
3.12.3. Signing kernel modules with the private key 26
3.12.4. Loading signed kernel modules 27
.CHAPTER
. . . . . . . . . . 4.
. . .CONFIGURING
. . . . . . . . . . . . . . . .KERNEL
. . . . . . . . .COMMAND-LINE
. . . . . . . . . . . . . . . . . .PARAMETERS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
..............
4.1. UNDERSTANDING KERNEL COMMAND-LINE PARAMETERS 29
4.2. WHAT GRUBBY IS 29
4.3. WHAT BOOT ENTRIES ARE 30
4.4. SETTING KERNEL COMMAND-LINE PARAMETERS 30
4.4.1. Changing kernel command-line parameters for all boot entries 30
4.4.2. Changing kernel command-line parameters for a single boot entry 31
. . . . . . . . . . . 5.
CHAPTER . . CONFIGURING
. . . . . . . . . . . . . . . . KERNEL
. . . . . . . . . PARAMETERS
. . . . . . . . . . . . . . . .AT
. . .RUNTIME
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .33
..............
5.1. WHAT ARE KERNEL PARAMETERS 33
5.2. SETTING KERNEL PARAMETERS AT RUNTIME 34
5.2.1. Configuring kernel parameters temporarily with sysctl 34
5.2.2. Configuring kernel parameters permanently with sysctl 35
5.2.3. Using configuration files in /etc/sysctl.d/ to adjust kernel parameters 35
5.2.4. Configuring kernel parameters temporarily through /proc/sys/ 36
1
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
.CHAPTER
. . . . . . . . . . 6.
. . .GETTING
. . . . . . . . . .STARTED
. . . . . . . . . . WITH
. . . . . . KERNEL
. . . . . . . . . LOGGING
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
..............
6.1. WHAT IS THE KERNEL RING BUFFER 42
6.2. ROLE OF PRINTK ON LOG-LEVELS AND KERNEL LOGGING 42
.CHAPTER
. . . . . . . . . . 7.
. . INSTALLING
. . . . . . . . . . . . . .AND
. . . . . CONFIGURING
. . . . . . . . . . . . . . . .KDUMP
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
..............
7.1. WHAT IS KDUMP 44
7.2. INSTALLING KDUMP 44
7.3. CONFIGURING KDUMP ON THE COMMAND LINE 45
7.3.1. Configuring kdump memory usage 45
7.3.2. Configuring the kdump target 46
7.3.3. Configuring the core collector 49
7.3.4. Configuring the kdump default failure responses 49
7.3.5. Enabling and disabling the kdump service 50
7.4. CONFIGURING KDUMP IN THE WEB CONSOLE 51
7.4.1. Configuring kdump memory usage and target location in web console 51
7.5. SUPPORTED KDUMP CONFIGURATIONS AND TARGETS 53
7.5.1. Memory requirements for kdump 53
7.5.2. Minimum threshold for automatic memory reservation 54
7.5.3. Supported kdump targets 55
7.5.4. Supported kdump filtering levels 56
7.5.5. Supported default failure responses 57
7.5.6. Estimating kdump size 58
7.6. TESTING THE KDUMP CONFIGURATION 58
7.7. USING KEXEC TO REBOOT THE KERNEL 59
7.8. BLACKLISTING KERNEL DRIVERS FOR KDUMP 60
7.9. RUNNING KDUMP ON SYSTEMS WITH ENCRYPTED DISK 61
7.10. ANALYZING A CORE DUMP 61
7.10.1. Installing the crash utility 62
7.10.2. Running and exiting the crash utility 62
7.10.3. Displaying various indicators in the crash utility 63
7.10.4. Using Kernel Oops Analyzer 66
7.11. USING EARLY KDUMP TO CAPTURE BOOT TIME CRASHES 67
7.11.1. What is early kdump 67
7.11.2. Enabling early kdump 67
7.12. RELATED INFORMATION 68
. . . . . . . . . . . 8.
CHAPTER . . .APPLYING
. . . . . . . . . . . PATCHES
. . . . . . . . . . .WITH
. . . . . .KERNEL
. . . . . . . . .LIVE
. . . . .PATCHING
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
..............
8.1. LIMITATIONS OF KPATCH 70
8.2. SUPPORT FOR THIRD-PARTY LIVE PATCHING 70
8.3. ACCESS TO KERNEL LIVE PATCHES 71
8.4. COMPONENTS OF KERNEL LIVE PATCHING 71
8.5. HOW KERNEL LIVE PATCHING WORKS 71
8.6. ENABLING KERNEL LIVE PATCHING 72
8.6.1. Subscribing to the live patching stream 72
8.7. UPDATING KERNEL PATCH MODULES 74
8.8. DISABLING KERNEL LIVE PATCHING 74
2
Table of Contents
.CHAPTER
. . . . . . . . . . 9.
. . .SETTING
. . . . . . . . . LIMITS
. . . . . . . .FOR
. . . . .APPLICATIONS
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .79
..............
9.1. UNDERSTANDING CONTROL GROUPS 79
9.2. WHAT KERNEL RESOURCE CONTROLLERS ARE 80
9.3. USING CONTROL GROUPS THROUGH A VIRTUAL FILE SYSTEM 81
9.3.1. Setting CPU limits to applications using cgroups-v1 81
9.3.2. Setting CPU limits to applications using cgroups-v2 84
9.4. ROLE OF SYSTEMD IN CONTROL GROUPS VERSION 1 89
9.5. USING CONTROL GROUPS VERSION 1 WITH SYSTEMD 90
9.5.1. Creating control groups version 1 with systemd 90
9.5.1.1. Creating transient control groups 91
9.5.1.2. Creating persistent control groups 92
9.5.2. Modifying control groups version 1 with systemd 92
9.5.2.1. Configuring memory resource control settings on the command-line 92
9.5.2.2. Configuring memory resource control settings with unit files 93
9.5.3. Removing control groups version 1 with systemd 94
9.5.3.1. Removing transient control groups 94
9.5.3.2. Removing persistent control groups 95
9.6. OBTAINING INFORMATION ABOUT CONTROL GROUPS VERSION 1 96
9.6.1. Listing systemd units 96
9.6.2. Viewing a control group version 1 hierarchy 97
9.6.3. Viewing resource controllers 99
9.6.4. Monitoring resource consumption 100
9.7. WHAT NAMESPACES ARE 100
. . . . . . . . . . . 10.
CHAPTER . . . ANALYZING
. . . . . . . . . . . . . SYSTEM
. . . . . . . . . .PERFORMANCE
. . . . . . . . . . . . . . . . .WITH
. . . . . .BPF
. . . . .COMPILER
. . . . . . . . . . . .COLLECTION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
...............
10.1. A BRIEF INTRODUCTION TO BCC 102
10.2. INSTALLING THE BCC-TOOLS PACKAGE 102
10.3. USING SELECTED BCC-TOOLS FOR PERFORMANCE ANALYSES 103
Using execsnoop to examine the system processes 103
Using opensnoop to track what files a command opens 104
Using biotop to examine the I/O operations on the disk 104
Using xfsslower to expose unexpectedly slow file system operations 105
. . . . . . . . . . . 11.
CHAPTER . . .ENHANCING
. . . . . . . . . . . . . SECURITY
. . . . . . . . . . . WITH
. . . . . . THE
. . . . . KERNEL
. . . . . . . . . INTEGRITY
. . . . . . . . . . . . SUBSYSTEM
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .107
...............
11.1. THE KERNEL INTEGRITY SUBSYSTEM 107
11.2. INTEGRITY MEASUREMENT ARCHITECTURE 108
11.3. EXTENDED VERIFICATION MODULE 108
11.4. TRUSTED AND ENCRYPTED KEYS 108
11.4.1. Working with trusted keys 109
11.4.2. Working with encrypted keys 110
11.5. ENABLING INTEGRITY MEASUREMENT ARCHITECTURE AND EXTENDED VERIFICATION MODULE 111
11.6. COLLECTING FILE HASHES WITH INTEGRITY MEASUREMENT ARCHITECTURE 114
11.7. RELATED INFORMATION 115
3
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
4
PROVIDING FEEDBACK ON RED HAT DOCUMENTATION
1. Make sure you are viewing the documentation in the Multi-page HTML format. In addition,
ensure you see the Feedback button in the upper right corner of the document.
2. Use your mouse cursor to highlight the part of text that you want to comment on.
3. Click the Add Feedback pop-up that appears below the highlighted text.
3. Fill in the Description field with your suggestion for improvement. Include a link to the
relevant part(s) of documentation.
5
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Files
Binary RPM
A binary RPM contains the binaries built from the sources and patches.
kernel-core - contains a minimal number of kernel modules needed for core functionality. This
sub-package alone could be used in virtualized and cloud environments to provide a Red Hat
Enterprise Linux 8 kernel with a quick boot time and a small disk size footprint.
The small set of kernel sub-packages above aims to provide a reduced maintenance surface to system
administrators especially in virtualized and cloud environments.
kernel-debug — Contains a kernel with numerous debugging options enabled for kernel
diagnosis, at the expense of reduced performance.
kernel-tools — Contains tools for manipulating the Linux kernel and supporting documentation.
kernel-devel — Contains the kernel headers and makefiles sufficient to build modules against
the kernel package.
6
CHAPTER 1. THE LINUX KERNEL RPM
kernel-abi-whitelists — Contains information pertaining to the Red Hat Enterprise Linux kernel
ABI, including a list of kernel symbols that are needed by external Linux kernel modules and a
yum plug-in to aid enforcement.
kernel-headers — Includes the C header files that specify the interface between the Linux
kernel and user-space libraries and programs. The header files define structures and constants
that are needed for building most standard programs.
Prerequisites
Procedure
7
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Additional resources
For information on how to use the rpm command on already installed kernel RPM, including its
sub-packages, see the rpm(8) manual page.
8
CHAPTER 2. UPDATING KERNEL WITH YUM
Before Red Hat releases a new kernel version, the kernel needs to pass a set of rigorous quality
assurance tests.
The Red Hat kernels are packaged in the RPM format so that they are easy to upgrade and verify by the
yum package manager.
WARNING
Kernels that have not been compiled by Red Hat are not supported by Red Hat.
Additional resources
For more information on yum see the relevant sections of Configuring basic system settings .
Procedure
This command updates the kernel along with all dependencies to the latest available version.
NOTE
9
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
NOTE
When upgrading from Red Hat Enterprise Linux 7 to Red Hat Enterprise Linux 8, follow
relevant sections of the Upgrading from RHEL 7 to RHEL 8 document.
Procedure
Additional resources
For a list of release dates of specific kernel versions, see this article.
10
CHAPTER 3. MANAGING KERNEL MODULES
System calls
On modern systems, kernel modules are automatically loaded when needed. However, in some cases it is
necessary to load or unload modules manually.
Like the kernel itself, the modules can take parameters that customize their behavior if needed.
Tooling is provided to inspect which modules are currently running, which modules are available to load
into the kernel and which parameters a module accepts. The tooling also provides a mechanism to load
and unload kernel modules into the running kernel.
Using BLS, you can manage the bootloader menu options by adding, removing, or editing individual boot
entry files in a directory. This makes the kernel installation process significantly simpler and consistent
across the different architectures.
The grubby tool is a thin wrapper script around the BLS and it supports the same grubby arguments
and options. It runs the dracut to create an initial ramdisk image. With this setup, the core bootloader
configuration files are static and are not modified after kernel installation.
This premise is particularly relevant in Red Hat Enterprise Linux 8 because the same bootloader is not
used in all architectures. GRUB2 is used in most of them such as the 64-bit ARM, but little-endian
variants of IBM Power Systems with Open Power Abstraction Layer (OPAL) uses Petitboot and the IBM
Z architecture uses zipl.
Additional Resources
11
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
For more details for boot entries, see What are Boot Entries
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.
WARNING
Additional resources
For further details including the synopsis and options of depmod, see the depmod(8) manual
page.
Prerequisites
Procedure
$ lsmod
12
CHAPTER 3. MANAGING KERNEL MODULES
The second column displays the amount of memory per module in kilobytes.
The last column shows the number, and optionally the names of modules that are
dependent on a particular module.
Additional resources
For more information about kmod, refer to the /usr/share/doc/kmod/README file or the
lsmod(8) manual page.
Procedure
The following output displays the boot entries of the kernel. The kernel field shows the kernel
path.
Procedure
Execute the following command to set the kernel as default using the grubby tool:
13
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
NOTE
List the boot entries using the id argument and then set an intended kernel as default:
NOTE
To list the boot entries using the title argument, execute the # grubby --info=ALL |
grep title command.
Execute the following command to set the default kernel for only the next reboot using the
grub2-reboot command:
# grub2-reboot <index|title|id>
WARNING
Set the default kernel for only the next boot with care. Installing new kernel
RPM’s, self-built kernels, and manually adding the entries to the
/boot/loader/entries/ directory may change the index values.
Prerequisites
Procedure
14
CHAPTER 3. MANAGING KERNEL MODULES
$ modinfo <KERNEL_MODULE_NAME>
For example:
$ modinfo virtio_net
filename: /lib/modules/4.18.0-94.el8.x86_64/kernel/drivers/net/virtio_net.ko.xz
license: GPL
description: Virtio network driver
rhelversion: 8.1
srcversion: 2E9345B281A898A91319773
alias: virtio:d00000001v*
depends: net_failover
intree: Y
name: virtio_net
vermagic: 4.18.0-94.el8.x86_64 SMP mod_unload modversions
…
parm: napi_weight:int
parm: csum:bool
parm: gso:bool
parm: napi_tx:bool
The modinfo command displays some detailed information about the specified kernel module.
You can query information about all available modules, regardless of whether they are loaded or
not. The parm entries show parameters the user is able to set for the module, and what type of
value they expect.
NOTE
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.
Additional resources
For more information about the modinfo, refer to the modinfo(8) manual page.
Prerequisites
Root permissions
The respective kernel module is not loaded. To ensure this is the case, list the loaded kernel
modules.
Procedure
15
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# modprobe <MODULE_NAME>
NOTE
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.
If the module was loaded correctly, this command displays the relevant kernel module. For
example:
IMPORTANT
The changes described in this procedure will not persist after rebooting the system.
Additional resources
For further details about modprobe, see the modprobe(8) manual page.
Prerequisites
Root permissions
Procedure
1. 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 Section 3.4, “Listing currently loaded
kernel modules”.
# modprobe -r <MODULE_NAME>
When entering the name of a kernel module, do not append the .ko.xz extension to the end of
16
CHAPTER 3. MANAGING KERNEL MODULES
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.
WARNING
Do not unload kernel modules when they are used by the running system.
Doing so can lead to an unstable or non-operational system.
If the module was unloaded successfully, this command does not display any output.
IMPORTANT
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
For further details about modprobe, see the modprobe(8) manual page.
Prerequisites
Root permissions
Procedure
1. 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.
NOTE
17
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
NOTE
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.
The example command above should succeed and display the relevant kernel module.
IMPORTANT
The changes described in this procedure will persist after rebooting the system.
Additional resources
For further details about loading kernel modules during the boot process, see the modules-
load.d(5) manual page.
Prerequisites
Root permissions
Ensure that a blacklisted kernel module is not vital for your current system configuration.
Procedure
$ lsmod
The lsmod command displays a list of modules loaded to the currently running kernel.
Alternatively, identify an unloaded kernel module you want to prevent from potentially
loading.
# 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 the blacklist.conf file, edited by the vim editor. The
blacklist line ensures that the relevant kernel module will not be automatically loaded during
the boot process. The blacklist command, however, does not prevent the module from being
loaded as a dependency for another kernel module that is not blacklisted. Therefore the install
line causes the /bin/false to run instead of installing a module.
The lines starting with a hash sign are comments to make the file more readable.
NOTE
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.
3. Create a backup copy of the current initial ramdisk image before rebuilding:
The command above creates a backup initramfs image 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 blacklist kernel modules:
# cp /boot/initramfs-<SOME_VERSION>.img /boot/initramfs-
<SOME_VERSION>.img.bak.$(date +%m-%d-%H%M%S)
# 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:
19
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# dracut -f -v /boot/initramfs-<TARGET_VERSION>.img
<CORRESPONDING_TARGET_KERNEL_VERSION>
$ reboot
IMPORTANT
The changes described in this procedure will take effect and persistafter rebooting the
system. Improper blacklisting of a key kernel module can result in an unstable or non-
operational system.
Additional resources
For further details concerning the dracut utility, refer to the dracut(8) manual page.
If Secure Boot is enabled, the UEFI operating system boot loaders, the Red Hat Enterprise Linux kernel,
and all kernel modules have to 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.
Signed kernels
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 RHEL 8 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. Note that not all UEFI-based systems include support for
Secure Boot.
20
CHAPTER 3. MANAGING KERNEL MODULES
Prerequisites
To be able to sign externally built kernel modules, install the utilities listed in the following table on the
build system.
NOTE
The build system, where you build and sign your kernel module, does not need to have
UEFI Secure Boot enabled and does not even need to be a UEFI-based system.
This section explains what conditions have to be met for loading kernel modules on systems with
enabled UEFI Secure Boot functionality.
If UEFI Secure Boot is enabled or if the module.sig_enforce kernel parameter has been specified, you
can only load signed kernel modules that are authenticated using a key on the system keyring. In
addition, the public key must not be on the system black list keyring.
If UEFI Secure Boot is disabled and if the module.sig_enforce kernel parameter has not been
specified, you can load unsigned kernel modules and signed kernel modules without a public key. This is
summarized in the table below.
21
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Module signed Public key UEFI Secure sig_enforce Module load Kernel tainted
found and Boot state
signature valid
Enabled - Fails -
Enabled - Fails -
Enabled - Succeeds No
During boot, the kernel loads X.509 keys into the system keyring or the system black list keyring from a
set of persistent key stores as shown in the table below.
Source of X.509 keys User ability to add keys UEFI Secure Boot state Keys loaded during
boot
Enabled .system_keyring
Enabled .system_keyring
22
CHAPTER 3. MANAGING KERNEL MODULES
Source of X.509 keys User ability to add keys UEFI Secure Boot state Keys loaded during
boot
Enabled .system_keyring
If the system is not UEFI-based or if UEFI Secure Boot is not enabled, then only the keys that are
embedded in the kernel are loaded onto the system keyring. In that case you have no ability to augment
that set of keys without rebuilding the kernel.
The system black list keyring is a list of X.509 keys which have been revoked. If your module is signed by
a key on the black list then it will fail authentication even if your public key is in the system keyring.
You can display information about the keys on the system keyrings using the keyctl utility. The following
is a shortened example output from a RHEL 8 system where UEFI Secure Boot is not enabled.
The following is a shortened example output from a RHEL 8 system where UEFI Secure Boot is enabled.
The above output shows the addition of two keys from the UEFI Secure Boot "db" keys as well as the
Red Hat Secure Boot (CA key 1), which is embedded in the shim.efi boot loader. You can also look for
the kernel console messages that identify the keys with an UEFI Secure Boot related source. These
include UEFI Secure Boot db, embedded shim, and MOK list.
You need to generate a public and private X.509 key pair to succeed in your efforts of using kernel
modules on a Secure Boot-enabled system. You will later use the private key to sign the kernel module.
You will also have to add the corresponding public key to the Machine Owner Key (MOK) for Secure
Boot to validate the signed module.
Some of the parameters for this key pair generation are best specified with a configuration file.
Procedure
23
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
1. Create a configuration file with parameters for the key pair generation:
[ req_distinguished_name ]
O = Organization
CN = Organization signing key
emailAddress = E-mail address
[ myexts ]
basicConstraints=critical,CA:FALSE
keyUsage=digitalSignature
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid
EOF
2. Create an X.509 public and private key pair as shown in the following example:
The public key will be written to the my_signing_key_pub.der file and the private key will be
written to the my_signing_key.priv file.
In RHEL 8, the validity dates of the key pair matter. The key does not expire, but the kernel
module must be signed within the validity period of its signing key. For example, a key that is
only valid in 2019 can be used to authenticate a kernel module signed in 2019 with that key.
However, users cannot use that key to sign a kernel module in 2020.
3. Optionally, you can review the validity dates of your public keys like in the example below:
Validity
Not Before: Feb 14 16:34:37 2019 GMT
Not After : Feb 11 16:34:37 2029 GMT
4. Enroll your public key on all systems where you want to authenticate and load your kernel
module.
24
CHAPTER 3. MANAGING KERNEL MODULES
WARNING
Apply strong security measures and access policies to guard the contents of your
private key. In the wrong hands, the key could be used to compromise any system
which is authenticated by the corresponding public key.
Additional resources
For details about enrolling public keys into target systems, see Section 3.12.2.2, “Manually
adding public key to the MOK list”.
To facilitate authentication of your kernel module on your systems, consider requesting your system
vendor to incorporate your public key into the UEFI Secure Boot key database in their factory firmware
image.
The Machine Owner Key (MOK) facility feature can be used to expand the UEFI Secure Boot key
database. When RHEL 8 boots on a UEFI-enabled system with Secure Boot enabled, the keys on the
MOK list are also added to the system keyring in addition to the keys from the key database. The MOK
list keys are also stored persistently and securely in the same fashion as the Secure Boot database keys,
but these are two separate facilities. The MOK facility is supported by shim.efi, MokManager.efi,
grubx64.efi, and the mokutil utility.
Enrolling a MOK key requires manual interaction by a user at the UEFI system console on each target
system. Nevertheless, the MOK facility provides a convenient method for testing newly generated key
pairs and testing kernel modules signed with them.
Procedure
You will be asked to enter and confirm a password for this MOK enrollment request.
3. Enter the password you previously associated with this request and confirm the enrollment.
25
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Once a key is on the MOK list, it will be automatically propagated to the system keyring on this and
subsequent boots when UEFI Secure Boot is enabled.
Prerequisites
You generated a public and private key pair and know the validity dates of your public keys. For
details, see Section 3.12.1.3, “Generating a public and private key pair” .
You enrolled your public key on the target system. For details, see Section 3.12.2, “Enrolling
public key on target system”.
Procedure
Execute the sign-file utility with parameters as shown in the example below:
# /usr/src/kernels/$(uname -r)/scripts/sign-file \
sha256 \
my_signing_key.priv \
my_signing_key_pub.der \
my_module.ko
Your kernel module is in ELF image format and sign-file computes and appends the signature
directly to the ELF image in your kernel module file. The modinfo utility can be used to display
information about the kernel module’s signature, if it is present.
The appended signature is not contained in an ELF image section and is not a formal part of the
ELF image. Therefore, utilities such as readelf will not be able to display the signature on your
kernel module.
Your kernel module is now ready for loading. Note that your signed kernel module is also
loadable on systems where UEFI Secure Boot is disabled or on a non-UEFI system. That means
you do not need to provide both a signed and unsigned version of your kernel module.
IMPORTANT
In RHEL 8, the validity dates of the key pair matter. The key does not expire, but
the kernel module must be signed within the validity period of its signing key. The
sign-file utility will not warn you of this. For example, a key that is only valid in
2019 can be used to authenticate a kernel module signed in 2019 with that key.
However, users cannot use that key to sign a kernel module in 2020.
Additional resources
For details on using modinfo to obtain information about kernel modules, see Section 3.7,
“Displaying information about kernel modules”.
26
CHAPTER 3. MANAGING KERNEL MODULES
Prerequisites
You generated the public and private keypair. For details, see Section 3.12.1.3, “Generating a
public and private key pair”.
You enrolled the public key into the system keyring. For details, see Section 3.12.2.2, “Manually
adding public key to the MOK list”.
Procedure
1. Optionally, verify that your kernel module will not load before you have enrolled your public key.
For details on how to list currently loaded kernel modules, see Section 3.4, “Listing currently
loaded kernel modules”.
2. Verify what keys have been added to the system keyring on the current boot:
Since your public key has not been enrolled yet, it should not be displayed in the output of the
command.
# reboot
6. Copy the kernel module into the /extra/ directory of the kernel you want:
# depmod -a
8. Load the kernel module and verify that it was successfully loaded:
# modprobe -v my_module
# lsmod | grep my_module
Additional resources
For further information about loading kernel modules, see the relevant sections of Chapter 3,
Managing kernel modules.
28
CHAPTER 4. CONFIGURING KERNEL COMMAND-LINE PARAMETERS
IMPORTANT
Kernel boot time parameters are often used to overwrite default values and for setting specific
hardware settings.
By default, the kernel command-line parameters for systems using the GRUB2 bootloader are defined
in the kernelopts variable of the /boot/grub2/grubenv file for all kernel boot entries.
NOTE
For IBM Z, the kernel command-line parameters are stored in the boot entry
configuration file because the zipl bootloader does not support environment variables.
Thus, the kernelopts environment variable cannot be used.
Additional resources
For more information about what kernel command-line parameters you can modify, see kernel-
command-line(7), bootparam(7) and dracut.cmdline(7) manual pages.
For more information about the kernelopts variable, see the knowledge base article, How to
install and boot custom kernels in Red Hat Enterprise Linux 8.
You can use grubby also for changing the default boot entry, and for adding/removing arguments from
a GRUB2 menu entry.
29
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
6f9cc9cb7d7845d49698c9537337cedc-4.18.0-5.el8.x86_64.conf
The file name above consists of a machine ID stored in the /etc/machine-id file, and a kernel version.
The boot entry configuration file contains information about the kernel version, the initial ramdisk image,
and the kernelopts environment variable, which contains the kernel command-line parameters. The
contents of a boot entry config can be seen below:
Additional resources
For more information about kernelopts variable, see knowledge base article How to install and boot
custom kernels in Red Hat Enterprise Linux 8.
This section explains how to change kernel command-line parameters on various CPU architectures.
Prerequisites
Verify that the grubby and zipl utilities are installed on your system.
Procedure
To add a parameter:
For systems that use the GRUB2 bootloader, the command updates the /boot/grub2/grubenv
30
CHAPTER 4. CONFIGURING KERNEL COMMAND-LINE PARAMETERS
For systems that use the GRUB2 bootloader, the command updates the /boot/grub2/grubenv
file by adding a new kernel parameter to the kernelopts variable in that file.
On IBM Z that use the zIPL bootloader, the command adds a new kernel parameter to each
/boot/loader/entries/<ENTRY>.conf file.
On IBM Z, execute the zipl command with no options to update the boot menu.
To remove a parameter:
On IBM Z, execute the zipl command with no options to update the boot menu.
Additional resources
For more information about kernel command-line parameters, see Section 4.1, “Understanding
kernel command-line parameters”.
For information on the grubby utility, see the grubby(8) manual page.
For further examples on how to use grubby, see the grubby tool.
For information about the zipl utility, see the zipl(8) manual page.
Prerequisites
Verify that the grubby and zipl utilities are installed on your system.
Procedure
To add a parameter:
On IBM Z, execute the zipl command with no options to update the boot menu.
On IBM Z, execute the zipl command with no options to update the boot menu.
NOTE
On systems that use the grub.cfg file, there is, by default, the options parameter for
each kernel boot entry, which is set to the kernelopts variable. This variable is defined in
the /boot/grub2/grubenv configuration file.
IMPORTANT
31
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
IMPORTANT
On GRUB 2 systems:
+ * If the kernel command-line parameters are modified for all boot entries, the grubby
utility updates the kernelopts variable in the /boot/grub2/grubenv file.
+ * If kernel command-line parameters are modified for a single boot entry, the
kernelopts variable is expanded, the kernel parameters are modified, and the resulting
value is stored in the respective boot entry’s
/boot/loader/entries/<RELEVANT_KERNEL_BOOT_ENTRY.conf> file.
+ * On zIPL systems, grubby modifies and stores the kernel command-line parameters of
an individual kernel boot entry in the /boot/loader/entries/<ENTRY>.conf file.
Additional resources
For more information about kernel command-line parameters, see Section 4.1, “Understanding
kernel command-line parameters”.
For information on the grubby utility, see the grubby(8) manual page.
For further examples on how to use grubby, see the grubby tool.
For information about the zipl utility, see the zipl(8) manual page.
32
CHAPTER 5. CONFIGURING KERNEL PARAMETERS AT RUNTIME
Tunables are divided into classes by the kernel subsystem. Red Hat Enterprise Linux has the following
tunable classes:
Additional resources
33
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
IMPORTANT
Prerequisites
Root permissions
Procedure
# sysctl -a
NOTE
# sysctl <TUNABLE_CLASS>.<PARAMETER>=<TARGET_VALUE>
The sample command above changes the parameter value while the system is running. The
changes take effect immediately, without a need for restart.
NOTE
Additional resources
For more information about sysctl, see the sysctl(8) manual page.
To permanently modify kernel parameters, either use the sysctl command to write the values to
the /etc/sysctl.conf file or make manual changes to the configuration files in the /etc/sysctl.d/
directory.
34
CHAPTER 5. CONFIGURING KERNEL PARAMETERS AT RUNTIME
Prerequisites
Root permissions
Procedure
# sysctl -a
The command displays all kernel parameters that can be configured at runtime.
The sample command changes the tunable value and writes it to the /etc/sysctl.conf file, which
overrides the default values of kernel parameters. The changes take effect immediately and
persistently, without a need for restart.
NOTE
To permanently modify kernel parameters you can also make manual changes to the
configuration files in the /etc/sysctl.d/ directory.
Additional resources
For more information about sysctl, see the sysctl(8) and sysctl.conf(5) manual pages.
For more information about using the configuration files in the /etc/sysctl.d/ directory to make
permanent changes to kernel parameters, see Using configuration files in /etc/sysctl.d/ to
adjust kernel parameters section.
Prerequisites
Root permissions
Procedure
35
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# vim /etc/sysctl.d/<some_file.conf>
<TUNABLE_CLASS>.<PARAMETER>=<TARGET_VALUE>
<TUNABLE_CLASS>.<PARAMETER>=<TARGET_VALUE>
# sysctl -p /etc/sysctl.d/<some_file.conf>
The command enables you to read values from the configuration file, which you created
earlier.
Additional resources
For more information about sysctl, see the sysctl(8) manual page.
For more information about /etc/sysctl.d/, see the sysctl.d(5) manual page.
Prerequisites
Root permissions
Procedure
# ls -l /proc/sys/<TUNABLE_CLASS>/
The writable files returned by the command can be used to configure the kernel. The files with
read-only permissions provide feedback on the current settings.
The command makes configuration changes that will disappear once the system is restarted.
36
CHAPTER 5. CONFIGURING KERNEL PARAMETERS AT RUNTIME
# cat /proc/sys/<TUNABLE_CLASS>/<PARAMETER>
Additional resources
To permanently modify kernel parameters, either use the sysctl command or make manual
changes to the configuration files in the /etc/sysctl.d/ directory.
The following sections explain the reasons behind this advice by summarizing:
Describing the kernel parameters that control a system’s behavior on a soft lockup.
Additional resources
For a technical reason behind a soft lockup, example log messages, and other details, see the
following Knowledge Article.
softlockup_panic
Controls whether or not the kernel will panic when a soft lockup is detected.
In order to panic, the system needs to detect a hard lockup first. The detection is controlled by the
37
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
In order to panic, the system needs to detect a hard lockup first. The detection is controlled by the
nmi_watchdog parameter.
nmi_watchdog
Controls whether lockup detection mechanisms (watchdogs) are active or not. This parameter is of
integer type.
Value Effect
The hard lockup detector monitors each CPU for its ability to respond to interrupts.
watchdog_thresh
Controls frequency of watchdog hrtimer, NMI events, and soft/hard lockup thresholds.
10 seconds 2 * watchdog_thresh
Additional resources
For further information about nmi_watchdog and softlockup_panic, see the Softlockup
detector and hardlockup detector document.
For more details about watchdog_thresh, see the Kernel sysctl document.
Heavy work-load on a host or high contention over some specific resource such as memory, usually
causes a spurious soft lockup firing. This is because the host may schedule out the guest CPU for a
period longer than 20 seconds. Then when the guest CPU is again scheduled to run on the host, it
experiences a time jump which triggers due timers. The timers include also watchdog hrtimer, which can
consequently report a soft lockup on the guest CPU.
Because a soft lockup in a virtualized environment may be spurious, you should not enable the kernel
parameters that would cause a system panic when a soft lockup is reported on a guest CPU.
IMPORTANT
To understand soft lockups in guests, it is essential to know that the host schedules the
guest as a task, and the guest then schedules its own tasks.
38
CHAPTER 5. CONFIGURING KERNEL PARAMETERS AT RUNTIME
Additional resources
For soft lockup definition and technicalities behind its functioning, see Section 5.3.1, “What is a
soft lockup”.
To learn about components of RHEL 8 virtualized environments and their interaction, see RHEL
8 virtual machine components and their interaction.
MariaDB 10.3
MySQL 8.0
PostgreSQL 10
PostgreSQL 9.6
fs.aio-max-nr
Defines the maximum number of asynchronous I/O operations the system can handle on the server.
NOTE
fs.file-max
Defines the maximum number of file handles (temporary file names or IDs assigned to open files) the
system supports at any instance.
The kernel dynamically allocates file handles whenever a file handle is requested by an application.
The kernel however does not free these file handles when they are released by the application. The
kernel recycles these file handles instead. This means that over time the total number of allocated
file handles will increase even though the number of currently used file handles may be low.
39
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
kernel.shmall
Defines the total number of shared memory pages that can be used system-wide. To use the entire
main memory, the value of the kernel.shmall parameter should be ≤ total main memory size.
kernel.shmmax
Defines the maximum size in bytes of a single shared memory segment that a Linux process can
allocate in its virtual address space.
kernel.shmmni
Defines the maximum number of shared memory segments the database server is able to handle.
net.ipv4.ip_local_port_range
Defines the port range the system can use for programs which want to connect to a database server
without a specific port number.
net.core.rmem_default
Defines the default receive socket memory through Transmission Control Protocol (TCP).
net.core.rmem_max
Defines the maximum receive socket memory through Transmission Control Protocol (TCP).
net.core.wmem_default
Defines the default send socket memory through Transmission Control Protocol (TCP).
net.core.wmem_max
Defines the maximum send socket memory through Transmission Control Protocol (TCP).
vm.dirty_bytes / vm.dirty_ratio
Defines a threshold in bytes / in percentage of dirty-able memory at which a process generating
dirty data is started in the write() function.
NOTE
vm.dirty_background_bytes / vm.dirty_background_ratio
Defines a threshold in bytes / in percentage of dirty-able memory at which the kernel tries to actively
write dirty data to hard-disk.
NOTE
vm.dirty_writeback_centisecs
Defines a time interval between periodic wake-ups of the kernel threads responsible for writing dirty
data to hard-disk.
This kernel parameters measures in 100th’s of a second.
vm.dirty_expire_centisecs
Defines the time after which dirty data is old enough to be written to hard-disk.
This kernel parameters measures in 100th’s of a second.
Additional resources
40
CHAPTER 5. CONFIGURING KERNEL PARAMETERS AT RUNTIME
For explanation of dirty data writebacks, how they work, and what kernel parameters relate to
them, see the Dirty pagecache writeback and vm.dirty parameters document.
41
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The buffer mentioned above is a cyclic data structure which has a fixed size, and is hard-coded into the
kernel. Users can display data stored in the kernel ring buffer through the dmesg command or the
/var/log/boot.log file. When the ring buffer is full, the new data overwrites the old.
Additional resources
For more information about syslog, see the syslog(2) manual page.
For more details on how to examine or control boot log messages with dmesg, see the
dmesg(1) manual page.
# sysctl kernel.printk
kernel.printk = 7 4 1 7
42
CHAPTER 6. GETTING STARTED WITH KERNEL LOGGING
1. value. Console log-level, defines the lowest priority of messages printed to the console.
2. value. Default log-level for messages without an explicit log-level attached to them.
3. value. Sets the lowest possible log-level configuration for the console log-level.
4. value. Sets default value for the console log-level at boot time.
Each of these values above defines a different rule for handling error messages.
NOTE
Certain kernel command line parameters, such as quiet or debug, change the default
kernel.printk values.
Additional resources
For more information on kernel.printk and log-levels, see the syslog(2) manual page.
43
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
IMPORTANT
A kernel crash dump can be the only information available in the event of a system failure
(a critical bug). Therefore, ensuring that kdump is operational is important in mission-
critical environments. Red Hat advise that system administrators regularly update and
test kexec-tools in your normal kernel update cycle. This is especially important when new
kernel features are implemented.
Some installation options, such as custom Kickstart installations, in some cases do not install or enable
kdump by default. If this is the case on your system, follow the procedure below to install kdump.
Prerequisites
A repository containing the kexec-tools package for your system CPU architecture
Procedure
44
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
1. Execute the following command to check whether kdump is installed on your system:
$ rpm -q kexec-tools
kexec-tools-2.0.17-11.el8.x86_64
IMPORTANT
Starting with Red Hat Enterprise Linux 7.4 (kernel-3.10.0-693.el7) the Intel IOMMU
driver is supported with kdump. For prior versions, Red Hat Enterprise Linux 7.3 (kernel-
3.10.0-514[.XYZ].el7) and earlier, it is advised that Intel IOMMU support is disabled,
otherwise kdump kernel is likely to become unresponsive.
Additional resources
Information about memory requirements for kdump is available in Section 7.5.1, “Memory
requirements for kdump”.
Prerequisites
Procedure
crashkernel=128M
Alternatively, you can set the amount of reserved memory to a variable depending on the total
amount of installed memory. The syntax for memory reservation into a variable is
crashkernel=<range1>:<size1>,<range2>:<size2>. For example:
45
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
crashkernel=512M-2G:64M,2G-:128M
The above example reserves 64 MB of memory if the total amount of system memory is 512 MB
or higher and lower than 2 GB. If the total amount of memory is more than 2 GB, 128 MB is
reserved for kdump instead.
crashkernel=128M@16M
The example above means that kdump reserves 128 MB of memory starting at 16 MB
(physical address 0x01000000). If the offset parameter is set to 0 or omitted entirely,
kdump offsets the reserved memory automatically. This syntax can also be used when
setting a variable memory reservation as described above; in this case, the offset is always
specified last (for example, crashkernel=512M-2G:64M,2G-:128M@16M).
# grub2-mkconfig -o /boot/grub2/grub.cfg
NOTE
The alternative way to configure memory for kdump is to append the crashkernel=
<SOME_VALUE> parameter to the kernelopts variable with the grub2-editenv which
will update all of your boot entries. Or you can use the grubby utility to update kernel
command line parameters of just one entry.
Additional resources
The crashkernel= option can be defined in multiple ways. The auto value enables automatic
configuration of reserved memory based on the total amount of memory in the system,
following the guidelines described in Section 7.5.1, “Memory requirements for kdump” .
For more information on boot entries, kernelopts, and how to work with grub2-editenv and
grubby see Chapter 4, Configuring kernel command-line parameters .
Prerequisites
Procedure
To store the vmcore file in /var/crash/ directory of the local file system:
46
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
path /var/crash
The option path /var/crash represents the path to the file system in which kdump saves the
vmcore file. When you specify a dump target in the /etc/kdump.conf file, then the path is
relative to the specified dump target.
If you do not specify a dump target in the /etc/kdump.conf file, then the path represents the
absolute path from the root directory. Depending on what is mounted in the current system, the
dump target and the adjusted dump path are taken automatically.
WARNING
kdump saves the vmcore file in /var/crash/var/crash directory, when the dump
target is mounted at /var/crash and the option path is also set as /var/crash in the
/etc/kdump.conf file. For example, in the following instance, the ext4 file system is
already mounted at /var/crash and the path are set as /var/crash:
This results in the /var/crash/var/crash path. To solve this problem, use the option
path / instead of path /var/crash
To change the local directory in which the core dump is to be saved, as root, edit the /etc/kdump.conf
configuration file as described below.
1. Remove the hash sign ("#") from the beginning of the #path /var/crash line.
2. Replace the value with the intended directory path. For example:
path /usr/local/cores
IMPORTANT
In Red Hat Enterprise Linux 8, the directory defined as the kdump target using
the path directive must exist when the kdump systemd service is started -
otherwise the service fails. This behavior is different from earlier releases of
Red Hat Enterprise Linux, where the directory was being created automatically if
it did not exist when starting the service.
To write the file to a different partition, as root, edit the /etc/kdump.conf configuration file as described
below.
1. Remove the hash sign ("#") from the beginning of the #ext4 line, depending on your choice.
47
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
2. Change the file system type as well as the device name, label or UUID to the desired values. For
example:
ext4 UUID=03138356-5e61-4ab3-b58e-27507ac41937
IMPORTANT
IMPORTANT
1. Remove the hash sign ("#") from the beginning of the #raw /dev/vg/lv_kdump line.
2. Replace the value with the intended device name. For example:
raw /dev/sdb1
1. Remove the hash sign ("#") from the beginning of the #nfs my.server.com:/export/tmp line.
2. Replace the value with a valid hostname and directory path. For example:
nfs penguin.example.com:/export/cores
1. Remove the hash sign ("#") from the beginning of the #ssh [email protected] line.
Remove the hash sign from the beginning of the #sshkey /root/.ssh/kdump_id_rsa line.
Change the value to the location of a key valid on the server you are trying to dump to. For
example:
ssh [email protected]
sshkey /root/.ssh/mykey
48
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
Additional resources
For a complete list of currently supported and unsupported targets sorted by type, see
Section 7.5.3, “Supported kdump targets” .
For information on how to configure an SSH server and set up a key-based authentication, see
Configuring basic system settings in Red Hat Enterprise Linux.
To enable and configure the core collector, follow the procedure below.
Prerequisites
Procedure
1. As root, edit the /etc/kdump.conf configuration file and remove the hash sign ("#") from the
beginning of the #core_collector makedumpfile -l --message-level 1 -d 31.
core_collector makedumpfile -c
core_collector makedumpfile -d 17 -c
The command above removes both zero and free pages from the dump. The value represents a
bitmask, where each bit is associated with a certain type of memory pages and determines
whether that type of pages will be collected. For description of respective bits see
Section 7.5.4, “Supported kdump filtering levels” .
Additional resources
See the makedumpfile(8) man page for a complete list of available options.
Prerequisites
49
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Procedure
1. As root, remove the hash sign ("#") from the beginning of the #default shell line in the
/etc/kdump.conf configuration file.
2. Replace the value with a desired action as described in Section 7.5.5, “Supported default failure
responses”. For example:
default poweroff
Prerequisites
Procedure
2. To start the service in the current session, use the following command:
WARNING
Troubleshooting step
When kptr_restrict is not set to (1), and if KASLR is enabled, the contents of /proc/kore file are
50
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
When kptr_restrict is not set to (1), and if KASLR is enabled, the contents of /proc/kore file are
generated as all zeros. Consequently, the kdumpctl service fails to access the /proc/kcore and load the
crash kernel.
To work around this problem, the kexec-kdump-howto.txt file displays a warning message, which
specifies to keep the recommended setting as kptr_restrict=1.
To ensure that kdumpctl service loads the crash kernel, verify that:
Additional resources
For more information on systemd and configuring services in general, see Configuring basic
system settings in Red Hat Enterprise Linux.
Prerequisites
See Red Hat Enterprise Linux web console for further details.
7.4.1. Configuring kdump memory usage and target location in web console
The procedure below shows you how to use the Kernel Dump tab in the Red Hat Enterprise Linux web
console interface to configure the amount of memory that is reserved for the kdump kernel. The
procedure also describes how to specify the target location of the vmcore dump file and how to test
your configuration.
Prerequisites
Procedure
1. Open the Kernel Dump tab and start the kdump service.
51
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
4. Select the Local Filesystem option from the drop-down and specify the directory you want to
save the dump in.
Alternatively, select the Remote over SSH option from the drop-down to send the vmcore
to a remote machine using the SSH protocol.
Fill the Server, ssh key, and Directory fields with the remote machine address, ssh key
location, and a target directory.
Another choice is to select the Remote over NFS option from the drop-down and fill the
Mount field to send the vmcore to a remote machine using the NFS protocol.
NOTE
Tick the Compression check box to reduce the size of the vmcore file.
52
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
WARNING
This step disrupts execution of the kernel and results in a system crash and
loss of data.
Additional resources
For a complete list of currently supported targets for kdump, see Supported kdump targets .
For information on how to configure an SSH server and set up a key-based authentication, see
Using secure communications between two systems with OpenSSH .
The memory requirements vary based on certain system parameters. One of the major factors is the
system’s hardware architecture. To find out the exact machine architecture (such as Intel 64 and
AMD64, also known as x86_64) and print it to standard output, use the following command:
$ uname -m
The table below contains a list of minimum memory requirements to automatically reserve a memory
size for kdump. The size changes according to the system’s architecture and total available physical
memory.
53
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
64 GB to 1 TB 256 MB of RAM.
4 GB to 16 GB 512 MB of RAM.
16 GB to 64 GB 1 GB of RAM.
64 GB to 128 GB 2 GB of RAM.
64 GB to 1 TB 256 MB of RAM.
On many systems, kdump is able to estimate the amount of required memory and reserve it
automatically. This behavior is enabled by default, but only works on systems that have more than a
certain amount of total available memory , which varies based on the system architecture.
IMPORTANT
The automatic configuration of reserved memory based on the total amount of memory
in the system is a best effort estimation. The actual required memory may vary due to
other factors such as I/O devices. Using not enough of memory might cause that a debug
kernel is not able to boot as a capture kernel in case of a kernel panic. To avoid this
problem, sufficiently increase the crash kernel memory.
Additional resources
For information on how to change memory settings on the command line, see Section 7.3.1,
“Configuring kdump memory usage”.
For instructions on how to set up the amount of reserved memory through the web console, see
Section 7.4.1, “Configuring kdump memory usage and target location in web console” .
For more information about various Red Hat Enterprise Linux technology capabilities and limits,
see the technology capabilities and limits tables .
On some systems, it is possible to allocate memory for kdump automatically, either by using the
54
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
On some systems, it is possible to allocate memory for kdump automatically, either by using the
crashkernel=auto parameter in the boot loader configuration file, or by enabling this option in the
graphical configuration utility. For this automatic reservation to work, however, a certain amount of total
memory needs to be available in the system. The amount differs based on the system’s architecture.
The table below lists the thresholds for automatic memory allocation. If the system has less memory
than specified in the table, the memory needs to be reserved manually.
Table 7.2. Minimum Amount of Memory Required for Automatic Memory Reservation
IBM Z (s390x ) 4 GB
Additional resources
For information on how to manually change these settings on the command line, see
Section 7.3.1, “Configuring kdump memory usage” .
For instructions on how to manually change the amount of reserved memory through the web
console, see Section 7.4.1, “Configuring kdump memory usage and target location in web
console”.
Local file system ext2, ext3, ext4, and xfs file Any local file system not explicitly
systems on directly attached disk listed as supported in this table,
drives, hardware RAID logical including the auto type
drives, LVM devices, and mdraid (automatic file system detection).
arrays.
55
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
IMPORTANT
Utilizing firmware assisted dump (fadump) to capture a vmcore and store it to a remote
machine using SSH or NFS protocol causes renaming of the network interface to kdump-
<interface-name>. The renaming happens if the <interface-name> is generic, for
example *eth#, net#, and so on. This problem occurs because the vmcore capture scripts
in the initial RAM disk (initrd) add the kdump- prefix to the network interface name to
secure persistent naming. Since the same initrd is used also for a regular boot, the
interface name is changed for the production kernel too.
Additional resources
For information on how to configure the target type on the command line, see Section 7.3.2,
“Configuring the kdump target”.
For information on how to configure the target through the web console, see Section 7.4.1,
“Configuring kdump memory usage and target location in web console”.
Option Description
1 Zero pages
56
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
Option Description
2 Cache pages
4 Cache private
8 User pages
16 Free pages
NOTE
The makedumpfile command supports removal of transparent huge pages and hugetlbfs
pages. Consider both these types of hugepages User Pages and remove them using the -
8 level.
Additional resources
For instructions on how to configure the core collector on the command line, see Section 7.3.3,
“Configuring the core collector”.
Option Description
halt Halt the system, losing the core dump in the process.
poweroff Power off the system, losing the core dump in the
process.
57
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Additional resources
For detailed information on how to set up the default failure responses on the command line,
see Section 7.3.4, “Configuring the kdump default failure responses” .
The makedumpfile --mem-usage command provides a useful report about excludable pages, and can
be used to determine which dump level you want to assign. Run this command when the system is under
representative load, otherwise makedumpfile --mem-usage returns a smaller value than is expected in
your production environment.
IMPORTANT
The makedumpfile --mem-usage command reports in pages. This means that you have
to calculate the size of memory in use against the kernel page size. By default the
Red Hat Enterprise Linux kernel uses 4 KB sized pages for AMD64 and Intel 64
architectures, and 64 KB sized pages for IBM POWER architectures.
WARNING
The commands below cause the kernel to crash. Use caution when following these
steps, and never carelessly use them on active production system.
Procedure
58
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
WARNING
NOTE
The kexec utility loads the kernel and the initramfs image for the kexec system call to boot into
another kernel.
The following procedure describes how to manually invoke the kexec system call when using the kexec
utility to reboot into another kernel.
Procedure
The command manually loads the kernel and the initramfs image for the kexec system call.
# reboot
The command detects the kernel, shuts down all services and then calls the kexec system call
to reboot into the kernel you provided in the previous step.
59
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
WARNING
When you use the kexec -e command to reboot the kernel, the system does not go
through the standard shutdown sequence before starting the next kernel, which
may cause data loss or an unresponsive system.
To blacklist the kernel drivers, you may update the KDUMP_COMMANDLINE_APPEND= variable in the
/etc/sysconfig/kdump file and specify one of the following blacklisting option:
rd.driver.blacklist=<modules>
modprobe.blacklist=<modules>
When you blacklist drivers in /etc/sysconfig/kdump file, it prevents the kdump initramfs from loading
the blacklisted modules.
The following procedure describes how to blacklist a kernel driver to prevent crash kernel failures.
Procedure
$ lsmod
The lsmod command displays a list of modules that are loaded to the currently running kernel.
KDUMP_COMMANDLINE_APPEND="rd.driver.blacklist=hv_vmbus,hv_storvsc,hv_utils,hv_netv
sc,hid-hyperv"
KDUMP_COMMANDLINE_APPEND="modprobe.blacklist=emcp modprobe.blacklist=bnx2fc
modprobe.blacklist=libfcoe modprobe.blacklist=fcoe"
60
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
Additional resources
For more information concerning the oom killer, see the following Knowledge Article.
This procedure describes the running kdump mechanism by increasing the crashkernel= value, using a
remote kdump target, or using a key derivation function (KDF).
Procedure
Run the kdump mechanism using one of the following procedures:
Using the default KDF of the encrypted partition may consume a lot of memory. You must manually
provide the password in the second kernel (capture), even if you encounter an Out of Memory (OOM)
error message.
WARNING
Adding an extra key slot can have a negative effect on security, as multiple keys can
decrypt an encrypted volume. This may cause a potential risk to the volume.
61
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
To determine the cause of the system crash, you can use the crash utility, which provides an interactive
prompt very similar to the GNU Debugger (GDB). This utility allows you to interactively analyze a core
dump created by kdump, netdump, diskdump or xendump as well as a running Linux system.
Alternatively, you have the option to use the Kdump Helper or Kernel Oops Analyzer.
Procedure
The package corresponds to your running kernel and provides the data necessary for the dump
analysis.
Additional resources
For more information about how to work with repositories using the subscription-manager
utility, see Configuring basic system settings .
Prerequisites
Procedure
1. To start the crash utility, two necessary parameters need to be passed to the command:
62
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
The following example shows analyzing a core dump created on October 6 2018 at 14:05
PM, using the 4.18.0-5.el8.x86_64 kernel.
...
WARNING: kernel relocated [202MB]: patching 90160 gdb minimal_symbol values
KERNEL: /usr/lib/debug/lib/modules/4.18.0-5.el8.x86_64/vmlinux
DUMPFILE: /var/crash/127.0.0.1-2018-10-06-14:05:33/vmcore [PARTIAL DUMP]
CPUS: 2
DATE: Sat Oct 6 14:05:16 2018
UPTIME: 01:03:57
LOAD AVERAGE: 0.00, 0.00, 0.00
TASKS: 586
NODENAME: localhost.localdomain
RELEASE: 4.18.0-5.el8.x86_64
VERSION: #1 SMP Wed Aug 29 11:51:55 UTC 2018
MACHINE: x86_64 (2904 Mhz)
MEMORY: 2.9 GB
PANIC: "sysrq: SysRq : Trigger a crash"
PID: 10635
COMMAND: "bash"
TASK: ffff8d6c84271800 [THREAD_INFO: ffff8d6c84271800]
CPU: 1
STATE: TASK_RUNNING (SYSRQ)
crash>
crash> exit
~]#
NOTE
The crash command can also be used as a powerful tool for debugging a live system.
However use it with caution so as not to break your system.
63
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
To display the kernel message buffer, type the log command at the interactive prompt as
displayed in the example below:
crash> log
... several lines omitted ...
EIP: 0060:[<c068124f>] EFLAGS: 00010096 CPU: 2
EIP is at sysrq_handle_crash+0xf/0x20
EAX: 00000063 EBX: 00000063 ECX: c09e1c8c EDX: 00000000
ESI: c0a09ca0 EDI: 00000286 EBP: 00000000 ESP: ef4dbf24
DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
Process bash (pid: 5591, ti=ef4da000 task=f196d560 task.ti=ef4da000)
Stack:
c068146b c0960891 c0968653 00000003 00000000 00000002 efade5c0 c06814d0
<0> fffffffb c068150f b7776000 f2600c40 c0569ec4 ef4dbf9c 00000002 b7776000
<0> efade5c0 00000002 b7776000 c0569e60 c051de50 ef4dbf9c f196d560 ef4dbfb4
Call Trace:
[<c068146b>] ? __handle_sysrq+0xfb/0x160
[<c06814d0>] ? write_sysrq_trigger+0x0/0x50
[<c068150f>] ? write_sysrq_trigger+0x3f/0x50
[<c0569ec4>] ? proc_reg_write+0x64/0xa0
[<c0569e60>] ? proc_reg_write+0x0/0xa0
[<c051de50>] ? vfs_write+0xa0/0x190
[<c051e8d1>] ? sys_write+0x41/0x70
[<c0409adc>] ? syscall_call+0x7/0xb
Code: a0 c0 01 0f b6 41 03 19 d2 f7 d2 83 e2 03 83 e0 cf c1 e2 04 09 d0 88 41 03 f3 c3 90 c7 05
c8 1b 9e c0 01 00 00 00 0f ae f8 89 f6 <c6> 05 00 00 00 00 01 c3 89 f6 8d bc 27 00 00 00 00 8d 50
d0 83
EIP: [<c068124f>] sysrq_handle_crash+0xf/0x20 SS:ESP 0068:ef4dbf24
CR2: 0000000000000000
NOTE
The kernel message buffer includes the most essential information about the system
crash and, as such, it is always dumped first in to the vmcore-dmesg.txt file. This is
useful when an attempt to get the full vmcore file failed, for example because of lack
of space on the target location. By default, vmcore-dmesg.txt is located in the
/var/crash/ directory.
Displaying a backtrace
crash> bt
PID: 5591 TASK: f196d560 CPU: 2 COMMAND: "bash"
#0 [ef4dbdcc] crash_kexec at c0494922
#1 [ef4dbe20] oops_end at c080e402
#2 [ef4dbe34] no_context at c043089d
#3 [ef4dbe58] bad_area at c0430b26
#4 [ef4dbe6c] do_page_fault at c080fb9b
#5 [ef4dbee4] error_code (via page_fault) at c080d809
EAX: 00000063 EBX: 00000063 ECX: c09e1c8c EDX: 00000000 EBP: 00000000
DS: 007b ESI: c0a09ca0 ES: 007b EDI: 00000286 GS: 00e0
64
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
Type bt <pid> to display the backtrace of a specific process or type help bt for more information on
bt usage.
crash> ps
PID PPID CPU TASK ST %MEM VSZ RSS COMM
> 0 0 0 c09dc560 RU 0.0 0 0 [swapper]
> 0 0 1 f7072030 RU 0.0 0 0 [swapper]
0 0 2 f70a3a90 RU 0.0 0 0 [swapper]
> 0 0 3 f70ac560 RU 0.0 0 0 [swapper]
1 0 1 f705ba90 IN 0.0 2828 1424 init
... several lines omitted ...
5566 1 1 f2592560 IN 0.0 12876 784 auditd
5567 1 2 ef427560 IN 0.0 12876 784 auditd
5587 5132 0 f196d030 IN 0.0 11064 3184 sshd
> 5591 5587 2 f196d560 RU 0.0 5084 1648 bash
Use ps <pid> to display the status of a single specific process. Use help ps for more information on
ps usage.
To display basic virtual memory information, type the vm command at the interactive
prompt.
crash> vm
PID: 5591 TASK: f196d560 CPU: 2 COMMAND: "bash"
MM PGD RSS TOTAL_VM
f19b5900 ef9c6000 1648k 5084k
VMA START END FLAGS FILE
f1bb0310 242000 260000 8000875 /lib/ld-2.12.so
f26af0b8 260000 261000 8100871 /lib/ld-2.12.so
efbc275c 261000 262000 8100873 /lib/ld-2.12.so
efbc2a18 268000 3ed000 8000075 /lib/libc-2.12.so
efbc23d8 3ed000 3ee000 8000070 /lib/libc-2.12.so
efbc2888 3ee000 3f0000 8100071 /lib/libc-2.12.so
efbc2cd4 3f0000 3f1000 8100073 /lib/libc-2.12.so
efbc243c 3f1000 3f4000 100073
efbc28ec 3f6000 3f9000 8000075 /lib/libdl-2.12.so
65
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Use vm <pid> to display information on a single specific process, or use help vm for more
information on vm usage.
crash> files
PID: 5591 TASK: f196d560 CPU: 2 COMMAND: "bash"
ROOT: / CWD: /root
FD FILE DENTRY INODE TYPE PATH
0 f734f640 eedc2c6c eecd6048 CHR /pts/0
1 efade5c0 eee14090 f00431d4 REG /proc/sysrq-trigger
2 f734f640 eedc2c6c eecd6048 CHR /pts/0
10 f734f640 eedc2c6c eecd6048 CHR /pts/0
255 f734f640 eedc2c6c eecd6048 CHR /pts/0
Use files <pid> to display files opened by only one selected process, or use help files for more
information on files usage.
Prerequisites
Secure an oops message to feed the Kernel Oops Analyzer by following instructions in Red Hat
Labs.
Procedure
66
CHAPTER 7. INSTALLING AND CONFIGURING KDUMP
3. Click the DETECT button to compare the oops message based on information from
makedumpfile against known solutions.
To address this problem, RHEL 8 introduced the early kdump feature as a part of the kdump service.
Additional resources
For more information about early kdump and its use, see the /usr/share/doc/kexec-
tools/early-kdump-howto.txt file and What is early kdump support and how do I configure it?
solution.
For more information about the kdump service, see the Section 7.1, “What is kdump”.
Prerequisites
A repository containing the kexec-tools package for your system CPU architecture
Procedure
67
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
If kdump is not enabled and running see, Section 7.3.5, “Enabling and disabling the kdump
service”.
2. Rebuild the initramfs image of the booting kernel with the early kdump functionality:
4. Reboot
5. Optionally, verify that rd.earlykdump was successfully added and early kdump feature was
enabled:
# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-187.el8.x86_64 root=/dev/mapper/rhel-root ro
crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap
rhgb quiet rd.earlykdump
Additional resources
kdump.conf(5) — a manual page for the /etc/kdump.conf configuration file containing the full
documentation of available options.
zipl(8) — a manual page for the zipl boot loader utility for IBM System z.
For more information about the kexec and kdump configuration see the Red Hat
Knowledgebase article.
For more information about the supported kdump targets see the Red Hat Knowledgebase
article.
69
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Do not have to wait for long-running tasks to complete, for users to log off, or for scheduled
downtime.
Control the system’s uptime more and do not sacrifice security or stability.
Note that not every critical or important CVE will be resolved using the kernel live patching solution. Our
goal is to reduce the required reboots for security-related patches, not to eliminate them entirely. For
more details about the scope of live patching, see the Customer Portal Solutions article .
WARNING
Some incompatibilities exist between kernel live patching and other kernel
subcomponents. Read the Section 8.1, “Limitations of kpatch” carefully before using
kernel live patching.
Do not use the SystemTap or kprobe tools during or after loading a patch. The patch could fail
to take effect until after such probes have been removed.
If you require support for an issue that arises with a third-party live patch, Red Hat recommends that you
open a case with the live patching vendor at the outset of any investigation in which a root cause
determination is necessary. This allows the source code to be supplied if the vendor allows, and for their
support organization to provide assistance in root cause determination prior to escalating the
investigation to Red Hat Support.
For any system running with third-party live patches, Red Hat reserves the right to ask for reproduction
with Red Hat shipped and supported software. In the event that this is not possible, we require a similar
system and workload be deployed on your test environment without live patches applied, to confirm if
the same behavior is observed.
70
CHAPTER 8. APPLYING PATCHES WITH KERNEL LIVE PATCHING
For more information about third-party software support policies, see How does Red Hat Global
Support Services handle third-party software, drivers, and/or uncertified hardware/hypervisors or guest
operating systems?
All customers have access to kernel live patches, which are delivered through the usual channels.
However, customers who do not subscribe to an extended support offering will lose access to new
patches for the current minor release once the next minor release becomes available. For example,
customers with standard subscriptions will only be able to live patch RHEL 8.2 kernel until the RHEL 8.3
kernel is released.
A kernel module which is built specifically for the kernel being patched.
The patch module contains the code of the desired fixes for the kernel.
The patch modules register with the livepatch kernel subsystem and provide information
about original functions to be replaced, with corresponding pointers to the replacement
functions. Kernel patch modules are delivered as RPMs.
1. The kernel patch module is copied to the /var/lib/kpatch/ directory and registered for re-
application to the kernel by systemd on next boot.
2. The kpatch module is loaded into the running kernel and the new functions are registered to the
ftrace mechanism with a pointer to the location in memory of the new code.
3. When the kernel accesses the patched function, it is redirected by the ftrace mechanism which
bypasses the original functions and redirects the kernel to patched version of the function.
The following sections describe how to ensure you receive all future cumulative live patching updates for
a given kernel.
WARNING
Red Hat does not support any third party live patches applied to a Red Hat
supported system.
WARNING
Because live patches are cumulative, you cannot select which individual patches are
deployed for a given kernel.
72
CHAPTER 8. APPLYING PATCHES WITH KERNEL LIVE PATCHING
Prerequisites
Root permissions
Procedure
# uname -r
4.18.0-94.el8.x86_64
2. Search for a live patching package that corresponds to the version of your kernel:
The command above installs and applies the latest cumulative live patches for that specific
kernel only.
The live patching package contains a patch module, if the package’s version is 1-1 or higher. In
that case the kernel will be automatically patched during the installation of the live patching
package.
The kernel patch module is also installed into the /var/lib/kpatch/ directory to be loaded by the
systemd system and service manager during the future reboots.
NOTE
If there are not yet any live patches available for the given kernel, an empty live
patching package will be installed. An empty live patching package will have a
kpatch_version-kpatch_release of 0-0, for example kpatch-patch-4_18_0-94-0-
0.el8.x86_64.rpm. The installation of the empty RPM subscribes the system to all
future live patches for the given kernel.
# kpatch list
Loaded patch modules:
kpatch_4_18_0_94_1_1 [enabled]
The output shows that the kernel patch module has been loaded into the kernel, which is now
patched with the latest fixes from the kpatch-patch-4_18_0-94-1-1.el8.x86_64.rpm package.
Additional resources
For more information about the kpatch command-line utility, see the kpatch(1) manual page.
73
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Refer to the relevant sections of the Configuring basic system settings for further information
about installing software packages in Red Hat Enterprise Linux 8.
Prerequisites
The system is subscribed to the live patching stream, as described in Section 8.6.1, “Subscribing
to the live patching stream”.
Procedure
The command above automatically installs and applies any updates that are available for the
currently running kernel. Including any future released cumulative live patches.
NOTE
When the system reboots into the same kernel, the kernel is automatically live patched
again by the kpatch.service systemd service.
Additional resources
For further information about updating software packages, see the relevant sections of
Configuring basic system settings in Red Hat Enterprise Linux 8.
IMPORTANT
Currently, Red Hat does not support reverting live patches without rebooting your
system. In case of any issues, contact our support team.
74
CHAPTER 8. APPLYING PATCHES WITH KERNEL LIVE PATCHING
Prerequisites
Root permissions
Procedure
The example output above lists live patching packages that you installed.
When a live patching package is removed, the kernel remains patched until the next reboot, but
the kernel patch module is removed from disk. After the next reboot, the corresponding kernel
will no longer be patched.
The command displays no output if the package has been successfully removed.
# kpatch list
Loaded patch modules:
The example output shows that the kernel is not patched and the live patching solution is not
active because there are no patch modules that are currently loaded.
Additional resources
For more information about the kpatch command-line utility, see the kpatch(1) manual page.
For further information about removing software packages in RHEL 8, see relevant sections of
Configuring basic system settings .
Prerequisites
Root permissions
75
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Procedure
# kpatch list
Loaded patch modules:
kpatch_4_18_0_94_1_1 [enabled]
# kpatch list
Loaded patch modules:
kpatch_4_18_0_94_1_1 [enabled]
When the selected module is uninstalled, the kernel remains patched until the next reboot,
but the kernel patch module is removed from disk.
4. Optionally, verify that the kernel patch module has been uninstalled:
# kpatch list
Loaded patch modules:
…
The example output above shows no loaded or installed kernel patch modules, therefore the
kernel is not patched and the kernel live patching solution is not active.
Additional resources
For more information about the kpatch command-line utility, refer to the kpatch(1) manual
page.
Prerequisites
76
CHAPTER 8. APPLYING PATCHES WITH KERNEL LIVE PATCHING
Prerequisites
Root permissions
Procedure
2. Disable kpatch.service:
# kpatch list
Loaded patch modules:
kpatch_4_18_0_94_1_1 [enabled]
The example output testifies that kpatch.service has been disabled and is not running.
Thereby, the kernel live patching solution is not active.
# kpatch list
Loaded patch modules:
<NO_RESULT>
The example output above shows that a kernel patch module is still installed but the kernel is
not patched.
Additional resources
77
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
For more information about the kpatch command-line utility, see the kpatch(1) manual page.
For more information about the systemd system and service manager, unit configuration files,
their locations, as well as a complete list of systemd unit types, see the relevant sections in
Configuring basic system settings .
78
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
The resource controllers (a kernel component) then modify the behavior of processes in cgroups by
limiting, prioritizing or allocating system resources, (such as CPU time, memory, network bandwidth, or
various combinations) of those processes.
The added value of cgroups is process aggregation which enables division of hardware resources
among applications and users. Thereby an increase in overall efficiency, stability and security of users'
environment can be achieved.
The control file behavior and naming is consistent among different controllers.
WARNING
79
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Additional resources
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” section and cgroups(7) manual pages.
For more information about cgroups hierarchies and cgroups versions, refer to cgroups(7)
manual pages.
For more information about systemd and cgroups cooperation, see Role of systemd in control
groups section.
A resource controller, also called a control group subsystem, is a kernel subsystem that represents a
single resource, such as CPU time, memory, network bandwidth or disk I/O. The Linux kernel provides a
range of resource controllers that are mounted automatically by the systemd system and service
manager. Find a list of currently mounted resource controllers in the /proc/cgroups file.
blkio - can set limits on input/output access to and from block devices.
cpu - can adjust the parameters of the Completely Fair Scheduler (CFS) scheduler for control
group’s tasks. It is mounted together with the cpuacct controller on the same mount.
cpuacct - creates automatic reports on CPU resources used by tasks in a control group. It is
mounted together with the cpu controller on the same mount.
cpuset - can be used to restrict control group tasks to run only on a specified subset of CPUs
and to direct the tasks to use memory only on specified memory nodes.
memory - can be used to set limits on memory use by tasks in a control group and generates
automatic reports on memory resources used by those tasks.
net_cls - tags network packets with a class identifier ( classid) that enables the Linux traffic
controller (the tc command) to identify packets that originate from a particular control group
task. A subsystem of net_cls, the net_filter (iptables), can also use this tag to perform actions
on such packets. The net_filter tags network sockets with a firewall identifier ( fwid) that allows
the Linux firewall (through iptables command) to identify packets originating from a particular
control group task.
pids - can set limits for a number of processes and their children in a control group.
perf_event - can group tasks for monitoring by the perf performance monitoring and reporting
utility.
rdma - can set limits on Remote Direct Memory Access/InfiniBand specific resources in a
control group.
80
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
hugetlb - can be used to limit the usage of large size virtual memory pages by tasks in a control
group.
cpuset - Supports only the core functionality ( cpus{,.effective}, mems{,.effective}) with a new
partition feature.
perf_event - Support is inherent, no explicit control file. You can specify a v2 cgroup as a
parameter to the perf command that will profile all the tasks within that cgroup.
IMPORTANT
Additional resources
For more information about resource controllers in general, refer to the cgroups(7) manual
page.
For detailed descriptions of specific resource controllers, see the documentation in the
/usr/share/doc/kernel-doc-<kernel_version>/Documentation/cgroups-v1/ directory.
For more information about cgroups-v2, refer to the cgroups(7) manual page.
Prerequisites
81
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Procedure
1. Identify the process ID (PID) of the application you want to restrict in CPU consumption:
# top
top - 11:34:09 up 11 min, 1 user, load average: 0.51, 0.27, 0.22
Tasks: 267 total, 3 running, 264 sleeping, 0 stopped, 0 zombie
%Cpu(s): 49.0 us, 3.3 sy, 0.0 ni, 47.5 id, 0.0 wa, 0.2 hi, 0.0 si, 0.0 st
MiB Mem : 1826.8 total, 303.4 free, 1046.8 used, 476.5 buff/cache
MiB Swap: 1536.0 total, 1396.0 free, 140.0 used. 616.4 avail Mem
The example output of the top program reveals that PID 6955 (illustrative application
sha1sum) consumes a lot of CPU resources.
# mkdir /sys/fs/cgroup/cpu/Example/
The directory above represents a control group, where you can place specific processes and
apply certain CPU limits to the processes. At the same time, some cgroups-v1 interface files
and cpu controller-specific files will be created in the directory.
# ll /sys/fs/cgroup/cpu/Example/
-rw-r—r--. 1 root root 0 Mar 11 11:42 cgroup.clone_children
-rw-r—r--. 1 root root 0 Mar 11 11:42 cgroup.procs
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.stat
-rw-r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_all
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_percpu
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_percpu_sys
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_percpu_user
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_sys
-r—r—r--. 1 root root 0 Mar 11 11:42 cpuacct.usage_user
82
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
The example output shows files, such as cpuacct.usage, cpu.cfs._period_us, that represent
specific configurations and/or limits, which can be set for processes in the Example control
group. Notice that the respective file names are prefixed with the name of the control group
controller to which they belong.
By default, the newly created control group inherits access to the system’s entire CPU
resources without a limit.
The cpu.cfs_period_us file represents a period of time in microseconds (µs, represented here
as "us") for how frequently a control group’s access to CPU resources should be reallocated.
The upper limit is 1 second and the lower limit is 1000 microseconds.
The cpu.cfs_quota_us file represents the total amount of time in microseconds for which all
processes collectively in a control group can run during one period (as defined by
cpu.cfs_period_us). As soon as processes in a control group, during a single period, use up all
the time specified by the quota, they are throttled for the remainder of the period and not
allowed to run until the next period. The lower limit is 1000 microseconds.
The example commands above set the CPU time limits so that all processes collectively in the
Example control group will be able to run only for 0.2 seconds (defined by cpu.cfs_quota_us)
out of every 1 second (defined by cpu.cfs_period_us).
# cat /sys/fs/cgroup/cpu/Example/cpu.cfs_period_us
/sys/fs/cgroup/cpu/Example/cpu.cfs_quota_us
1000000
200000
or
The previous command ensures that a desired application becomes a member of the Example
control group and hence does not exceed the CPU limits configured for the Example control
group. The PID should represent an existing process in the system. The PID 6955 here was
assigned to process sha1sum /dev/zero &, used to illustrate the use-case of the cpu controller.
83
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# cat /proc/6955/cgroup
12:cpuset:/
11:hugetlb:/
10:net_cls,net_prio:/
9:memory:/user.slice/user-1000.slice/[email protected]
8:devices:/user.slice
7:blkio:/
6:freezer:/
5:rdma:/
4:pids:/user.slice/user-1000.slice/[email protected]
3:perf_event:/
2:cpu,cpuacct:/Example
1:name=systemd:/user.slice/user-1000.slice/[email protected]/gnome-terminal-
server.service
The example output above shows that the process of the desired application runs in the
Example control group, which applies CPU limits to the application’s process.
# top
top - 12:28:42 up 1:06, 1 user, load average: 1.02, 1.02, 1.00
Tasks: 266 total, 6 running, 260 sleeping, 0 stopped, 0 zombie
%Cpu(s): 11.0 us, 1.2 sy, 0.0 ni, 87.5 id, 0.0 wa, 0.2 hi, 0.0 si, 0.2 st
MiB Mem : 1826.8 total, 287.1 free, 1054.4 used, 485.3 buff/cache
MiB Swap: 1536.0 total, 1396.7 free, 139.2 used. 608.3 avail Mem
Notice that the CPU consumption of the PID 6955 has decreased from 99% to 20%.
Additional resources
For information about the control groups concept, see Section 9.1, “Understanding control
groups”.
For more information about resource controllers, see the Section 9.2, “What kernel resource
controllers are” section and the cgroups(7) manual page.
For more information about the /sys/fs/ virtual filesystem, see the sysfs(5) manual page.
Prerequisites
84
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
Prerequisites
Procedure
The command adds a kernel command-line parameter to the current boot entry. The
cgroup_no_v1=all parameter prevents cgroups-v1 from being automatically mounted.
NOTE
If cgroups-v1 have been successfully disabled, the output does not show any "type cgroup"
references, except for those which belong to systemd.
The example output shows that cgroups-v2 has been mounted to the /cgroups-v2/ directory.
# ll /cgroups-v2/
-r—r—r--. 1 root root 0 Mar 13 11:57 cgroup.controllers
-rw-r—r--. 1 root root 0 Mar 13 11:57 cgroup.max.depth
-rw-r—r--. 1 root root 0 Mar 13 11:57 cgroup.max.descendants
-rw-r—r--. 1 root root 0 Mar 13 11:57 cgroup.procs
-r—r—r--. 1 root root 0 Mar 13 11:57 cgroup.stat
85
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The /cgroups-v2/ directory, also called the root control group, contains some interface files
(starting with cgroup) and some controller-specific files such as cpuset.cpus.effective.
7. Identify the process IDs (PIDs) of applications you want to restrict in CPU consumption:
# top
top - 15:39:52 up 3:45, 1 user, load average: 0.79, 0.20, 0.07
Tasks: 265 total, 3 running, 262 sleeping, 0 stopped, 0 zombie
%Cpu(s): 74.3 us, 6.1 sy, 0.0 ni, 19.4 id, 0.0 wa, 0.2 hi, 0.0 si, 0.0 st
MiB Mem : 1826.8 total, 243.8 free, 1102.1 used, 480.9 buff/cache
MiB Swap: 1536.0 total, 1526.2 free, 9.8 used. 565.6 avail Mem
The example output of the top program reveals that PID 5473 and 5439 (illustrative application
sha1sum and cpu_load_generator) consume a lot of resources, namely CPU. Both are
example applications used to demonstrate managing the cgroups-v2 functionality.
The previous commands enable the cpu and cpuset controllers for the immediate sub-control
groups of the /cgroups-v2/ root control group.
# mkdir /cgroups-v2/Example/
The /cgroups-v2/Example/ directory represents a sub-control group, where you can place
specific processes and apply various CPU limits to the processes. Also, the previous step
enabled the cpu and cpuset controllers for this sub-control group.
At the time of creation of /cgroups-v2/Example/, some cgroups-v2 interface files and cpu and
cpuset controller-specific files will be created in the directory.
# ll /cgroups-v2/Example/
-r—r—r--. 1 root root 0 Mar 13 14:48 cgroup.controllers
86
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
The example output shows files such as cpuset.cpus and cpu.max. The files are specific to the
cpuset and cpu controllers that you enabled for the root’s ( /cgroups-v2/) direct child control
groups using the /cgroups-v2/cgroup.subtree_control file. Also, there are general cgroup
control interface files such as cgroup.procs or cgroup.controllers, which are common to all
control groups, regardless of enabled controllers.
By default, the newly created sub-control group inherited access to the system’s entire CPU
resources without a limit.
11. Ensure the processes that you want to limit compete for CPU time on the same CPU:
The previous command secures processes that you placed in the Example sub-control group,
compete on the same CPU. This setting is important for the cpu controller to activate.
IMPORTANT
The cpu controller is only activated if the relevant sub-control group has at least
2 processes, which compete for time on a single CPU.
The first value is the allowed time quota in microseconds for which all processes collectively in a
sub-control group can run during one period (specified by the second value). During a single
period, when processes in a control group collectively exhaust all the time specified by this
quota, they are throttled for the remainder of the period and not allowed to run until the next
period.
The example command sets the CPU time limits so that all processes collectively in the
87
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The example command sets the CPU time limits so that all processes collectively in the
Example sub-control group are able to run on the CPU only for 0.2 seconds out of every 1
second.
# cat /cgroups-v2/Example/cpu.max
200000 1000000
The example commands ensure that desired applications become members of the Example
sub-control group and hence do not exceed the CPU limits configured for the Example sub-
control group.
15. Verify that the applications run in the specified control group:
The example output above shows that the processes of the desired applications run in the
Example sub-control group.
# top
top - 15:56:27 up 4:02, 1 user, load average: 0.03, 0.41, 0.55
Tasks: 265 total, 4 running, 261 sleeping, 0 stopped, 0 zombie
%Cpu(s): 9.6 us, 0.8 sy, 0.0 ni, 89.4 id, 0.0 wa, 0.2 hi, 0.0 si, 0.0 st
MiB Mem : 1826.8 total, 243.4 free, 1102.1 used, 481.3 buff/cache
MiB Swap: 1536.0 total, 1526.2 free, 9.8 used. 565.5 avail Mem
Notice that the CPU consumption for the PID 5439 and PID 5473 has decreased to 10%. The
Example sub-control group limits its processes to 20% of the CPU time collectively. Since
there are 2 processes in the control group, each can utilize 10% of the CPU time.
Additional resources
For information about the control groups concept, see Section 9.1, “Understanding control
88
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
For information about the control groups concept, see Section 9.1, “Understanding control
groups”.
For more information about resource controllers, see the Section 9.2, “What kernel resource
controllers are” section and the cgroups(7) manual page.
For more information about the /sys/fs/ virtual filesystem, see the sysfs(5) manual page.
By default, the systemd system and service manager makes use of the slice, the scope and the
service units to organize and structure processes in the control groups. The systemctl command
enables you to further modify this structure by creating custom slices. Also, systemd automatically
mounts hierarchies for important kernel resource controllers in the /sys/fs/cgroup/ directory.
<name>.service
Scope - A group of externally created processes. Scopes encapsulate processes that are
started and stopped by the arbitrary processes through the fork() function and then registered
by systemd at runtime. For example, user sessions, containers, and virtual machines are treated
as scopes. Scopes are named as follows:
<name>.scope
Slice - A group of hierarchically organized units. Slices organize a hierarchy in which scopes and
services are placed. The actual processes are contained in scopes or in services. Every name of
a slice unit corresponds to the path to a location in the hierarchy. The dash ("-") character acts
as a separator of the path components to a slice from the -.slice root slice. In the following
example:
<parent-name>.slice
The service, the scope, and the slice units directly map to objects in the control group hierarchy. When
these units are activated, they map directly to control group paths built from the unit names.
Control group /:
-.slice
├─user.slice
│ ├─user-42.slice
│ │ ├─session-c1.scope
89
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The example above shows that services and scopes contain processes and are placed in slices that do
not contain processes of their own.
Additional resources
For more information about systemd, unit files, and a complete list of systemd unit types, see
the relevant sections in Configuring basic system settings .
For more information about resource controllers, see the What are kernel resource controllers
section and the systemd.resource-control(5), cgroups(7) manual pages.
For more information about fork(), see the fork(2) manual pages.
You can use the systemd system and service manager to create transient and persistent control groups
90
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
You can use the systemd system and service manager to create transient and persistent control groups
(cgroups) to set limits, prioritize, or control access to hardware resources for groups of processes.
The transient cgroups set limits on resources consumed by a unit (service or scope) during its runtime.
Procedure
To create a transient control group, use the systemd-run command in the following format:
This command creates and starts a transient service or a scope unit and runs a custom command
in such a unit.
The --unit=<name> option gives a name to the unit. If --unit is not specified, the name is
generated automatically.
The --slice=<name>.slice option makes your service or scope unit a member of a specified
slice. Replace <name>.slice with the name of an existing slice (as shown in the output of
systemctl -t slice), or create a new slice by passing a unique name. By default, services and
scopes are created as members of the system.slice.
Replace <command> with the command you wish to execute in the service or the scope
unit.
The following message is displayed to confirm that you created and started the service or
the scope successfully:
Optionally, keep the unit running after its processes finished to collect run-time information:
The command creates and starts a transient service unit and runs a custom command in such a
unit. The --remain-after-exit option ensures that the service keeps running after its processes
have finished.
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
For more information about systemd, unit configuration files and their locations, and a
complete list of systemd unit types, see the relevant sections in Configuring basic system
settings.
For a detailed description of systemd-run including further options and examples, see the
systemd-run(1) manual pages.
91
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
To assign a persistent control group to a service, it is necessary to edit its unit configuration file. The
configuration is preserved after the system reboot, so it can be used to manage services that are
started automatically.
Procedure
The command above automatically creates a unit configuration file into the
/usr/lib/systemd/system/ directory and by default, it assigns <name>.service to the
system.slice unit.
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
For more information about systemd, unit configuration files and their locations, and a
complete list of systemd unit types, see the relevant sections in Configuring basic system
settings.
For a detailed description of systemd-run including further options and examples, see the
systemd-run(1) manual pages.
Executing commands in the command-line interface is one of the ways how to set limits, prioritize, or
control access to hardware resources for groups of processes.
Procedure
The command instantly assigns the memory limit of 1,500 kilobytes to processes executed in a
control group the example.service service belongs to. The MemoryLimit parameter, in this
configuration variant, is defined in the /etc/systemd/system.control/example.service.d/50-
MemoryLimit.conf file and controls the value of the
/sys/fs/cgroup/memory/system.slice/example.service/memory.limit_in_bytes file.
92
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
The command instantly assigns the memory limit to the example.service service. The
MemoryLimit parameter is defined until the next reboot in the
/run/systemd/system.control/example.service.d/50-MemoryLimit.conf file. With a reboot,
the whole /run/systemd/system.control/ directory and MemoryLimit are removed.
NOTE
The 50-MemoryLimit.conf file stores the memory limit as a multiple of 4096 bytes - one
kernel page size specific for AMD64 and Intel 64. The actual number of bytes depends on
a CPU architecture.
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” and systemd.resource-control(5), cgroups(7) manual pages.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
Manually modifying unit files is one of the ways how to set limits, prioritize, or control access to hardware
resources for groups of processes.
Procedure
…
[Service]
MemoryLimit=1500K
…
NOTE
# systemctl daemon-reload
93
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# cat /sys/fs/cgroup/memory/system.slice/example.service/memory.limit_in_bytes
1536000
The example output shows that the memory consumption was limited at around 1,500 Kilobytes.
NOTE
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” and systemd.resource-control(5), cgroups(7) manual pages.
For more information about systemd, unit configuration files and their locations, as well as a
complete list of systemd unit types, see the relevant sections in Configuring basic system
settings.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
Transient cgroups are automatically released once all the processes that a service or a scope unit
contains, finish.
Procedure
94
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
The command above uses the --kill-who option to select process(es) from the control group
you wish to terminate. To kill multiple processes at the same time, pass a comma-separated list
of PIDs. The --signal option determines the type of POSIX signal to be sent to the specified
processes. The default signal is SIGTERM.
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” and systemd.resource-control(5), cgroups(7) manual pages.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
For more information about systemd, unit configuration files and their locations, as well as a
complete list of systemd unit types, see the relevant sections in Configuring basic system
settings.
Persistent cgroups are released when a service or a scope unit is stopped or disabled and its
configuration file is deleted.
Procedure
# rm /usr/lib/systemd/system/<name>.service
# systemctl daemon-reload
Additional resources
For more information about the concept of control groups, see Section 9.1, “Understanding
control groups”.
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” and systemd.resource-control(5), cgroups(7) manual pages.
For more information about the role of systemd in control groups, see Section 9.4, “Role of
systemd in control groups version 1”.
For more information about systemd, unit configuration files and their locations, as well as a
95
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
For more information about systemd, unit configuration files and their locations, as well as a
complete list of systemd unit types, see the relevant sections in Configuring basic system
settings.
For more information about killing processes with systemd, see the systemd.kill(5) manual
page.
Prerequisites
Procedure
To list all active units on the system, execute the # systemctl command and the terminal will
return an output similar to the following example:
96
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
UNIT - a name of a unit that also reflects the unit position in a control group hierarchy. The
units relevant for resource control are a slice, a scope, and a service.
LOAD - indicates whether the unit configuration file was properly loaded. If the unit file
failed to load, the field contains the state error instead of loaded. Other unit load states are:
stub, merged, and masked.
SUB - the low-level unit activation state. The range of possible values depends on the unit
type.
# systemctl --all
The --type option requires a comma-separated list of unit types such as a service and a slice, or
unit load states such as loaded and masked.
Additional resources
For more information about systemd, unit files, and a complete list of systemd unit types, see
the relevant sections in Configuring basic system settings .
Prerequisites
Procedure
Control group /:
-.slice
├─user.slice
│ ├─user-42.slice
│ │ ├─session-c1.scope
│ │ │ ├─ 965 gdm-session-worker [pam/gdm-launch-environment]
97
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The example output returns the entire cgroups hierarchy, where the highest level is formed by
slices.
# systemd-cgls memory
Controller memory; Control group /:
├─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 18
├─user.slice
│ ├─user-42.slice
│ │ ├─session-c1.scope
│ │ │ ├─ 965 gdm-session-worker [pam/gdm-launch-environment]
…
└─system.slice
|
…
├─chronyd.service
│ └─844 /usr/sbin/chronyd
├─example.service
│ ├─8914 /bin/bash /home/jdoe/example.sh
│ └─8916 sleep 1
…
The example output of the above command lists the services that interact with the selected
controller.
To display detailed information about a certain unit and its part of the cgroups hierarchy,
execute # systemctl status <system_unit>:
98
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
Additional resources
For more information about resource controllers, see Section 9.2, “What kernel resource
controllers are” section and systemd.resource-control(5), cgroups(7) manual pages.
Prerequisites
Procedure
1. To view which resource controllers a process interacts with, execute the # cat
proc/<PID>/cgroup command:
# cat /proc/11269/cgroup
12:freezer:/
11:cpuset:/
10:devices:/system.slice
9:memory:/system.slice/example.service
8:pids:/system.slice/example.service
7:hugetlb:/
6:rdma:/
5:perf_event:/
4:cpu,cpuacct:/
3:net_cls,net_prio:/
2:blkio:/
1:name=systemd:/system.slice/example.service
The example output relates to a process of interest. In this case, it is a process identified by PID
11269, which belongs to the example.service unit. You can determine whether the process was
placed in a correct control group as defined by the systemd unit file specifications.
NOTE
By default, the items and their ordering in the list of resource controllers is the
same for all units started by systemd, since it automatically mounts all the
default resource controllers.
Additional resources
For more information about resource controllers in general refer to the cgroups(7) manual
pages.
For a detailed description of specific resource controllers, see the documentation in the
99
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
For a detailed description of specific resource controllers, see the documentation in the
/usr/share/doc/kernel-doc-<kernel_version>/Documentation/cgroups-v1/ directory.
Prerequisites
Procedure
The example output displays currently running cgroups ordered by their resource usage (CPU,
memory, disk I/O load). The list refreshes every 1 second by default. Therefore, it offers a
dynamic insight into the actual resource usage of each control group.
Additional resources
For more information about dynamic monitoring of resource usage, see the systemd-cgtop(1)
manual pages.
A namespace wraps a global system resource (for example a mount point, a network device, or a
hostname) in an abstraction that makes it appear to processes within the namespace that they have
100
CHAPTER 9. SETTING LIMITS FOR APPLICATIONS
their own isolated instance of the global resource. One of the most common technologies that utilize
namespaces are containers.
Changes to a particular global resource are visible only to processes in that namespace and do not
affect the rest of the system or other namespaces.
To inspect which namespaces a process is a member of, you can check the symbolic links in the
/proc/<PID>/ns/ directory.
The following table shows supported namespaces and resources which they isolate:
Namespace Isolates
Additional resources
For more information about namespaces, see the namespaces(7) and cgroup_namespaces(7)
manual pages.
For more information about cgroups, see Section 9.1, “Understanding control groups” .
[1] Linux Control Group v2 - An Introduction, Devconf.cz 2019 presentation by Waiman Long
101
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
BCC removes the need for users to know deep technical details of eBPF, and provides many out-of-
the-box starting points, such as the bcc-tools package with pre-created eBPF programs.
NOTE
The eBPF programs are triggered on events, such as disk I/O, TCP connections, and
process creations. It is unlikely that the programs should cause the kernel to crash, loop or
become unresponsive because they run in a safe virtual machine in the kernel.
Additional resources
Prerequisites
Updated kernel
Procedure
1. Install bcc-tools:
# ll /usr/share/bcc/tools/
...
102
CHAPTER 10. ANALYZING SYSTEM PERFORMANCE WITH BPF COMPILER COLLECTION
The doc directory in the listing above contains documentation for each tool.
Prerequisites
Introduction to BCC
Root permissions
# /usr/share/bcc/tools/execsnoop
$ ls /usr/share/bcc/tools/doc/
3. The terminal running execsnoop shows the output similar to the following:
The execsnoop program prints a line of output for each new process, which consumes system
resources. It even detects processes of programs that run very shortly, such as ls, and most
monitoring tools would not register them.
The result above shows a parent process name (ls), its process ID ( 5076), parent process ID
(2931), the return value of the exec() system call (0), which loads program code into new
processes. Finally, the output displays a location of the started program with arguments
(/usr/bin/ls --color=auto /usr/share/bcc/tools/doc/).
103
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
To see more details, examples, and options for execsnoop, refer to the
/usr/share/bcc/tools/doc/execsnoop_example.txt file.
# /usr/share/bcc/tools/opensnoop -n uname
The above prints output for files, which are opened only by the process of the uname command.
$ uname
The command above opens certain files, which are captured in the next step.
3. The terminal running opensnoop shows the output similar to the following:
The opensnoop program watches the open() system call across the whole system, and prints a
line of output for each file that uname tried to open along the way.
The result above shows a process ID (PID), a process name ( COMM), and a file descriptor ( FD)
- a value that open() returns to refer to the open file. Finally, the output displays a column for
errors (ERR) and a location of files that open() tries to open ( PATH).
If a command tries to read a non-existent file, then the FD column returns -1 and the ERR
column prints a value corresponding to the relevant error. As a result, opensnoop can help you
identify an application that does not behave properly.
To see more details, examples, and options for opensnoop, refer to the
/usr/share/bcc/tools/doc/opensnoop_example.txt file.
# /usr/share/bcc/tools/biotop 30
The command enables you to monitor the top processes, which perform I/O operations on the
disk. The argument ensures that the command will produce a 30 second summary.
NOTE
104
CHAPTER 10. ANALYZING SYSTEM PERFORMANCE WITH BPF COMPILER COLLECTION
# dd if=/dev/vda of=/dev/zero
The command above reads the content from the local hard disk device and writes the output to
the /dev/zero file. This step generates certain I/O traffic to illustrate biotop.
3. The terminal running biotop shows the output similar to the following:
The results shows that the dd process, with the process ID 9568, performed 16,294 read
operations from the vda disk. The read operations reached total of 14,440,636 Kbytes with an
average I/O time 3.69 ms.
To see more details, examples, and options for biotop, refer to the
/usr/share/bcc/tools/doc/biotop_example.txt file.
# /usr/share/bcc/tools/xfsslower 1
The command above measures the time the XFS file system spends in performing read, write,
open or sync (fsync) operations. The 1 argument ensures that the program shows only the
operations that are slower than 1 ms.
NOTE
$ vim text
105
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
The command above creates a text file in the vim editor to initiate certain interaction with the
XFS file system.
3. The terminal running xfsslower shows something similar upon saving the file from the previous
step:
Each line above represents an operation in the file system, which took more time than a certain
threshold. xfsslower is good at exposing possible file system problems, which can take form of
unexpectedly slow operations.
The T column represents operation type ( Read/Write/Sync), OFF_KB is a file offset in KB.
FILENAME is the file the process (COMM) is trying to read, write, or sync.
To see more details, examples, and options for xfsslower, refer to the
/usr/share/bcc/tools/doc/xfsslower_example.txt file.
106
CHAPTER 11. ENHANCING SECURITY WITH THE KERNEL INTEGRITY SUBSYSTEM
Measures files' content whenever it is executed or opened. Users can change this behavior by
applying custom policies.
Places the measured values within the kernel’s memory space thereby it prevents any
modification from the users of the system.
Protects files' extended attributes (also known as xattr) that are related to the system’s
security, like IMA measurements and SELinux attributes, by cryptographically hashing their
corresponding values.
Both IMA and EVM also contain numerous feature extensions that bring additional functionality. For
example:
IMA-Appraisal
Provides local validation of the current file’s content against the values previously stored in
the measurement file within the kernel memory. This extension forbids any operation to be
performed over a specific file in case the current and the previous measure do not match.
Allows digital signatures to be used through cryptographic keys stored into the kernel’s
keyring.
NOTE
The feature extensions complement each other, but you can configure and use them
independently of one another.
The kernel integrity subsystem can harness the Trusted Platform Module (TPM) to harden the system
security even more. TPM is a specification by the Trusted Computing Group (TCG) for important
cryptographic functions. TPMs are usually built as dedicated hardware that is attached to the platform’s
107
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Random-number generator
Hashing generator
Remote attestation
Additional resources
For details about the kernel integrity subsystem, see the official upstream wiki page .
For further information about TPM, see the Trusted Computing Group resources .
RHEL 8 accepts the special encrypted key under the evm-key keyring. The key was created by a master
key held in the kernel keyrings.
Trusted and encrypted keys are variable-length symmetric keys generated by the kernel that utilize the
kernel keyring service. The fact that this type of keys never appear in the user space in an unencrypted
form means that their integrity can be verified, which in turn means that they can be used, for example,
by the extended verification module (EVM) to verify and confirm the integrity of a running system. User-
level programs can only access the keys in the form of encrypted blobs.
Trusted keys need a hardware component: the Trusted Platform Module (TPM) chip, which is used to
both create and encrypt (seal) the keys. The TPM seals the keys using a 2048-bit RSA key called the
storage root key (SRK).
NOTE
108
CHAPTER 11. ENHANCING SECURITY WITH THE KERNEL INTEGRITY SUBSYSTEM
NOTE
To use a TPM 1.2 specification, enable and activate it through a setting in the machine
firmware or by using the tpm_setactive command from the tpm-tools package of
utilities. Also, the TrouSers software stack needs to be installed and the tcsd daemon
needs to be running to communicate with the TPM (dedicated hardware). The tcsd
daemon is part of the TrouSers suite, which is available through the trousers package.
The more recent and backward incompatible TPM 2.0 uses a different software stack,
where the tpm2-tools or ibm-tss utilities provide access to the dedicated hardware.
In addition to that, the user can seal the trusted keys with a specific set of the TPM’s platform
configuration register (PCR) values. PCR contains a set of integrity-management values that reflect the
firmware, boot loader, and operating system. This means that PCR-sealed keys can only be decrypted
by the TPM on the same system on which they were encrypted. However, once a PCR-sealed trusted
key is loaded (added to a keyring), and thus its associated PCR values are verified, it can be updated
with new (or future) PCR values, so that a new kernel, for example, can be booted. A single key can also
be saved as multiple blobs, each with different PCR values.
Encrypted keys do not require a TPM, as they use the kernel Advanced Encryption Standard (AES),
which makes them faster than trusted keys. Encrypted keys are created using kernel-generated random
numbers and encrypted by a master key when they are exported into user-space blobs. The master key
is either a trusted key or a user key. If the master key is not trusted, the encrypted key is only as secure
as the user key used to encrypt it.
Prerequisites
For the 64-bit ARM architecture and IBM Z, the trusted kernel module needs to be loaded. For
more information on how to load kernel modules, see Chapter 3, Managing kernel modules.
Trusted Platform Module (TPM) needs to be enabled and active. For more information about
TPM see, ] and xref:trusted-and-encrypted-keys_enhancing-security-with-the-kernel-
integrity-subsystem[.
Procedure
The command creates a trusted key called kmk with the length of 32 bytes (256 bits) and
places it in the user keyring (@u). The keys may have a length of 32 to 128 bytes (256 to
1024 bits).
109
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# keyctl show
Session Keyring
-3 --alswrv 500 500 keyring: ses 97833714 --alswrv 500 -1 \ keyring: uid.1000
642500861 --alswrv 500 500 \ trusted: kmk
The command uses the pipe subcommand and the serial number of kmk.
4. To load the trusted key from the user-space blob, use the add subcommand with the blob as an
argument:
Based on the syntax, generate an encrypted key using the already created trusted key:
The command uses the TPM-sealed trusted key (kmk), produced in the previous step, as a
master key for generating encrypted keys.
Additional resources
For detailed information about using keyctl, see the keyctl(1) manual page.
For more information about trusted and encrypted keys, see Section 11.4, “Trusted and
encrypted keys”.
For more information about the kernel keyring service, see the upstream kernel documentation .
For more information about the TPM, see Section 11.1, “The kernel integrity subsystem” .
Prerequisites
For the 64-bit ARM architecture and IBM Z, the encrypted-keys kernel module needs to be
loaded. For more information on how to load kernel modules, see Chapter 3, Managing kernel
modules.
Procedure
110
CHAPTER 11. ENHANCING SECURITY WITH THE KERNEL INTEGRITY SUBSYSTEM
The command generates a user key called kmk-user which acts as a master key and is used to
seal the actual encrypted keys.
2. Generate an encrypted key using the master key from the previous step:
# keyctl list @u
2 keys in keyring:
427069434: --alswrv 1000 1000 user: kmk-user
1012412758: --alswrv 1000 1000 encrypted: encr-key
IMPORTANT
Keep in mind that encrypted keys that are not sealed by a master trusted key are only as
secure as the user master key (random-number key) used to encrypt them. Therefore,
the master user key should be loaded as securely as possible and preferably early during
the boot process.
Additional resources
For detailed information about using keyctl, see the keyctl(1) manual page.
For more information about the kernel keyring service, see the upstream kernel documentation .
Prerequisites
Verify that the securityfs filesystem is mounted on the /sys/kernel/security/ directory and the
/sys/kernel/security/integrity/ima/ directory exists.
# mount
…
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
…
Verify that the systemd service manager is already patched to support IMA and EVM on boot
time:
111
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
Procedure
The command enables IMA and EVM in the fix mode for the current boot entry and allows users
to gather and update the IMA measurements.
The ima_policy=appraise_tcb kernel command line parameter ensures that the kernel uses
the default Trusted Computing Base (TCB) measurement policy and the appraisal step. The
appraisal part forbids access to files, whose prior and current measures do not match.
3. Optionally, verify that the parameters have been added to the kernel command line:
# cat /proc/cmdline
BOOT_IMAGE=(hd0,msdos1)/vmlinuz-4.18.0-167.el8.x86_64 root=/dev/mapper/rhel-root ro
crashkernel=auto resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap
rhgb quiet ima_policy=appraise_tcb ima_appraise=fix evm=fix
112
CHAPTER 11. ENHANCING SECURITY WITH THE KERNEL INTEGRITY SUBSYSTEM
The kernel master key (kmk) is kept entirely in the kernel space memory. The 32-byte long
value of the kernel master key kmk is generated from random bytes from the /dev/urandom
file and placed in the user (@u) keyring. The key serial number is on the second line of the
previous output.
The command uses kmk to generate and encrypt a 64-byte long user key (named evm-key)
and places it in the user (@u) keyring. The key serial number is on the second line of the
previous output.
IMPORTANT
It is necessary to name the user key as evm-key because that is the name the
EVM subsystem is expecting and is working with.
# mkdir -p /etc/keys/
7. Search for the kmk key and export its value into a file:
The command places the unencrypted value of the kernel master key (kmk) into a file of
previously defined location (/etc/keys/).
8. Search for the evm-key user key and export its value into a file:
The command places the encrypted value of the user evm-key key into a file of arbitrary
location. The evm-key has been encrypted by the kernel master key earlier.
# keyctl show
Session Keyring
974575405 --alswrv 0 0 keyring: ses 299489774 --alswrv 0 65534 \ keyring: uid.0
748544121 --alswrv 0 0 \ user: kmk
641780271 --alswrv 0 0 \_ encrypted: evm-key
113
Red Hat Enterprise Linux 8 Managing, monitoring and updating the kernel
# dmesg | tail -1
[…] evm: key initialized
Additional resources
For more information about the kernel integrity subsystem, see Section 11.1, “The kernel integrity
subsystem”.
For more information about Integrity Measurement Architecture, see Section 11.2, “Integrity
measurement architecture”.
For more information about Extended Verification Module, see Section 11.3, “Extended
verification module”.
For more information about creating encrypted keys, see Section 11.4, “Trusted and encrypted
keys”.
Prerequisites
Enable integrity measurement architecture (IMA) and extended verification module (EVM) as
described in Section 11.5, “Enabling integrity measurement architecture and extended
verification module”.
Verify that the ima-evm-utils, attr, and keyutils packages are already installed:
Procedure
IMA and EVM ensure that the example file test_file is assigned hash values, which are stored as
its extended attributes.
114
CHAPTER 11. ENHANCING SECURITY WITH THE KERNEL INTEGRITY SUBSYSTEM
# getfattr -m . -d test_file
# file: test_file
security.evm=0sAnDIy4VPA0HArpPO/EqiutnNyBql
security.ima=0sAQOEDeuUnWzwwKYk+n66h/vby3eD
security.selinux="unconfined_u:object_r:admin_home_t:s0"
The previous example output shows extended attributes related to SELinux and the IMA and
EVM hash values. EVM actively adds a security.evm extended attribute and detects any offline
tampering to xattrs of other files such as security.ima that are directly related to content
integrity of files. The value of the security.evm field is in Hash-based Message Authentication
Code (HMAC-SHA1), which was generated with the evm-key user key.
Additional resources
For further information about general security concepts in Red Hat Enterprise Linux 8, see the
relevant sections of Security hardening.
For information about Integrity Measurement Architecture, see Section 11.2, “Integrity
measurement architecture”.
For information about Extended Verification Module, see Section 11.3, “Extended verification
module”.
For details about IMA and EVM see the official upstream wiki page .
Basic and advanced configuration of Security-Enhanced Linux (SELinux) describes the basic
principles of SELinux and documents in detail how to configure and use SELinux with various
services, such as the Apache HTTP Server.
115