Creating and Exporting an Image from a Cloud Server with Disk Capacity Greater Than 1 TiB
Scenarios
The IMS console only allows you to create images from cloud servers with disk capacity no greater than 1 TiB. If the disk capacity is greater than 1 TiB, you need to manually create an image file and upload it to an OBS bucket. This section guides you through creating and exporting an image for a disk greater than 1 TiB.
Resource Planning
| Resource | Description | Cost |
|---|---|---|
| One Linux ECS | Used to attach the disk for which you want to create an image and run commands to create an image file. | For pricing details, see the information displayed on the console. |
| One disk snapshot | To ensure that services are running properly, you need to create a snapshot for the target disk and then create a disk from the snapshot. | |
| Two disks |
| |
| One EIP | Used to access the Internet, and download and install the qemu-img and obsutil tools. | |
| One OBS bucket | Used to store the generated image file. | |
| qemu-img | An open-source tool used to create image files. | Free |
| obsutil | A tool used to upload files to an OBS bucket. |
After the image file is uploaded, delete the created ECS, disk snapshot, disks, and EIP in a timely manner to avoid generating any unnecessary expenditures.
Prerequisites
- You have obtained the temporary AK, SK, and security token of the current account to upload the image file to an OBS bucket. For details about how to obtain the temporary AK, SK, and security token, see Obtaining Temporary Access Keys and Security Tokens of an IAM User.
- You have created an OBS bucket to store the image file. For details about how to create an OBS bucket, see Creating a Bucket.
Process
The following example describes the process for exporting a data disk image from an ECS.
- You can create and export images for both system and data disks by following the instructions provided in this section.
- For a full-ECS image, create an ECS using the full-ECS image and then export the disk image by following the instructions provided in this section.
- Create a snapshot for the target disk. For details about how to create a disk snapshot, see Step 1: Create a Snapshot for the Target Disk.
- Create a disk named volume-data from the target disk snapshot. For details about how to create a disk from a snapshot, see Step 2: Create a Disk Named volume-data from the Target Disk Snapshot.
- Create an ECS and install the qemu-img and obsutil tools. For details, see Step 3: Create an ECS and Install qemu-img and obsutil.
- Attach the disk volume-data created in 2 to the created ECS. For details, see Step 4: Attach Disk volume-data to the Created ECS.
- Add a blank disk named volume-export to the created ECS and initialize the disk. For details, see Step 5: Add Disk volume-export to the ECS and Initialize the Disk.
- Create an image file. For details, see Step 6: Create an Image File.
- Upload the image file to the OBS bucket. For details, see Step 7: Upload the Image File to the OBS Bucket.
Step 1: Create a Snapshot for the Target Disk
To ensure that services are running properly, we strongly recommend that you create a snapshot for the target disk and then create a disk from the snapshot.
- Log in to the ECS console.
- Click the target ECS name. The ECS details page is displayed.
- Click the Disks tab and create a snapshot for the target disk.

- Confirm the snapshot configuration and click Create Now.

Step 2: Create a Disk Named volume-data from the Target Disk Snapshot
You can create a disk from the target disk snapshot. The disk has the same data as the snapshot.
- Log in to the EVS console.
- In the navigation pane on the left, choose Elastic Volume Service > Snapshots.
The Snapshots page is displayed.
- In the snapshot list, locate the target snapshot and click Create Disk in the Operation column.

