You need to enable JavaScript to run this app.
Elastic Compute Service

Elastic Compute Service

Copy page
Download PDF
Kernel fine-tuning
Upgrading kernel version of Linux operating system
Copy page
Download PDF
Upgrading kernel version of Linux operating system
If the kernel of the server operating system cannot meet your business needs, you can upgrade the kernel version, which can meet business requirements with less impact (compared with changing the operating system).​
Applicable scenario​
  • Improve system performance​
  • New kernel versions may provide performance optimizations, for example, faster file system operations, lower latency, or higher throughput.​
  • Support new hardware devices​
  • When the server is equipped with a new hardware device that is not supported by the current kernel, it may be necessary to upgrade the kernel to support the new hardware.​
  • Fix security vulnerabilities​
  • New kernel versions may fix some security vulnerabilities found in older kernel versions.​
  • Obtain support for more features​
  • New kernel versions may introduce new features, such as new file systems, virtualization technologies, and containerization capabilities.​
Usage notes​
  • Upgrading the system kernel may lead to compatibility, stability, and security issues. We recommend that you back up data before you upgrade the kernel.​
  • Kernel upgrade actions require root permission.​
CentOS OS​
​
Upgrade the minor version of the kernel
Upgrade the major version of the kernel
​
If you only need to upgrade the minor version of the kernel, you can use the official Yum repository.​
tip​
In the example provided in this section, the CentOS 7.9 kernel version is upgraded from 3.10.0-1160.102.1.el7 to 3.10.0-1160.119.1.​
  1. Execute the following command to view the current kernel version.​
  • ​
    uname -r​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to upgrade the system package list.​
  • ​
    sudo yum makecache​
    ​
  1. Execute the following command to view the installable kernel versions.​
  • ​
    sudo yum list kernel --showduplicates​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to install the specified version of the kernel.​
  • ​
    sudo yum install kernel-3.10.0-1160.119.1.el7 -y​
    ​
tip​
Replace 3.10.0-1160.119.1.el7 with the actual kernel version.​
  1. Update boot configuration.​
  • BIOS boot mode:​
  • ​
    grub2-mkconfig -o /boot/grub2/grub.cfg​
    ​
  • UEFI boot mode:​
  • ​
    grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg​
    ​
  1. Execute the following command to view the installed kernels.​
  • BIOS boot mode:​
  • ​
    awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub2/grub.cfg​
    ​
  • UEFI boot mode:​
  • ​
    awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/efi/EFI/centos/grub.cfg​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to specify the default kernel.​
  • ​
    sudo grub2-set-default 0​
    ​
tip​
Replace 0 with the serial number of the installed kernel that you obtained in Step 7.​
​​​
  1. Execute the following command to restart the instance.​
  • ​
    sudo reboot​
    ​
  1. Execute the following command to view the current kernel version and check whether the kernel is upgraded.​
  • ​
    uname -r​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to install the kernel software packages related to the new kernel.​
  • ​
    yum install kernel-devel kernel-headers kernel-modules-extra kernel-tools kernel-tools-libs kernel-tools-libs-devel -y​
    ​
  • Sample output:​
  • ​​​
warning​
If the required version of kernel-headers, kernel-devel, etc., is not available in the Yum repository. You can download and install them yourself:​
  1. Download the target software packages. One option is to download them from the Tsinghua University Mirror Site.​
  1. Upload the software packages to the target instance. Learn more.​
  1. Execute the rpm -ivh <RPM package to be installed> command to install the target software package.​
​
Ubuntu OS​
In this section, the operation of upgrading the Ubuntu 22.04 kernel version from 5.15.0-91-generic to 6.8.0-56-generic is used as an example.​
  1. Execute the following command to view the current kernel version.​
  • ​
    uname -r​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to update the system software package list.​
  • ​
    sudo apt update​
    ​
  1. Execute the following command to view the installable kernel versions.​
  • ​
    apt-cache search linux-image​
    ​
  • Sample output:​
  • ​​​
  1. Install the specified kernel version.​
  1. Execute the following command to install the specified version of the kernel.​
  • ​
    sudo apt install linux-image-6.8.0-56-generic -y​
    ​
tip​
Please replace 6.8.0-56-generic with the actual kernel version.​
  1. Press Enter to confirm new kernel information.​
  • ​​​
  1. Install kernel packages required by the new kernel.​
  1. Execute the following command to install kernel packages required by the new kernel.​
  • ​
    apt install linux-headers-6.8.0-56-generic linux-modules-extra-6.8.0-56-generic linux-generic -y​
    ​
