Skip to main content

CentOS Kernel Upgrade

RedHat KB: CHAPTER 5. MANUALLY UPGRADING THE KERNEL

Kernel Packages

CentOS/RedHat Linux 與 kernel 升級相關的套件清單

  • 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 /usr/share/doc/kernel-doc-kernel_version/ directory.
  • 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.
Preparing  to upgrade
# Current kernel running
uname -a
# Grub2 Info for syatem booting
awk -F\' '$1=="menuentry " {print $2}' /boot/grub2/grub.cfg

grub2-editenv list

# Current kernel packages installed
rpm -qa | grep kernel
# Or
yum list installed "kernel-*"
Downloading the upgraded kernel

RedHat Custom Portal 網站下載新版的 kernel 套件 

  1. kernel-3.10.0-1062.el7.x86_64.rpm
  2. linux-firmware-20190429-72.gitddde598.el7.noarch.rpm  (這是第一項安裝的相依性檔案)
Performing the upgrade

升級 kernel 時,系統會自動使用 Dracut 工具來建立新的 initialRAM file system 開機用映像檔。請確定 Dracut 已經有安裝。

升級 kernel

# 先升級 linux-firmware
# NOTE: 安裝指令不能使用 -ivh
rpm -Uvh linux-firmware-20190429-72.gitddde598.el7.noarch.rpm

# 再升級 kernel
# NOTE: 安裝時不要使用 -Uvh 
rpm -ivh kernel-3.10.0-1062.el7.x86_64.rpm
其他指令

安裝新 kernel 後會作為下一次開機的預設選單,設定檔在 /etc/sysconfig/kernel

# UPDATEDEFAULT specifies if new-kernel-pkg should make
# new kernels the default
UPDATEDEFAULT=yes

# DEFAULTKERNEL specifies the default kernel package type
DEFAULTKERNEL=kernel

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:
lsinitrd

# 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 -f option:
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 --kver option:
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

Reversing Changes Made to the Initial RAM File System Image

如果需要手動重建 initialramfs file 時:

  1. Reboot the system choosing the rescue kernel in the GRUB menu.
  2. Change the incorrect setting that caused the initramfs to malfunction.
  3. Recreate the initramfs with the correct settings by running the following command as root:
dracut --kver <kernel_version> --force
FAQ

 linux-firmware package files conflicts

 Solution:

 

# 
FAQ
Install kernel rpm -ivh kernel-3.10.0-1062.el7.x86_64.rpm warning: kernel-3.10.0-1062.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: linux-firmware >= 20190429-72 is needed by kernel-3.10.0-1062.el7.x86_64 # Install linux-firmware rpm -ivh linux-firmware-20190429-72.gitddde598.el7.noarch.rpm kernel-3.10.0-1062.el7.x86_64.rpm warning: linux-firmware-20190429-72.gitddde598.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY warning: kernel-3.10.0-1062.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] file /usr/lib/firmware/amd-ucode/microcode_amd_fam17h.bin from install of linux-firmware-20190429-72.gitddde598.el7.noarch conflicts with file from package linux-firmware-20180911-69.git85c5d90.el7.noarch file /usr/lib/firmware/amd-ucode/microcode_amd_fam17h.bin.asc from install of linux-firmware-20190429-72.gitddde598.el7.noarch conflicts with file from package linux-firmware-20180911-69.git85c5d90.el7.noarch # Solution: using -Uvh to upgrade the linux-firmware rpm -Uvh linux-firmware-20190429-72.gitddde598.el7.noarch.rpm rpm -ivh kernel-3.10.0-1062.el7.x86_64.rpm