Convert a virtual disk image to qcow2 format for use in VM Runtime on GDC

You can reduce the time it takes to create virtual machines (VMs) in VM Runtime on GDC by manually converting existing virtual disk images to the qcow2 format. After you convert an image, you can create and run VMs directly from it.

VM Runtime on GDC automatically converts non-qcow2 disk images during deployment. However, if you create multiple VMs from the same non-qcow2 image, VM Runtime on GDC converts the image every time, which increases the time it takes to create and start each VM. Converting the image first, as shown in this document, avoids this repeated conversion.

Before you begin

To create a VM after you convert your existing virtual disk image, you need access to the following resources:

Convert a virtual disk image

In this document, you use the QEMU disk image utility to convert existing virtual disk images to the qcow2 format. The qemu-img tool can convert virtual disk images from multiple formats, such as vmdk or vhdx, to the qcow2 format for use with VM Runtime on GDC.

To convert virtual disk images to the qcow2 format, complete the following steps:

  1. Install the qemu-utils package using your Linux distro's package manager.

    Ubuntu

    apt-get install qemu-utils
    

    RHEL

    yum install qemu-utils
    
  2. Use qemu-img to convert the existing virtual disk image:

    qemu-img convert -f EXISTING_DISK_IMAGE_FORMAT -O qcow2 \
      EXISTING_DISK_IMAGE_NAME \
      CONVERTED_DISK_IMAGE_NAME.qcow2
    

    Replace the following values:

    • EXISTING_DISK_IMAGE_FORMAT: the format of your existing virtual disk image, such as vmdk.
    • EXISTING_DISK_IMAGE_NAME: the path and name of your existing virtual disk image.
    • CONVERTED_DISK_IMAGE_NAME: the path and name for your converted qcow2 virtual disk image.

    For more information on the qemu-img tool, such as the different image format options, see the QEMU disk image utility documentation.

Create a VM with your converted image

If you want to see your converted virtual disk image in action, create a VM and use the local qcow2-formatted image created in the previous section. For production use, you should upload your converted virtual disk image to a central repository and then create a VM boot disk from HTTP source or from Cloud Storage using a Secret.

To use your local converted virtual disk image, complete the following steps:

  1. Create a VM in your cluster:

    kubectl virt create vm VM_NAME \
      --os-type OS_TYPE \
      --image CONVERTED_DISK_IMAGE_NAME.qcow2
    

    This command creates a VM with the defaults of 2 CPU, 4 Gi memory.

    Replace the following values:

    • VM_NAME: name for your VM
    • OS_TYPE: the OS type of your converted virtual disk image. Can be linux or windows.
    • CONVERTED_DISK_IMAGE_NAME: the path and name of your converted qcow2 virtual disk image from the previous section.
  2. It can take 10-20 minutes to create the VM from your locally converted virtual disk image, depending on the size of your image. Check the status of the VM with the kubectl command:

    kubectl get gvm VM_NAME
    

    Replace VM_NAME with the name of your VM.

    The following example output shows the VM in a Running state when the process is complete:

    NAME    STATUS    AGE   IP
    MY_VM   Running   64s   192.168.2.124
    

What's next

You can upload your converted virtual disk image in qcow2 format to an HTTP source or Cloud Storage. The following documents show you how to then create a VM from those sources: