All Products
Search
Document Center

Elastic Compute Service:Upgrade Linux ECS instance kernel

Last Updated:May 15, 2026

Resolve stability or performance issues such as crashes or memory leaks by upgrading the Linux kernel on an ECS instance.

Warning

Kernel upgrades carry a risk of instability or hardware incompatibility. Back up your data before you begin, and verify that you understand the full procedure and its impacts.

Prerequisites

Ensure the following:

  • (Optional) A snapshot of each disk attached to the instance is created to back up data.

  • SSH access to the instance is configured.

Upgrade the kernel

Choose the procedure for your Linux distribution.

Alibaba Cloud Linux and CentOS

  1. Check the current kernel version.

    uname -r
  2. Check for a newer kernel.

    CentOS 6 has reached end of life (EOL). Its official repository at http://mirror.centos.org/centos-6/ has been removed. If you use the default CentOS 6 repository on Alibaba Cloud, the command returns an error. Change the repository address first. See How do I change CentOS 6 repository addresses?
    sudo yum list kernel
  3. Check whether the initrd or initramfs file contains the virtio-blk and xen-blkfront drivers.

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

    If the output includes entries similar to the following, both drivers are present. Skip to step 4.

    -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

    If either driver is missing, add it before upgrading.

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

    sudo yum install kernel -y
  5. Update the GRUB configuration to load the new kernel at startup.

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

    sudo reboot
  7. Verify that the new kernel is running.

    uname -r

    The output shows the new kernel version.

Ubuntu and Debian

  1. Check the current kernel version.

    uname -r
  2. Update the package list and check for available kernel packages.

    • No kernel version available for upgrade: Replace the OS with a higher version. See Replace OS (system disk).

    • A newer kernel version is available: Continue to step 3.

    sudo apt update
    apt-cache search linux-image
  3. Install the kernel package.

    sudo apt-get install linux-image-<Kernel package name>

    (Optional) If the instance runs Ubuntu, install the extra kernel modules for the new version.

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

    Example: upgrade Ubuntu 20.04 to kernel 5.15.0

    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. Update the GRUB configuration to load the new kernel at startup.

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

    sudo reboot
  6. Verify that the new kernel is running.

    uname -r

    The output shows the new kernel version.

Roll back after a failed upgrade

If the upgraded kernel causes boot failures or instability, restore service by using one of the following methods:

  • Restore from snapshot: Roll back the system disk with the snapshot you created before the upgrade.

  • Replace the OS: Replace the system disk with a supported OS image. See Replace OS (system disk).

FAQ

Do I need to restart after a kernel upgrade?

Yes. The new kernel takes effect only after a restart. The instance runs the old kernel until then.

How do I confirm the upgrade succeeded?

Run uname -r after the restart. If the output shows the new version, the upgrade succeeded.

What if the new kernel is incompatible with my hardware or drivers?

Restore from the snapshot you created before the upgrade, or replace the OS. See Roll back after a failed upgrade.

What if no newer kernel is available for my distribution?

For Alibaba Cloud Linux and CentOS, switch to Alibaba Cloud Linux 3 via OS migration. For Ubuntu and Debian, replace the OS with a higher version. See Replace OS (system disk).

Next steps

  • Set up a regular snapshot schedule for your system disk to minimize downtime from future security fixes.