- Configure disk parameters.
Disk name: volume-data
The disk name here is only an example and does not affect the process. You can customize the disk name as needed.
For details about how to set other parameters, see Purchasing an EVS Disk.
- Click Submit.
- In the disk list, view the disk status. When the disk status changes to Available, the disk is successfully created.
Step 3: Create an ECS and Install qemu-img and obsutil
- Purchase an ECS.
- Go to the Buy ECS page. On the displayed page, click the Custom Config tab in the upper left corner.
- Configure the required parameters for purchasing an ECS.
- Billing mode: Select Pay-per-use. You can create or delete ECSs at any time. After the resources are no longer needed, you are advised to delete them in a timely manner to avoid generating unnecessary expenditures.
- CPU architecture: Select x86.
- Image: Select a Linux image (CentOS 8.2 is used as an example).
- EIP: Bind an EIP to the ECS for public network access and for downloading and installing the qemu-img and obsutil tools.
Configure other parameters based on service requirements. For details, see Purchasing an ECS in Custom Config Mode.
- Confirm the configuration and submit the order.
Click back to ECS list. You can view the created ECS on the ECS list page.
- Log in to the Linux ECS using VNC.
- Locate the target ECS and click Remote Login in the Operation column.
- In the Logging In to a Linux ECS dialog box, expand Other Login Modes and click Log In in the VNC Login area.
- Enter the ECS password as prompted. If the message "Welcome to Huawei Cloud Service" is displayed, the login is successful.
- Install qemu-img.
- For CentOS, run the command below. For other Linux OSs, see Linux.
yum install -y qemu-img
- Run the following command to check whether the installation is successful:
qemu-img -V
If the version information and help documentation of the qemu-img tool are displayed in the command output, the installation is successful. If CentOS 8.2 is used, the command output is as follows.

- For CentOS, run the command below. For other Linux OSs, see Linux.
- Install obsutil.
- Run the following command to download obsutil:
wget https://obs-community.obs.cn-north-1.myhuaweicloud.com/obsutil/current/obsutil_linux_amd64.tar.gz
- Run the following command to extract the package:
tar -xzvf obsutil_linux_amd64.tar.gz
- Run the command below to list the obsutil directory. x.x.x indicates the obsutil version.
ll dr-x------ 2 root root 4096 Jan 5 2024 obsutil_linux_amd64_x.x.x -rw------- 1 root root 3845484 Mar 27 17:05 obsutil_linux_amd64.tar.gz
- Go to the obsutil directory. x.x.x indicates the obsutil version.
cd obsutil_linux_amd64_x.x.x
- Run the following command to add execute permissions to obsutil:
chmod 755 obsutil
This step is required, or error "No such file or directory" will be reported when you are querying the obsutil version number.
- Run the command below in the obsutil directory. If the obsutil version number is returned, the installation is successful.
./obsutil version obsutil version:5.7.9, obssdk version:3.24.12 operating system:linux, arch:amd64
- Run the following command to download obsutil:
Step 4: Attach Disk volume-data to the Created ECS
- Log in to the ECS console and access the ECS list page.
- Click the name of the target ECS that you want to attach the disk to. The ECS details page is displayed.
- On the Disks tab, click Attach Disk. The Attach Disk dialog box is displayed.
- Select the target disk (volume-data) and specify the disk as a data disk.
- Click OK. After the disk is attached, you can view the disk information on the Disks tab.

Step 5: Add Disk volume-export to the ECS and Initialize the Disk
Add a blank disk named volume-export to the created ECS and set the disk size to be the same as that of the target disk. This disk is used to store the generated image file.
- Add a disk named volume-export.
- Log in to the ECS console and access the ECS list page.
- Click the name of the target ECS. The ECS details page is displayed.
- On the Disks tab, click Add Disk. The page for purchasing EVS disks is displayed.
- Configure disk parameters.
Disk size: the same as the target disk size
Disk name: volume-export
The disk name here is only an example and does not affect the process. You can customize the disk name as needed.
For details about how to set other parameters, see Purchasing an EVS Disk.
- Click Submit.
- In the disk list, view the disk status. When the disk status changes to Available, the disk is successfully created. Before using this disk, you need to log in to the ECS and initialize it.

- Log in to the Linux ECS using VNC.
- Locate the target ECS and click Remote Login in the Operation column.
- In the Logging In to a Linux ECS dialog box, expand Other Login Modes and click Log In in the VNC Login area.
- Enter the ECS password as prompted. If the message "Welcome to Huawei Cloud Service" is displayed, the login is successful.
- Initialize the created blank disk.
There are no special requirements for the disk partition, file system, and mount directory. In this example, the mount directory is /export-image.
- Confirm the disk list.
- Run the following command to check whether the disk list contains the system disk, data disk, and blank disk:
lsblk
- View the displayed information. vda is the system disk, vdb is the data disk (volume-data), and vdc is the blank disk (volume-export).

