Preparing VMs for Conversion to Google Cloud Platform

Updated

Before you perform a backup operation for virtual machines that you plan to convert, make changes to the source VMs to ensure that they can be converted successfully.

Before You Begin

  • For the Windows operating systems of guest Amazon, Azure Resource Manager, and VMware VMs, download the vioscsi.inf, netkvm.inf Windows driver files.

  • For the Linux operating systems of guest Azure Resource Manager and VMware VMs, download the virtio drivers (preloaded with Linux).

Procedure

Make the following changes to source VMs:

  1. For Windows VMs that are running in Amazon, Azure Resource Manager, and VMware, download and install GooGet PowerShell as follows:

    1. Download and install GooGet by running the following commands in an elevated PowerShell version 3.0 or higher prompt:

      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;

      Invoke-WebRequest https://github.com/google/googet/releases/download/v2.13.0/googet.exe -OutFile $env:temp\googet.exe;

      & "$env:temp\googet.exe" -root C:\ProgramData\GooGet -noconfirm install -sources `

      https://packages.cloud.google.com/yuck/repos/google-compute-engine-stable googet;

      Remove-Item "$env:temp\googet.exe"

      During installation, GooGet adds content to the system environment. After installation completes, launch a new PowerShell console or provide the full path to the googet.exe file (C:\ProgramData\GooGet\googet.exe).

    2. Open a new console and then add the google-compute-engine-stable repository by running the following command:

      .\googet.exe -root C:\ProgramData\GooGet addrepo google-compute-engine-stable https://packages.cloud.google.com/yuck/repos/google-compute-engine-stable
    3. Run the following commands to download VioSCSI and NetKVM drivers:

      .\googet.exe -root C:\ProgramData\GooGet download google-compute-engine-driver-netkvm
      .\googet.exe -root C:\ProgramData\GooGet download google-compute-engine-driver-vioscsi
    4. Extract the downloaded files using 7Zip, and then install the drivers as described in Step 2a through Step 2d, below.

  2. For Windows VMs that are running in Amazon, Azure Resource Manager, and VMware, inject drivers for the SCSI controller (vioscsi) and network adapter (netkvm) to ensure that the Google Cloud Platform instance can start after conversion. The vioscsi driver is required for the Windows boot process.

    1. Add a VirtIO SCSI controller device as a placeholder.

    2. Perform the following steps for both of the driver files (vioscsi.inf and netkvm.inf):

      1. Go to Run and execute hdwwiz.exe to open the Add New Hardware wizard.

      2. Select the Install the hardware that I manually select from a list option.

      3. As the hardware type, select Show All Devices.

      4. Click Have Disk.

        The Install from Disk dialog box appears.

      5. Browse and select the driver file, and then click OK.

      6. Click Next to continue, click Next again to start installing the driver, and then click Finish when the installation completes.

    3. From Windows Explorer, right-click the vioscsi.inf file, and then click Install.

    4. From Windows Explorer, right-click the netkvm.inf file, and then click Install.

    5. To add the VirtIO SCSI controller to the CriticalDeviceDatabase, add the following registry key to the Windows registry hive:

      [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CriticalDeviceDatabase\PCI#VEN_1AF4&DEV_1004&SUBSYS_00081AF4&REV_00] "ClassGUID"="{4D36E97B-E325-11CE-BFC1-08002BE10318}" "Service"="vioscsi"

      Note that "ClassGUID" and "Service" are string values.

      Note that, if the CriticalDeviceDatabase folder does not already exist, create one as follows:

      • Open the Windows Registry Editor, and then go to the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet directory.

      • Right-click Control, and then click New > Key.

      • Name the new key CriticalDeviceDatabase.

      • Close the Registry Editor.

  3. For Linux VMs, verify that required drivers are included in the initramfs RAM disk image.

    Although virtio drivers are preloaded with Linux, the drivers might not be included in the initramfs RAM disk image from which drivers are loaded.

    1. To check whether the drivers are included in the initramfs disk image run the following command:

      lsinitrd | grep -i virtio

      If virtio drivers are already included, you do not need to make any further changes to the Linux VMs.

      If the command does not list virtio drivers, then perform the following steps.

    2. Run the following command to identify the initramfs file version:

      uname -r
    3. Create a backup of the current initramfs image.

      cp /boot/<Current_Image_Name> /boot/<Current_Image_Name>.backup

      where <Current_Image_Name> is the initramfs file version.

    4. Run the followng command to edit the dracut.conf file:

      vi /etc/dracut.conf
    5. Uncomment the line that contains "add-drivers", and then add the drivers to the line, with spaces separating each module as shown in the following example:

      add_drivers+="virtio virtio_ring virtio_pci virtio_scsi virtio_net virtio_balloon"
    6. Go to the boot folder:

      cd /boot
    7. Recut the initramfs image:

      dracut -f -v
    8. List the RAM disk image contents and verify that the virtio drivers were added:

      lsinitrd | grep -i virtio
  4. For Linux VMs that are running in Azure Resource Manager, you must ensure that the following modules are configured to be available during the boot process: virtio, virtio_ring, virtio_pci, virtio_net, virtio_scsi. Although commonly used Linux distributions (CentOS, RHEL, OpenSUSE, Ubuntu) will have these virtio driver modules packaged, you should still ensure that they are configured to be available.

    1. To check whether the required modules are built into the kernel itself, run the following command:

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

      Look for values of CONFIG_VIRTIO, CONFIG_VIRTIO_PCI, CONFIG_VIRTIO_NET, and CONFIG_SCSI_VIRTIO.

      If a virtio driver’s line says y, the driver is built into the kernel and it will be available by default during the boot process.

      If a virtio driver’s line says m, the driver needs to be part of the initial RAM disk.

    2. Check if the drivers are part of the initial ramdisk, as follows:

      1. For CentOS, RHEL, or OpenSUSE, run the following command:

        lsinitrd | grep -i virtio

      2. For Ubuntu, run the following command:

        lsinitramfs /boot/initrd.img-$(uname -r) | grep -i virtio

    3. If any driver is missing from both the kernel and the initial ramdisk, rebuild the initial ramdisk to include the missing modules, as follows:

      1. For CentOS, RHEL, or OpenSUSE, create a backup of the current initial ramdisk image by running the following command:

        cp /boot/<Current_Image_Name> /boot/<Current_Image_Name>.backup

        Where:

        - (For CentOS and RHEL): <Current_Image_Name> = initramfs-$(uname -r).img

        - (For OpenSUSE): <Current_Image_Name> = initrd-$(uname -r)

      2. Edit the dracut.conf file by running the following command:

        vi /etc/dracut.conf

      3. Add the following line to the dracut.conf file. If it already exists as a commented line, uncomment the line and then add the drivers to the line, with spaces separating each driver:

        add_drivers+="virtio virtio_ring virtio_pci virtio_scsi virtio_net" (add the required drivers only)

      4. Go to the boot folder by running the following command:

        cd /boot

      5. Recut the initial ramdisk image by running the following command:

        dracut -f -v

      6. List the initial ramdisk image contents and verify that the virtio drivers were added, by running the following command:

        lsinitrd | grep -i virtio

  5. Perform a backup operation for the modified source VMs.