All Products
Search
Document Center

Elastic Compute Service:Upgrade the operating system kernel of a Linux ECS instance

Last Updated:Jul 02, 2025

When stability or performance issues, such as system crashes, stuttering, or memory leaks, occur in the operating system kernel of a Linux Elastic Compute Service (ECS) instance, you can upgrade the operating system kernel of the ECS instance to resolve the issues. You can also upgrade the operating system kernel of an ECS instance to obtain new kernel features.

Precautions

The kernel upgrade operation is a complex and high-risk operation that may lead to system instability or incompatibility issues. Before you upgrade the kernel, we recommend that you back up important data. Make sure that you fully understand the upgrade procedure and the impacts of the upgrade operation. Proceed with caution.

Procedure

This section describes how to upgrade the operating system kernel of an ECS instance. In this example, an ECS instance that runs one of the following operating systems is used: Alibaba Cloud Linux, CentOS, Ubuntu and Debian.

Alibaba Cloud Linux and CentOS

  1. (Optional) Create snapshots for the disks that are attached to the ECS instance to back up data. For more information, see Create a snapshot.

  2. Connect to the ECS instance. For more information, see Use Workbench to connect to a Linux instance over SSH.

  3. View the current operating system kernel version of the instance

    uname -r
  4. Check whether a kernel version is available for upgrade.

    sudo yum list kernel

    CentOS 6 reached end of life (EOL). In accordance with Linux community rules, all content was removed from the following CentOS 6 repository address: http://mirror.centos.org/centos-6/. If you continue to use the default CentOS 6 repository on Alibaba Cloud, an error is reported. To use specific installation packages of CentOS 6, change the CentOS 6 repository address. For more information, see How do I change CentOS 6 repository addresses?

    • If no kernel version is available for upgrade, we recommend that you change the operating system to Alibaba Cloud Linux 3. For more information, see Migrate and upgrade the operating system of an ECS instance or Replace the operating system (system disk) of an instance.

    • If a kernel version is available for upgrade, perform the following steps to upgrade the kernel:

      1. Check whether the initrd or initramfs file in the system contains the virtio-blk and xen-blkfront drivers:

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

        If a command output similar to the following one is returned, the file contains the virtio-blk and xen-blkfront drivers. Otherwise, the file does not contain the virtio-blk or xen-blkfront driver.

        -rw-r--r--   1 root     root        83312 Jul 22 10:38 usr/lib/modules/4.19.91-27.5.al7.x86_64/kernel/drivers/block/xen-blkfront.ko
        -rw-r--r--   1 root     root        68016 Jul 22 10:38 usr/lib/modules/4.19.91-27.5.al7.x86_64/kernel/drivers/net/xen-netfront.ko
      2. If the file does not contain the virtio-blk or xen-blkfront driver, run the following command to add the drivers to the system. If the file contains the drivers, skip this step.

        sudo sh -c 'echo 'add_drivers+="xen-blkfront virtio_blk"' >> /etc/dracut.conf.d/virt-drivers.conf'
  5. Upgrade the operating system kernel.

    sudo yum install kernel -y
  6. Update the configuration file of GRand Unified Bootloader (GRUB) for the instance to load the new kernel version on startup.

    sudo grub2-mkconfig -o /boot/grub2/grub.cfg
  7. Restart the instance.

    sudo reboot
  8. Check whether the new kernel version is installed.

    uname -r

    If the new kernel version is returned, the kernel upgrade is successful.

Ubuntu and Debian

  1. (Optional) Create snapshots for the disks that are attached to the ECS instance to back up data. For more information, see Create a snapshot.

  2. Connect to the ECS instance. For more information, see Use Workbench to connect to a Linux instance over SSH.

  3. Check the current operating system kernel version of the instance to determine whether an upgrade is required.

    uname -r
  4. Update the system software package list and check whether a kernel version is available for upgrade.

    sudo apt update
    apt-cache search linux-image
    • If no kernel version is available for upgrade, we recommend that you change the operating system to higher version. For more information, see Replace the operating system (system disk) of an instance.

    • If a kernel version is available for upgrade:

      1. Run the following command to upgrade the kernel:

        sudo apt-get install linux-image-<Kernel package name>
      2. (Optional) If you are using Ubuntu, you need to upgrade additional kernel modules for the operating system.

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

        Take Ubuntu 20.04 for example, run the following commands to upgrade the kernel version to 5.15.0 and the additional kernel modules:

        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
  5. Update the GRUB configuration file for the instance to load the new kernel version on startup.

    sudo update-grub
  6. Restart the instance and refresh the Workbench page.

    sudo reboot
  7. Check whether the new kernel version is installed.

    uname -r

    If the new kernel version is returned, the kernel upgrade is successful.