ECS can only import image files in the RAW, VHD, or qcow2 format. If you want to import image files in other formats, you must first convert their formats. This topic describes how to use the qemu-img tool to convert other image file formats to VHD or RAW.

Background information

The qemu-img tool supports the following formats:
  • Convert images from the RAW, qcow2, qcow1, VMDK, VDI, VHD (VPC), VHDX, or QED format to the VHD format.
  • Convert between RAW and VHD.
Note The qemu-img tool cannot convert ISO images to the VHD or RAW format. To convert the image format, install the ISO image to VHD or RAW media, and then create an image in the specified format.

Windows

To install qemu-img and convert the image file format, perform the following steps:

  1. Download and install qemu-img.
    This example uses installation path C:\Program Files\qemu. Visit qemu-img to download the qemu-img tool.
  2. Create an environment variable for qemu-img.
    1. Choose Start > Computer, right-click Computer, and choose Properties from the shortcut menu.
    2. In the left-side navigation pane, click Advanced System Settings.
    3. In the System Properties dialog box that appears, click the Advanced tab and then click Environment Variables.
    4. In the Environment Variables dialog box that appears, find the Path variable from the System Variables section and then click Edit. If the Path variable does not exist, click New.
    5. Add a system variable value.
      • In the Edit System Variable dialog box that appears, add C:\Program Files\qemu to the Variable Value field. Use semicolons (;) to separate different variable values.
      • In the New System Variable dialog box that appears, enter Path in the Variable Name field and enter C:\Program Files\qemu in the Variable Value field.
  3. Check whether the environment variable is properly configured.
    1. Open Command Prompt in Windows.
    2. Run the qemu-img --help command.
    If the command output is displayed, the environment variable is properly configured.
  4. In Command Prompt, run the cd [Directory of the source image file] command to switch to a new file directory, for example, cd D:\ConvertImage.
  5. Run the qemu-img convert -f qcow2 -O raw centos.qcow2 centos.raw command to convert the image file format.
    • The -f parameter is followed by the source image format.
    • The -O parameter (uppercase is required) is followed by the target image format, source file name, and target file name.

When the conversion is complete, the target file will appear in the directory where the source image file is located.

Linux

To install qemu-img and convert the image file format, perform the following steps:

  1. Install the qemu-img tool.
    Example:
    • For Ubuntu, run the apt-get install qemu-utils command.
      If the error Unable to locate package qemu-utils is returned during the installation on Ubuntu, run the following commands to install the qemu-img tool:
      apt-get update #Update the package list.
      apt-get install qemu-utils #Install the qemu-img tool.
    • For CentOS, run the yum install qemu-img command.

      Run pip install -r requirements.txt to install all of the dependent libraries based on the libraries contained in the requirements.txt file of cloud-init.

  2. Run the qemu-img convert -f qcow2 -O raw centos.qcow2 centos.raw command to convert the image file format.
    • The -f parameter is followed by the source image format.
    • The -O parameter (uppercase is required) is followed by the target image format, source file name, and target file name.

When the conversion is complete, the target file will appear in the directory where the source image file is located.

What to do next

Import custom images