All Products
Search
Document Center

Elastic Compute Service:Convert image formats

Last Updated:Dec 12, 2025

Elastic Compute Service (ECS) supports importing images only in RAW, QCOW2, VMDK, and VHD formats. If your image is in another format, use the qemu-img tool to convert it before importing it.

Usage note

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

Procedure

Windows

This topic uses Windows Server 2022 as an example.

  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's file path to the PATH environment variable. This allows you to run the tool from any command-line interface.

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

    2. In the left-side navigation pane, search for and open View advanced system settings.

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

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

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

        image.png

        image.png

      • If the variable does not exist: Click New.... Set Variable name to Path and Variable value to C:\Program Files\qemu.

    5. Test the environment variable configuration.

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

      2. In the PowerShell window, run the qemu-img --version. If the output shows the tool's version, the environment variable is configured correctly.

  3. Convert the image format.

    1. Run the conversion command.

      qemu-img convert [Options] <Full path of the source image> <Full path of the destination image>

      [OPTIONS] include:

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

        You can view the supported source formats in the Supported image formats field of the output from the qemu-img --help command.
      • -O <destination_format>: (Uppercase O) Specifies the format of the target image, such as raw, qcow2, vpc (for VHD), or vmdk.

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

      Command examples:

      # Scenario 1: Convert an image from VHD to RAW. The full path of the source image is D:\convertimage\source.vhd, and the full 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. The full path of the source image is D:\convertimage\source.vhdx, and the full 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 <Full path of the destination image>
      For example, if the full path to the target image is D:\convertimage\target.raw, run qemu-img info D:\convertimage\target.raw.

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

  4. Use the ossutil cp command to upload the destination image file to Object Storage Service (OSS) for later import.

    The OSS console does not support uploading files larger than 5 GB. Use ossutil for larger files.

MacOS

  1. Install the conversion tool.

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

    1. Run the conversion command.

      qemu-img convert [Options] <Full path of the source image> <Full path of the destination image>

      [OPTIONS] include:

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

        You can view the supported source formats in the Supported image formats field of the output from the qemu-img --help command.
      • -O <destination_format>: (Uppercase O) Specifies the format of the target image, such as raw, qcow2, vpc (for VHD), or vmdk.

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

      Command examples:

      # Scenario 1: Convert an image from VHD to RAW. The full path of the source image is /ConvertImage/source.vhd, and the full 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. The full path of the source image is /ConvertImage/source.vhdx, and the full 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 <Full path of the destination image>
      For example, if the full path to the target image is /ConvertImage/target.raw, run qemu-img info /ConvertImage/target.raw.

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

  3. Use the cp command of ossutil 2.0 to upload the target image file to OSS so you can import it later.

    The OSS console does not support uploading files larger than 5 GB. Use ossutil for 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. Run the conversion command.

      sudo qemu-img convert [Options] <Full path of the source image> <Full path of the destination image>

      [OPTIONS] include:

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

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

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

      Command examples:

      # Scenario 1: Convert an image from VHD to RAW. Source: /ConvertImage/source.vhd. Target: /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. Source: /ConvertImage/source.vhdx. Target: /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 <Full path of the destination image>
      For example, if the full path to the target image is /ConvertImage/target.raw, run qemu-img info /ConvertImage/target.raw.

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

  3. Use the cp command of ossutil 2.0 to upload the target image file to OSS so you can import it later.

    The OSS console does not support uploading files larger than 5 GB. Use ossutil for larger files.

FAQ

  • How can I convert an ISO image to a supported format (RAW, VHD, QCOW2, or VMDK)?

    The qemu-img tool does not directly support converting ISO images to RAW, VHD, QCOW2, or VMDK formats. You must first use a virtualization tool such as VirtualBox to create a virtual machine and install an operating system, and then export the virtual machine to a supported format. For detailed instructions, see Create a virtual machine and install an operating system (Linux) or Create a virtual machine and install an operating system (Windows).

  • What do I do if I get an "Unknown driver 'vhd'" error when converting an image to the VHD format?

    In qemu-img, the format identifier for VHD is vpc, not vhd. Use vpc as the format identifier.

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

References

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

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