Help Center> Bare Metal Server> FAQs> OS FAQ> How Do I Change the Kernel Version of CentOS 7 BMSs?
Updated on 2022-07-13 GMT+08:00

How Do I Change the Kernel Version of CentOS 7 BMSs?

Scenarios

Some special software runs properly only on specified Linux kernel versions. This section describes how to change the kernel version.

Solution

  1. Log in to the BMS OS.
  2. Run the following command to check the current kernel version:

    uname -r

    [root@xxxxxx~]# uname -r
    3.10.0-327.22.2.el7.x86_64
  3. Run the following command to check the number of kernels in the OS:

    cat /boot/grub2/grub.cfg | grep menuentry

    [root@xxxxxx~]# cat /boot/grub2/grub.cfg | grep menuentry
    if [ x"${feature_menuentry_id}" = xy ]; then
      menuentry_id_option="--id"
      menuentry_id_option=""
    export menuentry_id_option
    menuentry ´CentOS Linux (3.10.0-327.22.2.el7.x86_64) 7 (Core)´ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ´gnulinux-3.10.0-327.el7.x86_64-advanced-80b9b662-0a1d-4e84-b07b-c1bf19e72d97´ {
    menuentry ´CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)´ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ´gnulinux-3.10.0-327.el7.x86_64-advanced-80b9b662-0a1d-4e84-b07b-c1bf19e72d97´ {
    menuentry ´CentOS Linux (0-rescue-7d26c16f128042a684ea474c9e2c240f) 7 (Core)´ --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option ´gnulinux-0-rescue-7d26c16f128042a684ea474c9e2c240f-advanced-80b9b662-0a1d-4e84-b07b-c1bf19e72d97´ {
  4. Run the following command to set the kernel that is started by default, for example, CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core):

    grub2-set-default "CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)"

  5. Run the following command to check the kernel that is started by default:

    grub2-editenv list

    [root@xxxxxx~]# grub2-editenv list 
    saved_entry=CentOS Linux (3.10.0-327.el7.x86_64) 7 (Core)
  6. Restart the BMS, enter its OS, and run the command in step 2 to check whether the kernel has been changed.
    [root@xxxxxx~]# uname -r
    3.10.0-327.el7.x86_64

OS FAQ FAQs

more