Language and Page Formatting Options
Chapter 5. Manually upgrading the kernel
The Red Hat Enterprise Linux kernel is custom-built by the Red Hat Enterprise Linux kernel team to ensure its integrity and compatibility with supported hardware. Before Red Hat releases a kernel, it must first pass a rigorous set of quality assurance tests.
Red Hat Enterprise Linux kernels are packaged in the RPM format so that they are easy to upgrade and verify using the Yum or PackageKit package managers. PackageKit automatically queries the Red Hat Content Delivery Network servers and informs you of packages with available updates, including kernel packages.
This chapter is therefore only useful for users who need to manually update a kernel package using the
rpm command instead of
Whenever possible, use either the Yum or PackageKit package manager to install a new kernel because they always install a new kernel instead of replacing the current one, which could potentially leave your system unable to boot.
Custom kernels are not supported by Red Hat. However, guidance can be obtained from the solution article.
For more information on installing kernel packages with yum, see the relevant section in the System Administrator’s Guide.
For information on Red Hat Content Delivery Network, see the relevant section in the System Administrator’s Guide.
5.1. Overview of kernel packages
Red Hat Enterprise Linux contains the following kernel packages:
- kernel — Contains the kernel for single-core, multi-core, and multi-processor systems.
- kernel-debug — Contains a kernel with numerous debugging options enabled for kernel diagnosis, at the expense of reduced performance.
- kernel-devel — Contains the kernel headers and makefiles sufficient to build modules against the kernel package.
- kernel-debug-devel — Contains the development version of the kernel with numerous debugging options enabled for kernel diagnosis, at the expense of reduced performance.
kernel-doc — Documentation files from the kernel source. Various portions of the Linux kernel and the device drivers shipped with it are documented in these files. Installation of this package provides a reference to the options that can be passed to Linux kernel modules at load time.
By default, these files are placed in the
- 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.
- linux-firmware — Contains all of the firmware files that are required by various devices to operate.
- perf — This package contains the perf tool, which enables performance monitoring of the Linux kernel.
- kernel-abi-whitelists — Contains information pertaining to the Red Hat Enterprise Linux kernel ABI, including a lists of kernel symbols that are needed by external Linux kernel modules and a yum plug-in to aid enforcement.
- kernel-tools — Contains tools for manipulating the Linux kernel and supporting documentation.
5.2. Preparing to upgrade
Before upgrading the kernel, it is recommended that you take some precautionary steps.
First, ensure that working boot media exists for the system in case a problem occurs. If the boot loader is not configured properly to boot the new kernel, you can use this media to boot into Red Hat Enterprise Linux
USB media often comes in the form of flash devices sometimes called pen drives, thumb disks, or keys, or as an externally-connected hard disk device. Almost all media of this type is formatted as a
VFAT file system. You can create bootable USB media on media formatted as
You can transfer a distribution image file or a minimal boot media image file to USB media. Make sure that sufficient free space is available on the device. Around 4 GB is required for a distribution DVD image, around 700 MB for a distribution CD image, or around 10 MB for a minimal boot media image.
You must have a copy of the
boot.iso file from a Red Hat Enterprise Linux installation DVD, or installation CD-ROM #1, and you need a USB storage device formatted with the
VFAT file system and around 16 MB of free space.
For more information on using USB storage devices, review How to format a USB key and How to manually mount a USB flash drive in a non-graphical environment solution articles.
The following procedure does not affect existing files on the USB storage device unless they have the same path names as the files that you copy onto it. To create USB boot media, perform the following commands as the
Install the syslinux package if it is not installed on your system. To do so, as root, run the
yum install syslinuxcommand.
Install the SYSLINUX bootloader on the USB storage device:
# syslinux /dev/sdX1
…where sdX is the device name.
Create mount points for
boot.isoand the USB storage device:
# mkdir /mnt/isoboot /mnt/diskboot
# mount -o loop boot.iso /mnt/isoboot
Mount the USB storage device:
# mount /dev/sdX1 /mnt/diskboot
Copy the ISOLINUX files from the
boot.isoto the USB storage device:
# cp /mnt/isoboot/isolinux/* /mnt/diskboot
syslinux.cfgfile for the USB device:
# grep -v local /mnt/isoboot/isolinux/isolinux.cfg > /mnt/diskboot/syslinux.cfg
boot.isoand the USB storage device:
# umount /mnt/isoboot /mnt/diskboot
- Reboot the machine with the boot media and verify that you are able to boot with it before continuing.
Alternatively, on systems with a floppy drive, you can create a boot diskette by installing the mkbootdisk package and running the
mkbootdisk command as
man mkbootdisk man page after installing the package for usage information.
To determine which kernel packages are installed, execute the command
yum list installed "kernel-*" at a shell prompt. The output comprises some or all of the following packages, depending on the system’s architecture, and the version numbers might differ:
# yum list installed "kernel-*" kernel.x86_64 3.10.0-54.0.1.el7 @rhel7/7.0 kernel-devel.x86_64 3.10.0-54.0.1.el7 @rhel7 kernel-headers.x86_64 3.10.0-54.0.1.el7 @rhel7/7.0
From the output, determine which packages need to be downloaded for the kernel upgrade. For a single processor system, the only required package is the kernel package. See Section 5.1, “Overview of kernel packages” for descriptions of the different packages.
5.3. Downloading the upgraded kernel
There are several ways to determine if an updated kernel is available for the system.
- Security Errata — See Customer Portal for information on security errata, including kernel upgrades that fix security issues.
- The Red Hat Content Delivery Network — For a system subscribed to the Red Hat Content Delivery Network, the yum package manager can download the latest kernel and upgrade the kernel on the system. The Dracut utility creates an initial RAM file system image if needed, and configure the boot loader to boot the new kernel. For more information on installing packages from the Red Hat Content Delivery Network, see the relevant section of the System Administrator’s Guide. For more information on subscribing a system to the Red Hat Content Delivery Network, see the relevant section of the System Administrator’s Guide.
If yum was used to download and install the updated kernel from the Red Hat Network, follow the instructions in Section 5.5, “Verifying the initial RAM file system image” and Section 5.6, “Verifying the boot loader” only, do not change the kernel to boot by default. Red Hat Network automatically changes the default kernel to the latest version. To install the kernel manually, continue to Section 5.4, “Performing the upgrade”.
5.4. Performing the upgrade
After retrieving all of the necessary packages, it is time to upgrade the existing kernel.
It is strongly recommended that you keep the old kernel in case there are problems with the new kernel.
At a shell prompt, change to the directory that contains the kernel RPM packages. Use
-i argument with the
rpm command to keep the old kernel. Do not use the
-U option, since it overwrites the currently installed kernel, which creates boot loader problems. For example:
# rpm -ivh kernel-kernel_version.arch.rpm
The next step is to verify that the initial RAM file system image has been created. See Section 5.5, “Verifying the initial RAM file system image” for details.
5.5. Verifying the initial RAM file system image
The job of the initial RAM file system image is to preload the block device modules, such as for IDE, SCSI or RAID, so that the root file system, on which those modules normally reside, can then be accessed and mounted. On Red Hat Enterprise Linux 7 systems, whenever a new kernel is installed using either the Yum, PackageKit, or RPM package manager, the Dracut utility is always called by the installation scripts to create an initramfs (initial RAM file system image).
If you make changes to the kernel attributes by modifying the
/etc/sysctl.conf file or another
sysctl configuration file, and if the changed settings are used early in the boot process, then rebuilding the Initial RAM File System Image by running the
dracut -f command might be necessary. An example is if you have made changes related to networking and are booting from network-attached storage.
On all architectures other than IBM eServer System i (see the section called “Verifying the initial RAM file system image and kernel on IBM eServer System i”), you can create an
initramfs by running the
dracut command. However, you usually do not need to create an
initramfs manually: this step is automatically performed if the kernel and its associated packages are installed or upgraded from RPM packages distributed by Red Hat.
You can verify that an
initramfs corresponding to your current kernel version exists and is specified correctly in the
grub.cfg configuration file by following this procedure:
Verifying the initial RAM file system image
root, list the contents in the
/bootdirectory and find the kernel (
initramfs-kernel_versionwith the latest (most recent) version number:
Example 5.1. Ensuring that the kernel and initramfs versions match
# ls /boot config-3.10.0-67.el7.x86_64 config-3.10.0-78.el7.x86_64 efi grub grub2 initramfs-0-rescue-07f43f20a54c4ce8ada8b70d33fd001c.img initramfs-3.10.0-67.el7.x86_64.img initramfs-3.10.0-67.el7.x86_64kdump.img initramfs-3.10.0-78.el7.x86_64.img initramfs-3.10.0-78.el7.x86_64kdump.img initrd-plymouth.img symvers-3.10.0-67.el7.x86_64.gz symvers-3.10.0-78.el7.x86_64.gz System.map-3.10.0-67.el7.x86_64 System.map-3.10.0-78.el7.x86_64 vmlinuz-0-rescue-07f43f20a54c4ce8ada8b70d33fd001c vmlinuz-3.10.0-67.el7.x86_64 vmlinuz-3.10.0-78.el7.x86_64
we have three kernels installed (or, more correctly, three kernel files are present in the
the latest kernel is
initramfsfile matching our kernel version,
initramfs-3.10.0-78.el7.x86_64kdump.img, also exists.Important
/bootdirectory you might find several
initramfs-kernel_versionkdump.imgfiles. These are special files created by the Kdump mechanism for kernel debugging purposes, are not used to boot the system, and can safely be ignored. For more information on
kdump, see the Red Hat Enterprise Linux 7 Kernel Crash Dump Guide.
- we have three kernels installed (or, more correctly, three kernel files are present in the
initramfs-kernel_versionfile does not match the version of the latest kernel in the
/bootdirectory, or, in certain other situations, you might need to generate an
initramfsfile with the Dracut utility. Simply invoking
rootwithout options causes it to generate an
/bootfor the latest kernel present in that directory:
You must use the
--forceoption if you want
dracutto overwrite an existing
initramfs(for example, if your
initramfshas become corrupt). Otherwise
dracutrefuses to overwrite the existing
# dracut Does not override existing initramfs (/boot/initramfs-3.10.0-78.el7.x86_64.img) without --force
You can create an initramfs in the current directory by calling
dracut initramfs_name kernel_version:
# dracut "initramfs-$(uname -r).img" $(uname -r)
If you need to specify specific kernel modules to be preloaded, add the names of those modules (minus any file name suffixes such as
.ko) inside the parentheses of the
add_dracutmodules+="module more_modules "directive of the
/etc/dracut.confconfiguration file. You can list the file contents of an
initramfsimage file created by dracut by using the
# lsinitrd /boot/initramfs-3.10.0-78.el7.x86_64.img Image: /boot/initramfs-3.10.0-78.el7.x86_64.img: 11M ======================================================================== dracut-033-68.el7 ======================================================================== drwxr-xr-x 12 root root 0 Feb 5 06:35 . drwxr-xr-x 2 root root 0 Feb 5 06:35 proc lrwxrwxrwx 1 root root 24 Feb 5 06:35 init -> /usr/lib/systemd/systemd drwxr-xr-x 10 root root 0 Feb 5 06:35 etc drwxr-xr-x 2 root root 0 Feb 5 06:35 usr/lib/modprobe.d [output truncated]
man dracut.conffor more information on options and usage.
/boot/grub2/grub.cfgconfiguration file to ensure that an
initramfs-kernel_version.imgfile exists for the kernel version you are booting. For example:
# grep initramfs /boot/grub2/grub.cfg initrd16 /initramfs-3.10.0-123.el7.x86_64.img initrd16 /initramfs-0-rescue-6d547dbfd01c46f6a4c1baa8c4743f57.img
See Section 5.6, “Verifying the boot loader” for more information.
Verifying the initial RAM file system image and kernel on IBM eServer System i
On IBM eServer System i machines, the initial RAM file system and kernel files are combined into a single file, which is created with the
addRamDisk command. This step is performed automatically if the kernel and its associated packages are installed or upgraded from the RPM packages distributed by Red Hat thus, it does not need to be executed manually. To verify that it was created, run the following command as
root to make sure the
/boot/vmlinitrd-kernel_version file already exists:
# ls -l /boot/
The kernel_version needs to match the version of the kernel just installed.
Reversing the changes made to the initial RAM file system image
In some cases, for example, if you misconfigure the system and it no longer boots, you need to reverse the changes made to the Initial RAM File System Image by following this procedure:
Reversing Changes Made to the Initial RAM File System Image
- Reboot the system choosing the rescue kernel in the GRUB menu.
Change the incorrect setting that caused the
initramfswith the correct settings by running the following command as root:
# dracut --kver kernel_version --force
The above procedure might be useful if, for example, you incorrectly set the
vm.nr_hugepages in the
sysctl.conf file. Because the
sysctl.conf file is included in
initramfs, the new
vm.nr_hugepages setting gets applied in
initramfs and causes rebuilding of the
initramfs. However, because the setting is incorrect, the new
initramfs is broken and the newly built kernel does not boot, which necessitates correcting the setting using the above procedure.
Listing the contents of the initial RAM file system image
To list the files that are included in the
initramfs, run the following command as root:
To only list files in the
/etc directory, use the following command:
# lsinitrd | grep etc/
To output the contents of a specific file stored in the
initramfs for the current kernel, use the
# lsinitrd -f filename
For example, to output the contents of
sysctl.conf, use the following command:
# lsinitrd -f /etc/sysctl.conf
To specify a kernel version, use the
# lsinitrd --kver kernel_version -f /etc/sysctl.conf
For example, to list the information about kernel version 3.10.0-327.10.1.el7.x86_64, use the following command:
# lsinitrd --kver 3.10.0-327.10.1.el7.x86_64 -f /etc/sysctl.conf
5.6. Verifying the boot loader
You can install a kernel either with the
yum command or with the
When you install a kernel using
rpm, the kernel package creates an entry in the boot loader configuration file for that new kernel.
Note that both commands configure the new kernel to boot as the default kernel only when you include the following setting in the
/etc/sysconfig/kernel configuration file:
DEFAULTKERNEL option specifies the default kernel package type. The
UPDATEDEFAULT option specifies whether the new kernel package makes the new kernels the default.