Preparing Linux VMs for Conversion to Alibaba Cloud ECS

Before performing a backup that will be used for VM conversion, you must install the vioscsi and viostor drivers on the source VMs.

Before You Begin

  • Virtual machines running the following guest operating systems can be converted to Alibaba Cloud ECS instances:

    • CentOS 7

    • Ubuntu 14/16/18

    • SUSE 12

Procedure

  1. For CentOS and RHEL, run the following commands:

    1. To check whether the drivers are available on the Linux VM, run the following command:

      grep -i virtio /boot/config-$(uname -r)

      alivm1

      If the CONFIG_VIRTIO_BLK and CONFIG_VIRTIO_NET parameters display y, the virtio driver is already included, you do not need to make any further changes to the Linux VMs.

      If the parameters display m, then perform the following step.

      1. Run the following command to verify that the virtio driver is compiled in the temporary root file system of initramfs or initrd.

        lsinitrd /boot/initramfs-$(uname -r).img | grep virtio

        Output:

        alivm2

        The output shows that the virtio driver is compiled in the temporary file system initramfs. If the virtio driver is unavailable in the initramfs, perform the following step to recover the temporary root file system initramfs before migration.

      2. Recover the temporary root file system.

        CentOS/RedHat 5:

        mkinitrd -f --allow-missing \
                    --with=virtio_blk --preload=virtio_blk \
                    --with=virtio_pci --preload=virtio_pci \
                    --with=virtio_console --preload=virtio_console \

        CentOS/RedHat 6/7:

        mkinitrd -f --allow-missing 
                    --with=virtio_blk --preload=virtio_blk \
                    --with=virtio_pci --preload=virtio_pci \
                    --with=virtio_console --preload=virtio_console \
                    /boot/initramfs-$(uname -r).img $(uname -r)
  2. For SUSE 12 SP1 and later, run the following commands:

    1. Run the following command to open the /etc/dracut.conf file:

      vi /etc/dracut.conf
    2. Press i to enter editing mode and add the VirtIO driver to add-drivers.

      [root@CTU10000xxxxx ~]# vi /etc/dracut.conf
      # additional kernel modules to the default
      add_drivers+="virtio_blk virtio_scsi virtio_net virtio_pci virtio_ring virtio_balloon virtio"
    3. Press Esc, enter :wq, and then press Enter.

      The system saves the change and exits the /etc/dracut.conf file.

    4. Run the following command to generate initrd again:

      dracut -f /boot/initramfs file name

      If the virtual file system is not the default initramfs or initrd, run command dracut -f Name of the initramfs or initrd file actually used. The actual initramfs file name or initrd file name can be obtained from the GRUB configuration file, /boot/grub/grub.cfg, /boot/gurb2/grub.cfg, or /boot/grub/grub.conf (which varies depending on the OS).

    5. If the virtual file system is initramfs, run the following command to check whether native KVM driver is loaded:

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

      If the virtual file system is initrd, run the following command to check whether the original KVM driver module is successfully loaded:

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

      If the virtual file system is initramfs, the following information is displayed:

      sluo-ecs-30dc:~ # lsinitrd /boot/initrd-`uname -r` | grep virtio
      -rw-r--r-- 1 root root 29335 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/block/virtio_blk.ko
      -rw-r--r-- 1 root root 57007 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/net/virtio_net.ko
      -rw-r--r-- 1 root root 32415 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/scsi/virtio_scsi.ko
      drwxr-xr-x 2 root root 0 Sep 28 10:21 lib/modules/4.4.21-69-default/kernel/drivers/virtio
      -rw-r--r-- 1 root root 19623 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio.ko
      -rw-r--r-- 1 root root 38943 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_pci.ko
      -rw-r--r-- 1 root root 24431 Oct 26 2016 lib/modules/4.4.21-69-default/kernel/drivers/virtio/virtio_ring.ko
  3. For Ubuntu, run the following commands:

    1. Run the following command to open the modules file:

      vi /etc/initramfs-tools/modules
    2. Press i to enter editing mode and add the VirtIO driver to the /etc/initramfs-tools/modules file (the format depends on the OS requirements).

      [root@CTU10000xxxxx ~]#vi /etc/initramfs-tools/modules
      ......
      # Examples:
      #
      # raid1
      # sd_mOd
      virtio_blk
      virtio_scsi 
      virtio_net
      virtio_pci
      virtio_ring
      virtio_balloon 
      virtio
    3. Press Esc, enter :wq, and press Enter. The system saves the change and exits the /etc/initramfs-tools/modules file.

    4. Run the following command to generate initrd again:

      update-initramfs -u
    5. Run the following command to check whether native KVM drivers have been installed:

      [root@ CTU10000xxxxx home]# lsinitramfs /boot/initrd.img-`uname -r` |grep virtio
      lib/modules/3.5.0-23-generic/kernel/drivers/scsi/virtio_scsi.ko
  4. Perform a backup operation for the modified source VMs.

Loading...