• Image Management Service

ims
  1. Help Center
  2. Image Management Service
  3. User Guide
  4. Managing Private Images
  5. Quickly Importing an Image File
  6. Converting the Image File Format Using the Tool

Converting the Image File Format Using the Tool

  1. Verify that the Guest OS driver has been installed on the image file to be converted.

    It is recommended that you disable your antivirus and intrusion detection software. You can enable the software after the Guest OS driver is installed.

    For details, see Optimization Process.

    For details, see Optimization Process.

  2. Check the OS of the image file.
    1. If the image file runs a Linux OS, go to 3.
    2. If the image file runs a Windows OS, go to 4.
  3. Convert the format of a Linux image file.
    1. Create an ECS and with an EIP bound. (It is recommended that you use EulerOS as the ECS OS.) If an ECS is available, perform the following steps:
    2. Upload the image file to the ECS.
      • If the local host runs a Linux OS, run the scp command.

        For example, to upload image.qcow2 to the /usr/ directory on the ECS, run the following command:

        scp /var/image.qcow2 root@192.xxx.xx.xxx:/usr/

      • If the local host runs a Windows OS, use a file transfer tool, such as WinSCP, to upload the image file to the ECS.
    3. Download the required tool package, upload it to the ECS, and then decompress the package.

      For how to obtain the tool, see Overview.

    4. Go to the directory where qemu-img-hw is stored and run the chmod +x qemu-img-hw command.
    5. Run the qemu-img-hw command to convert the format of the image file to ZVHD2 or RAW. (ZVHD2 is recommended.) The following is an example command for converting a QCOW2 image file to a ZVHD2 image file:

      ./qemu-img-hw convert -p -O zvhd2 image. qcow2 image.zvhd2

    6. If the converted format is RAW, use CreateMF.jar contained in the tool package to generate the bitmap file. For details, see Generating a Bitmap File.
    7. Upload the image file that has been converted to the OBS bucket.

      Use s3cmd to upload the image file. If the image file is in RAW format, upload the bitmap file to the OBS bucket, too.

      For details, see Using s3cmd to Upload a Bitmap File.

  4. Convert the format of a Windows image file.
    1. Install qemu-img, the image format conversion tool.
    2. Run the qemu-img command to convert the image file to the RAW format. The following is an example of converting image.qcow2 to image.raw:

      qemu-img convert -p -O raw image. qcow2 image.raw

    3. Use CreateMF.jar contained in the tool package to generate the bitmap file. For details, see Generating a Bitmap File.
    4. Upload the image file that has been converted to the OBS bucket.

      Use OBS Browser to upload the external image file. For details, see the Object Storage Service User Guide.

      When uploading the external image file, you must select an OBS bucket with Standard storage.

  5. Create an image using the image file.

    Ensure that you select Fast Create during image creation.

Common qemu-img-hw Commands

  • Converting image file formats: qemu-img-hw convert -p -O Source image file Target image file

    The parameters are described as follows:

    -p: indicates the conversion progress.

    The part following -O (which must be in upper case) consists of the required format, source image file, and target image file.

    For example, run the following command to convert a QCOW image file to a ZVHD2 file:

    qemu-img-hw convert -p -O zvhd2 test1.qcow2 test2.zvhd2

  • Querying image file information: qemu-img-hw info Source image file

    An example command is qemu-img-hw info test.zvhd2.

  • Viewing the help information: qemu-img-hw –help

Common Errors During qemu-img-hw Running

  • Symptom:
    The following information is displayed when you run the qemu-img-hw command:
    ./qemu-img-hw: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./qemu-img-hw)

    Solution:

    Run the strings /lib64/libc.so.6 | grep glibc command to check the glibc version. If the version is too early, install the latest version. Run the following commands in sequence:

    wget http://ftp.gnu.org/gnu/glibc/glibc-2.15.tar.gz

    wget http://ftp.gnu.org/gnu/glibc/glibc-ports-2.15.tar.gz

    tar -xvf glibc-2.15.tar.gz

    tar -xvf glibc-ports-2.15.tar.gz

    mv glibc-ports-2.15 glibc-2.15/ports

    mkdir glibc-build-2.15

    cd glibc-build-2.15

    ../glibc-2.15/configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin

    NOTE:

    If configure: error: no acceptable C compiler found in $PATH is displayed, run the yum -y install gcc command.

    make

    make install

  • Symptom:

    The following information is displayed when you run the qemu-img-hw command:

       ./qemu-img-hw: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory

    Solution: Run the yum install libaio command.