CentOS 7
    • PDF

    CentOS 7

    • PDF

    Article Summary

    Available in VPC

    This guide describes how to update a kernel on the CentOS 7 server of NAVER Cloud Platform.

    This guide is written based on new servers created on NAVER Cloud Platform, so there might be differences from the user server environment. User server environments may be affected by kernel updates and server restarts due to various reasons such as security hardening operations and various setting operations. Therefore, check the following before you perform a kernel update.

    • Create a replicated server using Server image before updating a kernel of the actual server. Perform the kernel update on the replicated server and check if it restarts normally. When switching to operational status after restarting, check for any issues in the server. Proceed with the server kernel update only when no issues were found after through validation.
    • In the case of GPU servers, the GPU driver that matches the kernel version must be installed for normal operation. If the updated kernel isn't compatible with GPU drivers, the GPU server might not function normally. Therefore, check GPU driver compatibility before you perform kernel updates. For related information, see GPU driver guide.
    • NCP Repo is a repository provided by NAVER Cloud Platform to support user environments where external access is limited, such as VPC private subnet. NCP Repo may not provide the latest package.
    Note

    NAVER Cloud Platform has not tested all kernel versions after each update. As of January 1, 2024, the kernel version tested on CentOS 7 is 3.10.0-1160.102.1.el7.x86_64.

    Caution
    • The user is entirely responsible for performing user's server kernel updates. NAVER Cloud Platform does not take responsibility for issues caused by kernel updates.
    • Normal server usage might be unavailable during kernel updates and restart, and recovery due to this is not supported. In addition, server recovery is not supported when the kernel update fails.
    • Before updating the kernel, be sure to keep the backup created through Server image until it is no longer needed.
    • No separate support is provided for problems related to this guide.

    Update kernel

    To update kernels for CentOS 7.3 and CentOS 7.8 servers, do the following:

    1. Connect to the server you want to apply the kernel update to remotely.

    2. Check the kernel version of the server.

      • CentOS 7.3
      [root@centos73 ~]# uname -r
      3.10.0-514.2.2.el7.x86_64
      
      • CentOS 7.8
      [root@centos78 ~]# uname -r
      3.10.0-1127.10.1.el7.x86_64
      
    3. Check the repository information connected to the server.

      [root@centos78 ~]# grep ^baseurl /etc/yum.repos.d/CentOS-Base.repo
      baseurl=http://mirror.ncloud.com/centos/$releasever/os/$basearch
      baseurl=http://mirror.ncloud.com/centos/$releasever/updates/$basearch/
      baseurl=http://mirror.ncloud.com/centos/$releasever/extras/$basearch/
      baseurl=http://mirror.ncloud.com/centos/$releasever/centosplus/$basearch/
      baseurl=http://mirror.ncloud.com/centos/$releasever/contrib/$basearch/
      
    4. Download the Repo file using yum-config-manager.

      • CentOS 7.3
        To be able to use yum-config-manager, install the yum-utils package first and download the Repo file.
      [root@centos73 ~]# rpm -qa | grep yum-utils | wc -l
      0
      
      [root@centos73 ~]# yum install yum-utils
      Loaded plugins: fastestmirror
      Determining fastest mirrors
      Resolving Dependencies
      --> Running transaction check
      ---> Package yum-utils.noarch 0:1.1.31-54.el7_8 will be installed
      --> Processing Dependency: python-kitchen for package: yum-utils-1.1.31-54.el7_8.noarch
      --> Running transaction check
      ---> Package python-kitchen.noarch 0:1.1.1-5.el7 will be installed
      --> Processing Dependency: python-chardet for package: python-kitchen-1.1.1-5.el7.noarch
      --> Running transaction check
      ---> Package python-chardet.noarch 0:2.2.1-3.el7 will be installed
      --> Finished Dependency Resolution
      
      Dependencies Resolved
      
      =================================================================================================================================================================================================
       Package                                           Arch                                      Version                                               Repository                               Size
      =================================================================================================================================================================================================
      Installing:
       yum-utils                                         noarch                                    1.1.31-54.el7_8                                       base                                    122 k
      Installing for dependencies:
       python-chardet                                    noarch                                    2.2.1-3.el7                                           base                                    227 k
       python-kitchen                                    noarch                                    1.1.1-5.el7                                           base                                    267 k
      
      Transaction Summary
      =================================================================================================================================================================================================
      Install  1 Package (+2 Dependent packages)
      
      Total download size: 616 k
      Installed size: 2.8 M
      Is this ok [y/d/N]: y
      
      ... Omitted...
      
      Installed:
        yum-utils.noarch 0:1.1.31-54.el7_8                                                                                                                                                            
      
      Dependency Installed:
        python-chardet.noarch 0:2.2.1-3.el7                                                             python-kitchen.noarch 0:1.1.1-5.el7                                                           
      
      Complete!
      
      [root@centos73 ~ ]# yum-config-manager --add-repo http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo
      Loaded plugins: fastestmirror
      adding repo from: http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo
      grabbing file http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo to /etc/yum.repos.d/CentOS-Base.repo
      repo saved to /etc/yum.repos.d/CentOS-Base.repo
      
      • CentOS 7.8
      [root@centos78 ~ ]# yum-config-manager --add-repo http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo
      Loaded plugins: fastestmirror, langpacks
      adding repo from: http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo
      grabbing file http://init.ncloud.com/server/linux/repo/centos7/CentOS-Base.repo to /etc/yum.repos.d/CentOS-Base.repo
      repo saved to /etc/yum.repos.d/CentOS-Base.repo
      
    5. Check the changed repository information.

      [root@centos78 ~ ]# grep ^baseurl /etc/yum.repos.d/CentOS-Base.repo
      baseurl=http://repo.ncloud.com/centos/$releasever/os/$basearch
      baseurl=http://repo.ncloud.com/centos/$releasever/updates/$basearch/
      baseurl=http://repo.ncloud.com/centos/$releasever/extras/$basearch/
      baseurl=http://repo.ncloud.com/centos/$releasever/centosplus/$basearch/
      baseurl=http://repo.ncloud.com/centos/$releasever/contrib/$basearch/
      
    6. Check the kernel version provided by the repository.

      [root@centos78 ~ ]# rm -rf /var/cache/yum/*
      
      [root@centos78 ~ ]# yum list kernel-3.10.0-1160.102.1.el7
      Loaded plugins: fastestmirror, langpacks
      Loading mirror speeds from cached hostfile
      Available Packages
      kernel.x86_64                                                                  3.10.0-1160.102.1.el7                                                                  update    
      
    7. Install the latest version of the kernel.
      Carefully review the list of packages being newly installed, updated, or removed. If everything is in order, enter y to complete the installation.

      • CentOS 7.3
      [root@centos73 ~ ]# yum install kernel-3.10.0-1160.102.1.el7
      Loaded plugins: fastestmirror
      Loading mirror speeds from cached hostfile
      Resolving Dependencies
      --> Running transaction check
      ---> Package kernel.x86_64 0:3.10.0-1160.102.1.el7 will be installed
      --> Processing Dependency: linux-firmware >= 20190429-72 for package: kernel-3.10.0-1160.102.1.el7.x86_64
      --> Running transaction check
      
      ... Omitted...
      
      Dependencies Resolved
      
      ============================================================================================================================================================================
       Package                                         Arch                           Version                                                Repository                      Size
      ============================================================================================================================================================================
      Installing:
       kernel                                          x86_64                         3.10.0-1160.102.1.el7                                  update                          52 M
      Updating:
       kexec-tools                                     x86_64                         2.0.15-51.el7_9.3                                      update                         351 k
       selinux-policy-targeted                         noarch                         3.13.1-268.el7_9.2                                     update                         7.0 M
      Updating for dependencies:
       libselinux                                      x86_64                         2.5-15.el7                                             base                           162 k
       libselinux-devel                                x86_64                         2.5-15.el7                                             base                           187 k
       libselinux-python                               x86_64                         2.5-15.el7                                             base                           236 k
       libselinux-utils                                x86_64                         2.5-15.el7                                             base                           151 k
       libsemanage                                     x86_64                         2.5-14.el7                                             base                           151 k
       libsepol                                        x86_64                         2.5-10.el7                                             base                           297 k
       libsepol-devel                                  x86_64                         2.5-10.el7                                             base                            77 k
       linux-firmware                                  noarch                         20200421-80.git78c0348.el7_9                           update                          80 M
       policycoreutils                                 x86_64                         2.5-34.el7                                             base                           917 k
       selinux-policy                                  noarch                         3.13.1-268.el7_9.2                                     update                         498 k
      
      Transaction Summary
      ============================================================================================================================================================================
      Install  1 Package
      Upgrade  2 Packages (+10 Dependent packages)
      
      Total download size: 142 M
      Is this ok [y/d/N]: y
      
      ... Omitted...
      
      Installed:
        kernel.x86_64 0:3.10.0-1160.102.1.el7                                                                                                                                    
      
      Updated:
        kexec-tools.x86_64 0:2.0.15-51.el7_9.3                                         selinux-policy-targeted.noarch 0:3.13.1-268.el7_9.2                                       
      
      Dependency Updated:
        libselinux.x86_64 0:2.5-15.el7      libselinux-devel.x86_64 0:2.5-15.el7       libselinux-python.x86_64 0:2.5-15.el7 libselinux-utils.x86_64 0:2.5-15.el7               
        libsemanage.x86_64 0:2.5-14.el7     libsepol.x86_64 0:2.5-10.el7               libsepol-devel.x86_64 0:2.5-10.el7    linux-firmware.noarch 0:20200421-80.git78c0348.el7_9
        policycoreutils.x86_64 0:2.5-34.el7 selinux-policy.noarch 0:3.13.1-268.el7_9.2
      
      Complete!
      
      • CentOS 7.8
      [root@centos78 ~ ]# yum install kernel-3.10.0-1160.102.1.el7
      Loaded plugins: fastestmirror, langpacks
      Loading mirror speeds from cached hostfile
      Resolving Dependencies
      --> Running transaction check
      ---> Package kernel.x86_64 0:3.10.0-1160.102.1.el7 will be installed
      --> Finished Dependency Resolution
      
      Dependencies Resolved
      
      ============================================================================================================================================================================
       Package                              Arch                                 Version                                               Repository                            Size
      ============================================================================================================================================================================
      Installing:
       kernel                               x86_64                               3.10.0-1160.102.1.el7                                 update                                52 M
      
      Transaction Summary
      ============================================================================================================================================================================
      Install  1 Package
      
      Total download size: 52 M
      Installed size: 66 M
      Is this ok [y/d/N]: y
      
      ... Omitted...
      
      Installed:
        kernel.x86_64 0:3.10.0-1160.102.1.el7                                                                                                                                    
      
      Complete!
      
    8. After the installation is complete, check the bootable kernel version and the default boot kernel version.

      • CentOS 7.3
      [root@centos73 ~ ]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
      CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
      CentOS Linux (0-rescue-7b63677441464f9a89b04041488122e0) 7 (Core)
      
      [root@centos73 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      
      • CentOS 7.8
      [root@centos78 ~ ]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
      CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)
      CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core)
      
      [root@centos78 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      
      Note

      If the installed kernel version does not appear, use the grub2-mkconfig command to recreate grub.cfg.

    # grub2-mkconfig -o /boot/grub2/grub.cfg

    :::

    1. If the default boot kernel version is different from the installed kernel version, change the default boot kernel.

      [root@centos78 ~ ]# ls -ld /etc/grub2*
      lrwxrwxrwx. 1 root root 22 Aug 31  2020 /etc/grub2.cfg -> ../boot/grub2/grub.cfg
      
      [root@centos78 ~ ]# grub2-mkconfig -o /etc/grub2.cfg
      Generating grub configuration file ...
      Found linux image: /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img
      Found linux image: /boot/vmlinuz-3.10.0-1127.10.1.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-1127.10.1.el7.x86_64.img
      Found linux image: /boot/vmlinuz-3.10.0-1127.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-1127.el7.x86_64.img
      Found linux image: /boot/vmlinuz-0-rescue-aaaeb22f90c34b3e90e68880b8553310
      Found initrd image: /boot/initramfs-0-rescue-aaaeb22f90c34b3e90e68880b8553310.img
      done
      
      [root@centos78 ~ ]# grub2-set-default "CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)"
      
      [root@centos78 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      
      Note

      To boot with a non-default kernel, change the kernel from the grub page when booting. If the wait time of the CentOS 7.3 grub page is short, see Extend wait time of CentOS 7.3 grub page to extend the wait time.

    2. Reboot the server to activate the installed kernel version.

      [root@centos78 ~ ]# reboot
      
      Note

      If the server reboot fails, it means the kernel update was not performed normally. In this case, see Restore kernel update to revert to the previous kernel version.

    3. Log in to the server again and check if the new kernel is activated.

      • CentOS 7.3
      [root@centos73 ~ ]# uname -r
      3.10.0-1160.102.1.el7.x86_64
      
      • CentOS 7.8
      [root@centos78 ~ ]# uname -r
      3.10.0-1160.102.1.el7.x86_64
      
      Note

      To check if the updated kernel is properly applied, see Checking kernel updates to check the kernel installation status.

    Extend wait time of CentOS 7.3 grub page

    To extend the wait time of the CentOS 7.3 grub page, do the following:

    1. Check the grub configuration file before you boot the server.
      [root@centos73 ~ ]# grep GRUB_TIMEOUT /etc/default/grub
      GRUB_TIMEOUT=5
      
    2. Change the grub default configuration file and regenerate the grub.cfg file.
      [root@centos73 ~ ]# sed -i "s/GRUB_TIMEOUT=5/GRUB_TIMEOUT=30/" /etc/default/grub
      
      [root@centos73 ~ ]# grep GRUB_TIMEOUT /etc/default/grub
      GRUB_TIMEOUT=30
      
      [root@centos73 ~ ]# grub2-mkconfig -o /etc/grub2.cfg
      Generating grub configuration file ...
      Found linux image: /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img
      Found linux image: /boot/vmlinuz-3.10.0-514.2.2.el7.x86_64
      Found initrd image: /boot/initramfs-3.10.0-514.2.2.el7.x86_64.img
      Found linux image: /boot/vmlinuz-0-rescue-7b63677441464f9a89b04041488122e0
      Found initrd image: /boot/initramfs-0-rescue-7b63677441464f9a89b04041488122e0.img
      done    
      

    Check kernel update

    To check if the kernel update is applied normally, follow these steps:

    1. Connect to the server remotely.
    2. Check if the kernel package is installed.
      [root@centos78 ~ ]# rpm -qa | grep kernel-3.10.0-1160.102.1.el7.x86_64
      kernel-3.10.0-1160.102.1.el7.x86_64
      
    3. Check if the initramfs file and vmlinuz file are created in the /boot directory.
      [root@centos78 ~ ]# ls -l /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img
      -rw------- 1 root root 21897039 Dec  4 11:00 /boot/initramfs-3.10.0-1160.102.1.el7.x86_64.img
      
      [root@centos78 ~ ]# ls -l /boot/initramfs-3.10.0-1160.102.1.el7.x86_64kdump.img
      -rw------- 1 root root 20211564 Dec  4 11:10 /boot/initramfs-3.10.0-1160.102.1.el7.x86_64kdump.img
      
      [root@centos78 ~ ]# ls -l /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64
      -rwxr-xr-x 1 root root 7051880 Oct 18 00:46 /boot/vmlinuz-3.10.0-1160.102.1.el7.x86_64
      
    4. Check if the latest kernel settings are registered in the grub.cfg file.
      [root@centos78 ~ ]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
      CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)
      CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core)
      
    5. Check the grub settings.
      [root@centos78 ~ ]# grep GRUB_DEFAULT /etc/default/grub
      GRUB_DEFAULT=saved
      
      [root@centos78 ~ ]# cat /boot/grub2/grubenv
      # GRUB Environment Block
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      ... Omitted...
      

    Restore kernel update

    If you can't restart the server normally after a kernel update, you need to revert to the previous kernel before the update. You can revert it to one of the many installed kernel versions. This guide deals with how to revert the kernel to the version immediately before the update.

    To restore the kernel version, follow these steps:

    Note

    To resolve server restart issues, you can attempt server recovery by entering single mode. For how to run reboot in Single Mode, see Server recovery guide.

    1. Click the environment you are using in the Region menu and the Platform menu on the NAVER Cloud Platform console.

    2. Click Services > Compute > Server, in order.

    3. Click the Server menu.

    4. Select the server to recover from the server image list, and then click the [Server connection console] button.

    5. Select the previous version as the booting kernel from the grub booting page and reboot.

      • CentOS 7.3 grub boot page
        kernel-update-centos73_console01

      • CentOS 7.8 grub boot page
        kernel-update-centos78_console01

    6. After booting is complete, check the server kernel version.

      • CentOS 7.3
      [root@centos73 ~ ]# uname -r
      3.10.0-514.2.2.el7.x86_64
      
      • CentOS 7.8
      [root@centos78 ~ ]# uname -r
      3.10.0-1127.10.1.el7.x86_64
      
    7. Check the kernel version that is currently active.

      • CentOS 7.3
      [root@centos73 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      
      [root@centos73 ~ ]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
      CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
      CentOS Linux (0-rescue-7b63677441464f9a89b04041488122e0) 7 (Core)
      
      • CentOS 7.8
      [root@centos78 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      
      [root@centos78 ~ ]# grep ^menuentry /boot/grub2/grub.cfg | cut -d "'" -f2
      CentOS Linux (3.10.0-1160.102.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
      CentOS Linux (3.10.0-1127.el7.x86_64) 7 (Core)
      CentOS Linux (0-rescue-aaaeb22f90c34b3e90e68880b8553310) 7 (Core)
      
    8. Reset the default kernel version to the previous kernel version when booting.

      • CentOS 7.3
      [root@centos73 ~ ]# grub2-set-default "CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)"
      
      [root@centos73 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-514.2.2.el7.x86_64) 7 (Core)
      
      • CentOS 7.8
      [root@centos78 ~ ]# grub2-set-default "CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)"
      
      [root@centos78 ~ ]# grub2-editenv list
      saved_entry=CentOS Linux (3.10.0-1127.10.1.el7.x86_64) 7 (Core)
      
      Note

      You must change the default booting kernel when restoring the kernel because the default booting kernel settings were changed when updating to the latest kernel version. Otherwise, the server boots into the problematic kernel version on the next boot.

    9. (Optional) Reboot the server to check whether the server boots up normally with the updated kernel version.

      [root@centos78 ~ ]# reboot
      
    10. (Optional) Log back into the server to check the booting status and the kernel version.

      • CentOS 7.3
      [root@centos73 ~ ]# uname -r
      3.10.0-514.2.2.el7.x86_64
      
      • CentOS 7.8
      [root@centos78 ~ ]# uname -r
      3.10.0-1127.10.1.el7.x86_64
      

    Was this article helpful?

    What's Next
    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.