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)
- Log in to the ECS.
- Run the following command to query the OS kernel version:
- Run the following command to check whether there is any OS kernel that can be upgraded:
- 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:
- 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
- (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'
- Run the following command to check whether the initrd or initramfs file contains the virtio-blk or xen-blkfront driver:
- If no OS kernel can be upgraded:
- Run the following command to upgrade the OS kernel version:
- Run the following command to update the GRUB file so that the ECS can select the target kernel version during startup:
- Run the following command to restart the ECS:
- Run the following command to check whether the kernel version has been upgraded:
If the new kernel version is returned, the kernel has been upgraded.
Upgrading the Kernel (Ubuntu or Debian)
- Log in to the ECS.
- Run the following command to query the OS kernel version:
- Run the following commands to update the system software package list and check whether the OS kernel can be upgraded:
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:
- Run the following command to upgrade the OS kernel version:
sudo apt-get install linux-image-<target-kernel-package-name>
- (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
- Run the following command to upgrade the OS kernel version:
- If no OS kernel can be upgraded:
- Run the following command to update the GRUB file so that the ECS can select the target kernel version during startup:
- Run the following command to restart the ECS:
- Run the following command to check whether the kernel version has been upgraded:
If the new kernel version is returned, the kernel has been upgraded.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot