Converting Between Image Formats

Converting Between Image Formats

To convert an image from one format to another, use the qemu-img convert command. The syntax is:

qemu-img convert -f <old image format> -O <new image format> <old image file name> <new image file name>

The -f format flag is optional. If omitted, qemu-img will try to infer the image format.

If you created a VDI image using VirtualBox, you can convert it to raw format using the VBoxManage command-line tool that ships with VirtualBox. See Example 4 for details.

Supported Formats

The following table shows which formats are supported, and the corresponding names of the command arguments.

Image Format Command Argument
QCOW2 (KVM, Xen) qcow2
QED (KVM) qed
raw raw
VDI (VirtualBox) vdi
VHD (Hyper-V) vpc
VMDK (VMware) vmdk

Note: If you use Ceph as your image repository storage (Glance), QCOW2 images are no longer supported. As a result, QCOW2 images need to be converted to RAW image file format.

Conversion Examples

The examples in this section show how to convert from one image format to another using the qemu-img convert command.

Note:

  • When converting an image file with Windows, the virtio driver must be installed. If it is not installed, you will see a blue screen when launching the image.

  • An alternative to installing virtio is to set the image properties as shown below when you update the image in the Image service; however, this method will reduce virtual machine performance significantly.

      $ openstack image set --property hw_disk_bus='ide' image_name_or_id
    

###Example 1: Converting Raw image file to qcow2 image file

This example converts a raw image file named image.img to a qcow2 image file.

$ qemu-img convert -f raw -O qcow2 image.img image.qcow2

Example 2: Converting VMDK image file to raw image file

This example converts a vmdk image file to a raw image file.

$ qemu-img convert -f vmdk -O raw image.vmdk image.img

Example 3: Converting VMDK image file to qcow2 image file

This example converts a vmdk image file to a qcow2 image file.

$ qemu-img convert -f vmdk -O qcow2 image.vmdk image.qcow2

Example 4: Converting VDI (VirtualBox) to raw

If your VDI image was created using VirtualBox, you can convert it to raw format using the VBoxManage command-line tool that ships with VirtualBox. On Mac OS X and Linux, VirtualBox stores images in the ~/VirtualBox VMs/ directory by default.

The following example creates a raw image in the current directory from a VirtualBox VDI image.

$ VBoxManage clonehd ~/VirtualBox\ VMs/image.vdi image.img --format raw