Convert the image format

Last updated:2021-08-04 11:26:31

KEC allows you to import only image files in the RAW, VHD, QCOW2, and VMDK formats. For image files in any other format, you must convert the format before you import the image files.

This topic describes how to convert the format of image files by using the qemu-img tool.

Local Windows system

Preparations

  1. Download the qemu-img tool.

  2. Install the qemu-img tool by using default settings.
    In this example, the installation directory is D:\qemu.

Configure environment variables

  1. In the search box next to the Start menu, type This PC and press Enter.

  2. Right-click This PC and select Properties. Then, select Advanced system settings from the left navigation pane.

  3. Click the Advanced tab and then click Environment Variables.

  4. Select Path in the system variables and click Edit. If there is no Path variable, click New.

  5. Add system variable values.

    • To create a Path variable from scratch, add the Path variable in the New System Variable dialog box. The variable value is D:\qemu.
    • To edit the Path variable, click New in the Edit Environment Variable dialog box, and then add D:\qemu.

Test environment variables

  1. Open Windows Command Prompt.

    1. Press Windows logo key and R on your keyboard at the same time.
    2. Enter cmd in the Run dialog box.
    3. Click OK.
  2. Run the qemu-img --help command. If the result shown in the following figure is displayed, the environment variables are successfully configured.
    image.png

Convert the image format

  1. Run the cd command to go to the directory of the source image file. In this example, run the cd D:\convert command.

  2. Run the qemu-img convert command to convert the format. After the conversion is complete, the target image is generated in the directory of the source image.

    Example : qemu-img convert -f qcow2 -O vpc source.qcow2 target.vpc

    Parameter Description
    qcow2 The format of the source image file.
    vpc The format of the target image file.
    source.qcow2 The name of the source image file.
    target.vpc The name of the target image file.

    Note: O in -O is in uppercase.

Local Linux system

  1. Install the qemu-img tool. For more information, see Install QEMU.

    • If the local operating system is Ubuntu, run the apt-get install qemu-utils command.
    • If the local operating system is CentOS, run the yum install qemu-img command.
  2. Run the qemu-img convert command to convert the format. After the conversion is complete, the target image is generated in the directory of the source image.

    Example: qemu-img convert -f qcow2 -O vpc source.qcow2 target.vpc.

    • qcow2: the format of the source image file.
    • vpc: the format of the target image file.
    • source.qcow2: The name of the source image file.
    • target.vpc: The name of the target image file.
    • -O: O is in uppercase.

qemu-img parameter corresponding to common image formats

Image format qemu-img parameter
QCOW2 qcow2
QED qed
RAW raw
VDI vdi
VHD vpc
VMDK vmdk

Did you find the above information helpful?

Unhelpful
Mostly Unhelpful
A little helpful
Helpful
Very helpful

What might be the problems?

Insufficient
Outdated
Unclear or awkward
Redundant or clumsy
Lack of context for the complex system or functionality

More suggestions

0/200

Please give us your feedback.

Submitted

Thank you for your feedback.

问题反馈