All Products
Search
Document Center

:How to Avoid boot failures during Kernel upgrade of a Linux instance

Last Updated:Dec 15, 2020

Disclaimer: This article may contain information about third-party products. Such information is for reference only. Alibaba Cloud does not make any guarantee, express or implied, with respect to the performance and reliability of third-party products, as well as potential impacts of operations on the products.

Overview

This topic describes how to avoid system startup failure due to Kernel upgrade of a Linux instance.

Detail

Alibaba Cloud reminds you that:

  • Before you perform operations that may cause risks, such as modifying instance configurations or data, we recommend that you check the disaster recovery and fault tolerance capabilities of the instances to ensure data security.
  • If you modify the configurations and data of instances including but not limited to ECS and RDS instances, we recommend that you create snapshots or enable RDS log backup.
  • If you have authorized or submitted security information such as the logon account and password in the Alibaba Cloud Management console, we recommend that you modify such information in a timely manner.

Images such as CentOS, OpenSUSE, SLES(SUSE Linux Enterprise Server), and Aliyun Linux cannot be started after the Linux instance is upgraded. This may be because the initrd file corresponding to the kernel does not contain the virtio-blk or xen-blkfront driver. Debian and Ubuntu virtio-blk and xen-blkfront drivers are Built-in kernels.

What is an initrd file

initrd(initial ramdisk) is used to load the temporary root file system to disk. It runs during the startup phase of a Linux instance. initramfs files play a similar role. Although initrd and initramfs are two different operations, both files are active before the file system is mounted at instance startup.

System images that can be directly upgraded

Note: we do not recommend that you upgrade the kernel of Alibaba Cloud. For more information, see ECS usage instructions.

Alibaba Cloud has optimized the public system Image kernel after 20161115. You can check the timestamp in the image name. If the timestamp is an image after 20161115, the kernel can be upgraded normally. The following are some of the system images that can be directly upgraded to the kernel. The initrd files of these images will not fail to start due to the lack of virtio-blk and blkfront drivers.

  • centos_6u8_64_40G_cloudinit_20161115.vhd
  • centos_6u8_32_40G_cloudinit_20161115.vhd
  • centos_5u11_64_40G_cloudinit_20161115.vhd
  • centos_5u11_32_40G_cloudinit_20161115.vhd
  • centos_6_8_64_40G_base_20170222.vhd
  • centos_6_8_32_40G_base_20170222.vhd
  • centos_7_2_64_40G_base_20170222.vhd
  • centos_5_11_64_40G_base_20170222.vhd
  • centos_5_11_32_40G_base_20170222.vhd
  • centos_6_08_64_20G_alibase_20170824.vhd
  • debian_8_09_64_20G_alibase_20170824.vhd
    Note: only partial public images are listed here. Replace them with the timestamps of the images.

How to optimize the kernel and avoid startup failure

If you are using a public image that has not been optimized by Alibaba Cloud and need to upgrade the system kernel, perform the following steps to optimize the kernel to avoid ECS startup failure.

Note: We recommend that you back up the original configuration file before modifying it.

  1. Create an ECS snapshot. For more information, see ECS snapshot.
  2. Run the following command to add the missing content to the specified system configuration file:
    • Run the following command to add the missing content to the CentOS configuration file:
      echo 'add_drivers+="xen-blkfront virtio_blk"' >> /etc/dracut.conf.d/virt-drivers.conf
    • For the CentOS 5 system, run the following command to add the missing content to the CentOS configuration file:
      echo 'add_drivers+="xen-vbd virtio_blk virtio_console"' >> /etc/dracut.conf.d/virt-drivers.conf
    • For OpenSUSE or SUSE systems, run the following commands in sequence to add the missing content to the /etc/sysconfig/kernel and /etc/dracut.conf configuration files:
      echo 'INITRD_MODULES=" virtio_blk virtio_pci xen-vbd"' >> /etc/sysconfig/kernel
      echo 'add_drivers+="virtio_blk virtio_pci xen-vbd"' >> /etc/dracut.conf
  3. Run the following command to update the kernel:
    • If the operating system is CentOS, run the following command to update the kernel:
      yum install kernel
    • If your operating system is OpenSUSE or SUSE, run the following command to update the kernel:
      zypper install kernel-default
  4. Run the following command to verify that the initrd or initramfs file contains the virtio-blk and xen-blkfront drivers:
    (: must be recognized virtio-blk and xen-blkfront drive in an initrd exist you can restart the instance.
    lsinitrd /boot/initramfs-`uname -r`.img | grep -E 'virtio|xen'
    The command output is as follows: take the CentOS system as an example.

Application scope

  • Elastic Compute Service