After you create a custom image, you can export it to Object Storage Service (OSS), and download it to your local machine for analysis, backup, or migration.
Usage notes
You cannot export encrypted images, custom images created from Alibaba Cloud Marketplace images, or Windows Server images.
You cannot directly export a custom image if one of its data disks is larger than 2 TiB.
To export the image, you must first distribute the data across multiple disks.
Procedure
Before you export
Prepare an OSS bucket in the same region as your target custom image to store the exported image file. During the export, you can select only OSS buckets using the Standard or Infrequent Access storage class. The Archive storage class is not supported. If you need to create a new bucket, see Create buckets.
Export a custom image to OSS
Console
Go to ECS console - Images. In the upper-left corner, select the region and resource group where the target resource is located.
On the Custom Images tab, find the target image and click Export Image in the Actions column.
Carefully review the Make Preparations and click Next. Confirm the prerequisites, and then click Continue.
Configure the parameters for Export Image File.
Image Format: Defaults to
Auto-detect
. You can also select RAW, VHD, QCOW2, VDI, or VMDK.OSS Bucket: Select an OSS bucket that is in the same region as the custom image.
Image File Name Prefix: For example, if you set the prefix to
Demo
, the name of the exported image file in the OSS bucket will be Demo-[System-generated file name].
Click OK to start exporting the custom image. The export duration depends on the image file size and the current task queue.
You can go to the ECS console - Task Management page to view the task's real-time progress or cancel the export. You can also log on to the OSS console to check the task result.
API
You can call the ExportImage operation to export a custom image. To stop an ongoing export, you can call the CancelTask operation.
Download and use the image file
After the image exports to OSS, you can download it to a local machine.
Download the image file to your local machine
If the image file is 5 GB or smaller: Log on to the OSS console, find the image file in the target OSS bucket, and click Download in the Actions column.
If the image file is larger than 5 GB: Use the command line tool ossutil to download the file. This multi-threaded tool supports resumable transfers and batch downloads, which makes it more stable and efficient.
Decompress the image file
RAW images are exported as.raw.tar.gz
files. After decompression, the file extension becomes.raw
.On Linux, run the command
tar -xzf <image-file-name>.raw.tar.gz
to extract the file.On macOS, use the
gnu-tar
utility to avoid compatibility issues.
(Optional) Convert the image format
If you need to convert an exported RAW image to another format, you can use the open-source toolqemu-img
. For instructions, see Convert the format of an image.
Billing
Exporting a custom image to OSS incurs costs for OSS resources, including:
OSS storage fees: You are charged for storing the exported image file in an OSS bucket, based on its size and storage duration.
OSS request fees: During the export process, the system calls OSS APIs for read and write operations, which incurs API request fees.
The image format you select affects the number of OSS API read operations, which can lead to different request fees. We recommend selecting the VHD format to minimize read operations.
OSS traffic fees: Downloading the image file from an OSS bucket to your local machine incurs an outbound data transfer fee. Accessing the file from an Elastic Compute Service (ECS) instance within the same Alibaba Cloud region is free.
Cost optimization tips
Clean up resources promptly: After downloading and verifying the image file, delete it from the OSS bucket to reduce storage costs.
Archive data: For long-term backup, configure a lifecycle rule for the OSS bucket to automatically transition the file to a lower-cost storage class, such as Infrequent Access or Archive, after a specified period.
FAQ
How do I fix a failed image export?
If an image export fails, find its error code on the ECS console - Task Management page or by calling the DescribeTaskAttribute operation. Use the error code to identify and resolve the issue.
Error code | Cause | Troubleshooting | Solution |
IMAGE_ALREADY_EXIST | A file (object) with the same name already exists in the OSS bucket. | Check whether a file (object) with the same name exists in the destination OSS bucket. |
|
How can I export a custom image if a single data disk is larger than 2 TiB?
If a data disk is larger than 2 TiB, you must copy its data to multiple new data disks that are each smaller than 2 TiB. You can then create a new custom image from these disks and export it. Follow these steps:
Log on to the created ECS instance. Run the
df -h
command to check the actual capacity of the data disk. Create one or more new, empty data disks based on the required capacity, attach them to the instance, and then copy the data from the original data disk to the new disks.Create snapshots of the new data disks and the system disk.
Create a custom image from the snapshots, and then export the custom image.
What are the different files in a multi-file image export?
If a custom image includes a data disk snapshot, files with system
in their names correspond to the system disk snapshot, and files with data
correspond to a data disk snapshot. Data disk files often include a mount point identifier (such as xvdb
or xvdc
) to help distinguish them.
Can an encrypted image be decrypted and then exported?
Encryption is irreversible. You cannot decrypt an Encrypted Image for export, and the data remains encrypted even after being exported.
To export data from an Encrypted Image, create an ECS instance from it. Inside the instance, perform the necessary data migration, and then create a new, unencrypted custom image to export.