Updated on 2024-01-11 GMT+08:00

Manually Changing a Xen ECS to a KVM ECS (Linux)

Scenarios

Before changing a Xen ECS that runs Linux to a KVM ECS, install and configure required drivers.

This section describes how to manually install drivers on a Linux ECS, configure automatic disk attachment, and change Xen to KVM.

For instructions about how to use a script to automatically install drivers, see Automatically Changing a Xen ECS to a KVM ECS (Linux).

  • Xen ECSs include S1, C1, C2, T2, and M1 ECSs.
  • To obtain KVM ECSs, see the Virtualization column in ECS Specifications and Types.
  • To support both Xen and KVM, Linux ECSs require the xen-pv and virtio drivers. Before changing a Xen ECS to a KVM ECS, make sure that the Linux ECS has been configured, including driver installation and automatic disk attachment.

Constraints

  • To prevent data loss, the specifications of Linux ECSs that use LVM or RAID arrays cannot be modified.
  • A Xen ECS with more than 24 VBD disks attached cannot be changed to a KVM ECS.
  • A Xen ECS can be changed to a KVM ECS, but a KVM ECS cannot be changed to a Xen ECS.

Procedure

Figure 1 shows the flowchart for manually changing a Xen ECS to a KVM ECS.
Figure 1 Flowchart for manually changing a Xen ECS to a KVM ECS

(Optional) Step 1: Back Up System Disk Data

If you modify the specifications of an ECS without installing the driver, the ECS may become unavailable and the data on the system disk may be lost. Therefore, back up the system disk first.

  1. Before you create a system disk backup, check the ECS.

    Stop and then start the ECS to ensure that services can run properly after the ECS is started. Back up the system disk.

  2. For instructions about how to back up the system disk, seeCreating a VBS Backup.

Step 2: Install Drivers

Perform the following operations to manually install drivers on an ECS.

  1. Log in to the ECS.
  2. Uninstall tools from the ECS.

    For details, see "Optimizing a Linux Private Image" in Image Management Service User Guide.

  3. Change the GRUB disk ID to UUID.

    For details, see "Optimizing a Linux Private Image" in Image Management Service User Guide.

  4. Change the fstab disk ID to UUID.

    For details, see "Optimizing a Linux Private Image" in Image Management Service User Guide.

  5. Install native Xen and KVM drivers.

    For details, see "Optimizing a Linux Private Image" in Image Management Service User Guide.

Step 3: Check Whether the ECS Is Configured Correctly

Perform the following operations to check whether the drivers have been installed and the configuration files have been modified.

Before manually modifying specifications, make sure that the ECS has been configured correctly.

  1. Log in to the ECS.
  2. Run the following command to check whether the root partition is in UUID format:

    cat /boot/grub/grub.cfg

    • If yes, the disk ID in the GRUB configuration file has been changed to UUID.
    • If no, the modification failed. In such a case, change the GRUB disk ID to UUID again by referring to Step 2: Install Drivers.
    ...menuentry 'Ubuntu Linux, with Linux 3.13.0-24-generic' --class ubuntu --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.13.0-24-generic-advanced-ec51d860-34bf-4374-ad46-a0c3e337fd34' {
    recordfail
    load_video
    gfxmode $linux_gfx_mode
    insmod gzio
    insmod part_msdos
    insmod ext2
    if [ x$feature_platform_search_hint = xy ]; then
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    else
    search --no-floppy --fs-uuid --set=root ec51d860-34bf-4374-ad46-a0c3e337fd34
    fi
    echo 'Loading Linux 3.13.0-24-generic ...'
    linux /boot/vmlinuz-3.13.0-24-generic root=UUID=ec51d860-34bf-4374-ad46-a0c3e337fd34 ro
    echo 'Loading initial ramdisk ...'
    initrd /boot/initrd.img-3.13.0-24-generic
    }

    The path in which the GRUB configuration file is stored varies depending on the OS. For example, the path can be /boot/grub/menu.lst, /boot/grub/grub.cfg, /boot/grub2/grub.cfg, or /boot/grub/grub.conf.

  3. Run the following command to check whether the disk ID in the fstab configuration file is UUID:

    cat /etc/fstab

    • If yes, the disk ID has been changed to UUID.
    • If no, the modification failed. In such a case, change the fstab disk ID to UUID again by referring to Step 2: Install Drivers.
    [root@****** ~]# cat /etc/fstab 
    UUID=4eb40294-4c6f-4384-bbb6-b8795bbb1130  /       xfs     defaults    0 0
    UUID=2de37c6b-2648-43b4-a4f5-40162154e135  swap    swap    defaults    0 0
  4. Check whether the native Xen and KVM drivers have been installed.
    • If the boot virtual file system is initramfs, run the following commands:

      lsinitrd /boot/initramfs-`uname -r`.img | grep ` uname -r ` | grep xen

      lsinitrd /boot/initramfs-`uname -r`.img | grep ` uname -r ` |grep virtio

    • If the boot virtual file system is initrd, run the following commands:

      lsinitrd /boot/initrd-`uname -r` | grep ` uname -r ` | grep xen

      lsinitrd /boot/initrd-`uname -r` | grep ` uname -r ` | grep virtio

    If the names of the native Xen and KVM drivers are displayed in the command output, the drivers have been installed.

    [root@CTU10000xxxxx home]# lsinitrd /boot/initramfs-`uname -r`.img | grep ` uname -r`| grep xen
    -rwxr--r--   1 root     root        54888 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/block/xen-blkfront.ko 
    -rwxr--r--   1 root     root        45664 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/net/xen-netfront.ko 
     
    [root@CTU10000xxxxx home]# lsinitrd /boot/initramfs-`uname -r`.img | grep ` uname -r`| grep virtio
    -rwxr--r--   1 root     root        23448 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/block/virtio_blk.ko 
    -rwxr--r--   1 root     root        50704 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/net/virtio_net.ko 
    -rwxr--r--   1 root     root        28424 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/scsi/virtio_scsi.ko 
    drwxr-xr-x   2 root     root            0 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio 
    -rwxr--r--   1 root     root        14544 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio.ko 
    -rwxr--r--   1 root     root        21040 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio_pci.ko 
    -rwxr--r--   1 root     root        18016 Jul 16 17:53 lib/modules/2.6.32-573.8.1.el6.x86_64/kernel/drivers/virtio/virtio_ring.ko

Make sure that the ECS has been configured successfully, or the ECS may become unavailable after the specifications are modified.

Step 4: Modify Specifications

  1. Log in to management console.
  2. Under Computing, click Elastic Cloud Server.
  3. On the Elastic Cloud Server page, view the status of the target ECS.

    If the ECS is not in Stopped state, click More in the Operation column and select Stop.

  4. Click More in the Operation column and select Modify Specifications.

    The Modify ECS Specifications page is displayed.

  5. Select the new ECS type, vCPUs, and memory as prompted.
  6. (Optional) Set DeH.

    If the ECS is created on a DeH, you can change the DeH where the ECS resides.

    To do so, select the target DeH from the drop-down list. If no DeH is available in the drop-down list, it indicates that DeH resources are insufficient and cannot be used to create the ECS with specifications modified.

  7. Select the check box to confirm that the configuration is complete.
  8. Click OK.

(Optional) Step 5: Check Disk Attachment

After a Xen ECS is changed to a KVM ECS, disk attachment may fail. Therefore, check disk attachment after specifications modification. If disks are properly attached, the specifications modification is successful.

Follow-up Procedure

If the ECS specifications have been modified but the OS cannot be started after remote login, reinstall the ECS OS to resolve this issue. For details, see Reinstalling the OS.