All Products
Search
Document Center

Elastic Compute Service:Convert image formats

Last Updated:Jun 21, 2026

ECS supports importing images in RAW, QCOW2, VMDK, and VHD formats. To import an image in a different format, you must first convert it by using the qemu-img tool.

Scope

You can convert images between RAW, QCOW2, QCOW1, VMDK, VDI, VHD, VHDX, and QED formats.

Procedure

Windows

The following example uses Windows Server 2022.

  1. Install the conversion tool.

    Download the qemu-img tool and install it to C:\Program Files\qemu.

  2. Configure environment variables.

    Add the qemu executable path to the PATH environment variable. This lets you run the tool from any command-line interface.

    1. Right-click the image.png icon and select System.

    2. Find and click View advanced system settings.

    3. In the System Properties window, on the Advanced tab, click Environment Variables....

    4. In the System variables section, find and select the Path variable.

      • If it exists: Select it and click Edit. On the Edit environment variable page, click New, and then add C:\Program Files\qemu.

      • If the Path variable does not exist: Click New. In the Variable name field, enter Path. In the Variable value field, enter C:\Program Files\qemu.

    5. Verify that the environment variable is configured correctly.

      1. Right-click the image.png icon, select Run, and then enter PowerShell.

      2. In the PowerShell window, run the qemu-img --version command. If the command returns version information, the environment variable is configured correctly.

  3. Convert the image format.

    1. Convert the image file format.

      qemu-img convert [options] <source_image_path> <destination_image_path>

      Description of [options]:

      • -f <source_format>: Specifies the format of the source image, such as vhdx, vdi, qed, qcow, or vpc (for VHD).

        To view all supported source formats, run the qemu-img --help command and find the Supported formats list in the output.
      • -O <destination_format>: (Uppercase O) Specifies the format of the destination image, such as raw, qcow2, vpc (for VHD), or VMDK.

      • -p: Displays the conversion progress as a percentage.

      Examples:

      # Scenario 1: Convert an image from VHD to RAW format. The path of the source image is D:\convertimage\source.vhd, and the path of the destination image is D:\convertimage\target.raw.
      qemu-img convert -p -f vpc -O raw D:\convertimage\source.vhd D:\convertimage\target.raw
      # Scenario 2: Convert an image from VHDX to QCOW2 format. The path of the source image is D:\convertimage\source.vhdx, and the path of the destination image is D:\convertimage\target.qcow2.
      qemu-img convert -p -f vhdx -O qcow2 D:\convertimage\source.vhdx D:\convertimage\target.qcow2
    2. Verify the conversion.

      qemu-img info <destination_image_path>
      For example, if the path of the destination image is D:\convertimage\target.raw, run the command qemu-img info D:\convertimage\target.raw.

      The conversion is successful if the file format in the output matches the destination format.

  4. Use the cp command of ossutil 2.0 to upload the destination image file to OSS for import.

    The OSS console does not support files larger than 5 GB. Use ossutil to upload larger files.

macOS

  1. Install the conversion tool.

    brew install qemu
    If you receive a command not found error, you may need to install the Homebrew package manager first. Run /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)", follow the prompts to complete the installation, and then run the command to install the qemu tool again.
  2. Convert the image format.

    1. Convert the image file format.

      qemu-img convert [options] <source_image_path> <destination_image_path>

      [Options] Description:

      • -f <source_format>: Specifies the format of the source image, such as vhdx, vdi, qed, qcow, or vpc (for VHD).

        To view all supported source formats, run the qemu-img --help command and find the Supported formats list in the output.
      • -O <destination_format>: (Uppercase O) Specifies the format of the destination image, such as raw, qcow2, vpc (for VHD), or VMDK.

      • -p: Displays the conversion progress as a percentage.

      Examples:

      # Scenario 1: Convert an image from VHD to RAW format. The path of the source image is /ConvertImage/source.vhd, and the path of the destination image is /ConvertImage/target.raw.
      qemu-img convert -p -f vpc -O raw /ConvertImage/source.vhd /ConvertImage/target.raw
      # Scenario 2: Convert an image from VHDX to QCOW2 format. The path of the source image is /ConvertImage/source.vhdx, and the path of the destination image is /ConvertImage/target.qcow2.
      qemu-img convert -p -f vhdx -O qcow2 /ConvertImage/source.vhdx /ConvertImage/target.qcow2
    2. Verify the conversion.

      qemu-img info <destination_image_path>
      For example, if the path of the destination image is /ConvertImage/target.raw, run the command qemu-img info /ConvertImage/target.raw.

      The conversion is successful if the file format in the output matches the destination format.

  3. Use the cp command of ossutil 2.0 to upload the destination image file to OSS for import.

    The OSS console does not support files larger than 5 GB. Use ossutil to upload larger files.

Linux

  1. Install the conversion tool.

    • For Alibaba Cloud Linux and CentOS:

      sudo yum install -y qemu-img
    • For Ubuntu and Debian:

      sudo apt-get update
      sudo apt-get install -y qemu-utils
  2. Convert the image format.

    1. Convert the image file format.

      sudo qemu-img convert [options] <source_image_path> <destination_image_path>

      [Options] Description:

      • -f <source_format>: Specifies the format of the source image, such as vhdx, vdi, qed, qcow, or vpc (for VHD).

        You can run the command sudo qemu-img --help | grep "Supported formats" to view the supported source formats.
      • -O <destination_format>: (Uppercase O) Specifies the format of the destination image, such as raw, qcow2, vpc (for VHD), or VMDK.

      • -p: Displays the conversion progress as a percentage.

      Examples:

      # Scenario 1: Convert an image from VHD to RAW format. The path of the source image is /ConvertImage/source.vhd, and the path of the destination image is /ConvertImage/target.raw.
      sudo qemu-img convert -p -f vpc -O raw /ConvertImage/source.vhd /ConvertImage/target.raw
      # Scenario 2: Convert an image from VHDX to QCOW2 format. The path of the source image is /ConvertImage/source.vhdx, and the path of the destination image is /ConvertImage/target.qcow2.
      sudo qemu-img convert -p -f vhdx -O qcow2 /ConvertImage/source.vhdx /ConvertImage/target.qcow2
    2. Verify the conversion.

      sudo qemu-img info <destination_image_path>
      For example, if the path of the destination image is /ConvertImage/target.raw, run the command sudo qemu-img info /ConvertImage/target.raw.

      The conversion is successful if the file format in the output matches the destination format.

  3. Use the cp command of ossutil 2.0 to upload the destination image file to OSS for import.

    The OSS console does not support files larger than 5 GB. Use ossutil to upload larger files.

FAQ

  • Convert an ISO image to a supported format

    The qemu-img tool cannot directly convert an ISO image to RAW, VHD, QCOW2, or VMDK format. You must use a tool such as VirtualBox to create a virtual machine and install an operating system from the ISO image. Then, you can export the virtual machine to a supported format. For more information, see Create a virtual machine and install an operating system (Linux) or Create a virtual machine and install an operating system (Windows).

  • "Unknown driver 'vhd'" error

    In qemu-img, the format identifier for VHD is vpc, not vhd. When you run the conversion command, use vpc as the format identifier.

    For example, to convert an image from VHDX format to VHD format, run the following command: qemu-img convert -f vhdx -O vpc source.vhdx target.vhd.

References

  • For more information about the qemu-img tool, see the official QEMU documentation.

  • The qemu-img tool does not support Open Virtualization Appliance (OVA) or Open Virtualization Format (OVF) formats. These formats are maintained by the Distributed Management Task Force (DMTF). For more information, see the DMTF official website.