tip​
Please replace 6.8.0-56-generic with the actual kernel version.​
  1. Press the Enter key to confirm the new kernel information.​
  • ​​​
  1. Execute the following command to forcibly update Initramfs.​
  • ​
    sudo update-initramfs -u -k 6.8.0-56-generic​
    ​
tip​
Please replace 6.8.0-56-generic with the actual kernel version.​
  1. Execute the following command to update the GRUB configuration file.​
  • BIOS boot mode:​
  • ​
    sudo grub-mkconfig -o /boot/grub/grub.cfg​
    ​
  • UEFI boot mode​
  • ​
    sudo [ -d /boot/efi/EFI/ubuntu ] && sudo grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg​
    ​
  1. Edit the default kernel.​
  1. Execute the following command to view the serial numbers of installed kernels.​
  • ​
    grep menuentry /boot/grub/grub.cfg​
    ​
  • When the following appears, it means that 6.8.0-56-generic, 5.15.0-135-generic, and 5.15.0-91-generic kernels have been installed. Their order is arranged from top to bottom, with the serial numbers starting from0, i.e., 6.8.0-56-generic serial number is 0, 5.15.0-135-generic serial number is 1, and 5.15.0-91-generic serial number is 2.​
  • ​​​
  1. Execute the following command to open the GRUB file.​
  • ​
    vim /etc/default/grub​
    ​
  1. Please replace the GRUB_DEFAULT argument value with the target kernel number.​
  • ​​​
  1. Press the Esc key to exit edit mode, enter :wq, and then press Enter to save the changes and exit the file.​
  1. Execute the following command to update the GRUB configuration file.​
  • ​
    sudo update-grub​
    ​
  1. Execute the following command to restart the instance.​
  • ​
    sudo reboot​
    ​
  1. Execute the following command to check whether the kernel is upgraded.​
  • ​
    uname -r​
    ​
  • The callback shown below indicates that the kernel version has been successfully upgraded to 6.8.0-56-generic.​
  • ​​​
Debian OS​
This section uses the example of upgrading the kernel version of Debian 12 from 6.1.0-18-amd64 to 6.1.0-31-amd64.​
  1. Execute the following command to view the current kernel version.​
  • ​
    uname -r​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to update the system software package list.​
  • ​
    sudo apt update​
    ​
  1. Execute the following command to view the installable kernel versions.​
  • ​
    apt-cache search linux-image​
    ​
  • Sample output:​
  • ​​​
  1. Execute the following command to install the specified version of the kernel.​
  • ​
    sudo apt install linux-image-6.1.0-31-amd64 -y​
    ​
tip​
Please replace 6.1.0-31-amd64 with the actual kernel version.​
  1. Execute the following command to force update initramfs.​
  • ​
    sudo update-initramfs -u -k 6.1.0-31-amd64​
    ​
tip​
Please replace 6.1.0-31-amd64 with the actual kernel version.​
  1. Execute the following command to update the GRUB configuration file.​
  • BIOS boot mode:​
  • ​
    sudo grub-mkconfig -o /boot/grub/grub.cfg​
    ​
  • UEFI boot mode:​
  • ​
    sudo [ -d /boot/efi/EFI/ubuntu ] && sudo grub-mkconfig -o /boot/efi/EFI/ubuntu/grub.cfg​
    ​
  1. Edit the default kernel.​
  1. Execute the following command to view the serial numbers of installed kernels.​
  • ​
    grep menuentry /boot/grub/grub.cfg​
    ​
  • When the following is echoed, it indicates two installed kernels: Kernel version: 6.1.0-31-amd64 and 6.1.0-18-amd64. Their order is arranged from top to bottom, with the serial numbers starting from 0, i.e., 6.1.0-31-amd64 number is 0, and 6.1.0-18-amd64 number is 1.​
  • ​​​
  1. Execute the following command to open the GRUB file.​
  • ​
    vim /etc/default/grub​
    ​
  1. Please replace the GRUB_DEFAULT argument value with the target kernel number.​
  • ​​​
  1. Press the Esc key to exit edit mode, enter :wq, and then press Enter to save the changes and exit the file.​
  1. Execute the following command to update the GRUB configuration file.​
  • ​
    sudo update-grub​
    ​
  1. Execute the following command to restart the instance.​
  • ​
    sudo reboot​
    ​
  1. Execute the following command to check whether the kernel is upgraded.​
  • ​
    uname -r​
    ​
  • When the echo is as follows, it indicates that the kernel version has been successfully upgraded to 6.1.0-31-amd64.​
  • ​​​
Last updated: 2026.06.18 17:49:52