This section describes how to convert the format of a large image file on a Linux server and then quickly import it to the cloud platform. You are advised to use a EulerOS ECS for converting image file formats and generating bitmap files.
In Linux, you are advised to use qemu-img-hw to convert image formats.
For example, to upload image01.qcow2 to the /usr/ directory of the ECS, run the following command:
scp /var/image01.qcow2 root@xxx.xxx.xx.xxx:/usr/
xxx.xxx.xx.xxx indicates the EIP bound to the ECS.
Tool Package | How to Obtain |
|---|---|
qemu-img-hw.zip | |
createMF.zip |
cd /usr/qemu-img-hw
chmod +x qemu-img-hw
Command format:
./qemu-img-hw convert -p -O Target_image_format Source_image_file Target_image_file
For example, run the following command to convert an image01.qcow2 file to an image01.zvhd2 file:
./qemu-img-hw convert -p -O zvhd2 image01.qcow2 image01.zvhd2
Run the following commands to check whether JDK is installed:
source /etc/profile
java -version
If a Java version is displayed, JDK has been installed.
cd /usr/createMF
java -jar CreateMF.jar /Original RAW file path/Generated .mf file path
Example:
java -jar CreateMF.jar image01.raw image01.mf
If s3cmd has been installed, skip this step.
yum install python-setuptools
yum install wget
wget https://github.com/s3tools/s3cmd/archive/master.zip
mv master.zip s3cmd-master.zip
unzip s3cmd-master.zip
cd s3cmd-master
python setup.py install
Run the following command to configure s3cmd:
s3cmd --configureAccess Key: Enter an AK.Secret Key: Enter an SK.Default Region: Enter the region where the bucket is located.S3 Endpoint: Refer to the OBS endpoint.DNS-style bucket+hostname:port template for accessing a bucket: Enter a server address with a bucket name, for example, mybucket.obs.myclouds.com.Encryption password: Press Enter.Path to GPG program: Press Enter.Use HTTPS protocol: Specifies whether to use HTTPS. The value can be Yes or No.HTTP Proxy server name: Specifies the proxy address used to connect the cloud from an external network. (If you do not need it, press Enter.)HTTP Proxy server port: Specifies the proxy port used to connect to the cloud from an external network (If you do not need it, press Enter.)Test access with supplied credentials? y(If "Success. Your access key and secret key worked fine :-)" is displayed, the connection is successful.)Save settings? y (Specifies whether to save the configurations. If you enter y, the configuration will be saved.)
The configurations will be stored in /root/.s3cfg. If you want to modify these configurations, run the s3cmd --configure command to configure the parameters or run the vi .s3cfg command to edit the .s3cfg file.
s3cmd put image01.zvhd2 s3://mybucket/
The .mf bitmap file must be in the same OBS bucket as the RAW image file.
You can register a private image using the converted ZVHD2 or RAW file on the console or using an API.
Method 1: Register a private image on the console.
For details about the parameters, see Registering an Image File as a Private Image.
Run the following command to check the system disk capacity in the image file:
qemu-img-hw info test.zvhd2
Method 2: Register a private image using an API.
The API is POST /v2/cloudimages/quickimport/action.
For details about how to call this API, see "Importing an Image File Quickly" in Image Management Service API Reference.
The parameters are described as follows:
-p: indicates the conversion progress.
The part following -O (which must be in upper case) consists of the target image format, source image file, and target image file.
For example, run the following command to convert a QCOW2 image file to a ZVHD2 file:
qemu-img-hw convert -p -O zvhd2 test.qcow2 test.zvhd2
An example command is qemu-img-hw info test.zvhd2.
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
If configure: error: no acceptable C compiler found in $PATH is displayed, run the yum -y install gcc command.
make
make install
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 first.
The following information is displayed when you run the qemu-img-hw command:
./qemu-img-hu: error while loading shared libraries: libcrypto.so.10: cannot open shared object file: No such file or directory
Solution: Run openssl version to check whether the OpenSSL version is later than 1.0. If yes, install OpenSSL 1.0.
Run the following commands to install OpenSSL 1.0:
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_0_2k/openssl-1.0.2k.tar.gz
tar -xvf openssl-1.0.2k.tar.gz
cd openssl-1.0.2k
./config -d shared --prefix=/tmp/openssl (custom installation directory)
make
make install
cp /tmp/openssl/lib/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.10
Delete the /usr/lib64/libcrypto.so.10 file if you do not need it any longer.