Help Center/ Elastic Cloud Server/ FAQs/ OS/ How Can I Upgrade the Kernel of a Linux ECS?
Updated on 2025-06-27 GMT+08:00

How Can I Upgrade the Kernel of a Linux ECS?

Scenarios

If the kernel of a Linux ECS has stability or performance issues such as system breakdown, freezing, and memory leakage, or new kernel functions are required, you can upgrade the OS kernel.

Constraints

Upgrading the OS kernel may cause system instability or compatibility issues. Before the upgrade, you should know the problems that may occur during the upgrade, back up important data, and perform the upgrade with caution.

For details about how to back up the ECS, see Backup Overview.

  • After the OS kernel is upgraded, the Linux ECS may not be able to identify the network interfaces. This will lead to network access failure.
  • After the OS kernel is upgraded, the Linux ECS may not be able to identify data disks. As a result, starting system mount points fails, and the ECS cannot start.

Procedure

This section uses the Huawei Cloud EulerOS, CentOS, Ubuntu, and Debian as examples to describe how to update the OS kernel.

Upgrading the Kernel (Huawei Cloud EulerOS or CentOS)

  1. Log in to the ECS.
  2. Run the following command to query the OS kernel version:

    uname -r

  3. Run the following command to check whether there is any OS kernel that can be upgraded:

    sudo yum list kernel

    • If no OS kernel can be upgraded:
      You are advised to replace the OS with Huawei Cloud EulerOS 2.0. For details, see Changing the OS.

      CentOS 6, CentOS 7, and CentOS 8 are no longer maintained and will not be supported by Huawei Cloud. For details, see What Do I Do If CentOS Linux Is No Longer Maintained?

    • If there is an OS kernel that can be upgraded:
      1. Run the following command to check whether the initrd or initramfs file contains the virtio-blk or xen-blkfront driver:

        sudo lsinitrd /boot/initramfs-`uname -r`.img | grep -E 'virtio|xen'

        If information similar to the following is displayed, the virtio-blk or xen-blkfront driver is contained. Otherwise, the driver is not included. Go to the next step.

        -rwxr--r--   1 root     root        23888 Feb 10  2022 lib/modules/2.6.32-754.35.1.el6.x86_64/kernel/drivers/block/virtio_blk.ko
        -rwxr--r--   1 root     root        55064 Feb 10  2022 lib/modules/2.6.32-754.35.1.el6.x86_64/kernel/drivers/block/xen-blkfront.ko
      2. (Optional) Run the following command to add the virtio-blk or xen-blkfront driver to the initrd or initramfs file.

        Perform this step only when the initrd or initramfs file does not contain the virtio-blk or xen-blkfront driver.

        sudo sh -c 'echo 'add_drivers+="xen-blkfront virtio_blk"' >> /etc/dracut.conf.d/virt-drivers.conf'

  4. Run the following command to upgrade the OS kernel version:

    sudo yum update -y

  5. Run the following command to update the GRUB file so that the ECS can select the target kernel version during startup:

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

  6. Run the following command to restart the ECS:

    sudo reboot

  7. Run the following command to check whether the kernel version has been upgraded:

    uname -r

    If the new kernel version is returned, the kernel has been upgraded.

Upgrading the Kernel (Ubuntu or Debian)

  1. Log in to the ECS.
  2. Run the following command to query the OS kernel version:

    uname -r

  3. Run the following commands to update the system software package list and check whether the OS kernel can be upgraded:

    sudo apt update

    apt-cache search linux-image

    • If no OS kernel can be upgraded:

      You are advised to change the OS kernel to a later version. For details, see Changing the OS.

    • If there is an OS kernel that can be upgraded:
      1. Run the following command to upgrade the OS kernel version:

        sudo apt-get install linux-image-<target-kernel-package-name>

      2. (Optional) Upgrade the additional modules of the OS kernel.

        For an ECS running Ubuntu, you need to upgrade additional modules after the OS kernel is upgraded.

        sudo apt-get install linux-modules-extra-<target-kernel-package-name>

        For example, to update the kernel of Ubuntu 20.04 to 5.15.0, run the following commands:

        sudo apt update

        apt-cache search linux-image | grep '5.15' | grep generic

        sudo apt-get install linux-image-5.15.0-122-generic

        sudo apt-get install linux-modules-extra-5.15.0-122-generic

  4. Run the following command to update the GRUB file so that the ECS can select the target kernel version during startup:

    sudo update-grub

  5. Run the following command to restart the ECS:

    sudo reboot

  6. Run the following command to check whether the kernel version has been upgraded:

    uname -r

    If the new kernel version is returned, the kernel has been upgraded.