- Run the following command to check whether the disk list contains the system disk, data disk, and blank disk:
- Run the following commands to initialize the disk:
fdisk /dev/vdc n p 1
- Enter n and press Enter to create a partition.
- Enter p and press Enter to create a primary partition.
- Enter 1 and press Enter to set a partition number. Partition number 1 is used in this example.
- Press Enter to select the start address of the partition.
- Press Enter to select the end address of the partition.
- Enter w and press Enter. The system automatically writes the partitioning results to the partition table. Then, the partition is created.
- Run the following command to format the file system:
mkfs -t ext4 /dev/vdc1
- Run the following command to create the /export-image directory:
mkdir -p /export-image
- Run the following command to mount the vdc1 partition to the /export-image directory:
mount /dev/vdc1 /export-image
- Run the following command to check whether the mounting is successful:
lsblk
If information similar to the following is displayed, the mounting is successful.

- Confirm the disk list.
Step 6: Create an Image File
- Run the following command to create the file image.qcow2 in the /export-image directory:
touch /export-image/image.qcow2
- Run the following command to check the device name:
lsblk -d -n -o NAME | sed 's|^|/dev/|'
The following information is displayed. /dev/vdb is the device name for disk volume-data, which stores service data. For details about how to determine whether a disk contains service data (how to identify a data disk), see Identifying Disk Functions.

- Run the following command to create an image file:
qemu-img convert -p -f raw -O qcow2 {{data-disk-name}} {{image-file-path}}
In this example, data-disk-name is dev/vdb, and image-file-path is /export-image/image.qcow2. The example command is as follows:qemu-img convert -p -f raw -O qcow2 /dev/vdb /export-image/image.qcow2

The command execution duration depends on the specifications and data volume. Please wait.
Step 7: Upload the Image File to the OBS Bucket
- Initialize the obsutil configuration.
The Linux OS is used as an example. For details, see Initializing the Configuration.
Run the following command to use the temporary AK, SK, and security token for initialization:./obsutil config -i=xxxxx -k=xxxxx -t=xxxxx -e=xxxxx
Table 2 Parameters Parameter
Mandatory
Description
i
Yes
The AK in permanent or temporary security credentials
k
Yes
The SK in permanent or temporary security credentials
e
Yes
The endpoint for accessing OBS. which can contain the protocol type, domain name, and port number (optional), for example, https://your-endpoint:443. (For security purposes, you are advised to use HTTPS. Port 443 can be omitted.)
For example, if you want to access OBS in the CN North-Beijing4 region, the address you actually visit is https://obs.cn-north-4.myhuaweicloud.com.
NOTE:You can click here to view the endpoints and regions where OBS is available.
t
No
The security token in the temporary security credentials. It is mandatory only when temporary security credentials are used.
- After the command is executed, the .obsutilconfig file will be automatically generated in the directory (~ in Linux) where obsutil commands run. This file contains all the configuration information of obsutil.
- For details about the parameters in the .obsutilconfig file, see Configuration Parameters.
- For details about how to obtain the temporary AK, SK, and security token, see Obtaining a User Token Through Password Authentication.
- The .obsutilconfig file contains the AK/SK information, so it is hidden by default to prevent leakage. To query this file, run the following command in the directory where you execute obsutil commands. Linux:
ls -a
Orls -al
- obsutil encrypts the AK/SK information in the .obsutilconfig file.
- After you use -i, -k, and -e to configure user authentication, the history command in Linux can query the configured values.
- Run the following command to upload the image file to the OBS bucket:
./obsutil cp {{image-file-path}} obs://{{obs-bucket-name}} /{{image-file-name}}
In this example, image-file-path is /export-image/image.qcow2. The example command is as follows:./obsutil cp /export-image/image.qcow2 obs://test-export-1/image.qcow2

- Check whether the image file is successfully uploaded.
Log in to the OBS console. On the bucket list page, search for the target bucket by name and check whether the image file exists. If yes, the image file has been uploaded.

Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot