After you create a custom image, you can export it to Object Storage Service (OSS). Then, you can download the image file to your computer for local analysis, backup, or migration.
Scope
-
You cannot export encrypted images, custom images created from Alibaba Cloud Marketplace images, or images of the Windows Server operating system.
-
When you export a custom image, the following capacity limits apply to a single data disk:
-
RAW, VDI, or QCOW2: 2 TiB
-
VHD: Up to 2040 GiB
-
VMDK: A maximum of 2000 GiB
If a single disk exceeds these limits and you still need to export it, you can distribute the data across multiple disks before exporting.
-
Procedure
Preparations
Create an OSS bucket in the same region as the custom image to temporarily store the exported image. You can export images only to OSS buckets that use the Standard or Infrequent Access storage class. Archive Storage is not supported. For more information about how to create a bucket, see Create a bucket.
Export the custom image to OSS
Console
-
Go to the ECS console - Images page. In the upper-left corner, select the resource group and region of the target resource.
-
On the Custom Images tab, find the target image. In the Operation column, click Export Image.
-
Carefully review the information in the Make Preparations step and click Next. Confirm that you have completed the prerequisites, and then click Continue.
-
In the Export Image File section, configure the following parameters.
-
Image Format: The image format is automatically detected by default. You can select RAW, VHD, QCOW2, VDI, or VMDK.
-
OSS Bucket: Select an OSS bucket in the same region as the custom image.
-
Image File Name Prefix: Specify a prefix for the image file name. For example, if you set the prefix to Demo, the exported file in the OSS bucket is named Demo-[System-generated file name].
-
-
Click OK to start the export. The time required for the export depends on the size of the image file and the current load of the export task queue.
You can go to the ECS console - Task Management page to query the real-time progress of the task by its ID or cancel the export task. You can also log on to the OSS console to view the task result.
API
You can call the ExportImage API operation to export a custom image. To cancel a running export task, you can call the CancelTask API operation.
Download and use image files
After you export an image to OSS, you can download the image to your local machine for further processing.
-
Download the image file to your local machine
-
For image files 5 GB or smaller: Log on to the OSS Management Console. Find the image file in the target OSS bucket and click Download in the Actions column.
-
For image files larger than 5 GB: Use the ossutil command-line tool to download the file. The tool supports resumable, batch, and multi-threaded downloads for greater stability and efficiency.
-
-
Decompress the image file
If you select RAW as the image format during export, the file name extension is .raw.tar.gz by default. After you decompress the file, the file name extension is .raw.-
On Linux, run the following command to decompress the file:
tar -xzf <image_file_name>.raw.tar.gz -
On macOS, use the
gnu-tartool to decompress the file to avoid compatibility issues.
-
-
(Optional) Convert the image format
To convert the exported RAW image to another format, use the open source toolqemu-img. For more information, see Convert image formats.
Billing details
When you export a custom image to Object Storage Service (OSS), fees are incurred for the required OSS resources. These fees include the following:
-
OSS storage fees: The exported image file is stored as an object in an OSS bucket. Billing is based on the storage duration and file size.
-
OSS request fees: During the export process, the system calls OSS APIs to read and write files. These calls incur request fees.
Different image formats result in different numbers of OSS API read calls. This variation affects the request fees. To reduce costs, select the VHD format because it requires fewer read calls.
-
OSS traffic fees: Outbound public traffic fees are incurred when you download an image file from an OSS bucket to a local device. Accessing the file from an ECS instance in the same Alibaba Cloud region over the internal network is free of charge.
Cost optimization suggestions
-
Clean up files: After you download an image to a local device and verify that it is usable, delete image files that you no longer need from the OSS bucket. This helps you save on storage fees.
-
Archive data: To store exported image files as long-term backups, set a lifecycle rule for the OSS bucket. The rule can automatically transition the files to a lower-cost storage class, such as Infrequent Access or Archive Storage, after a specified period.
FAQ
How to fix a failed image export
If an image export task fails, you can find the error code on the ECS console - Task Management page or by calling the DescribeTaskAttribute API operation to identify and resolve the problem.
|
Error code |
Cause |
Troubleshooting |
Solution |
|
IMAGE_ALREADY_EXIST |
A file (Object) with the same name already exists in the OSS bucket. |
Check if a file (Object) with the same name exists in the destination OSS bucket. |
|
How to export a custom image if a data disk is larger than 2 TiB
If a data disk is larger than 2 TiB, copy its data to multiple new data disks that are each smaller than 2 TiB. Then, create a custom image and export it. Follow these steps:
-
Log on to the ECS instance remotely and run the
df -hcommand to check the data disk capacity. Create and attach new empty data disks as needed, and then copy the data from the original 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 included in an exported image?
An exported custom image that contains data disk snapshots consists of multiple files. Files with system in their names are system disk snapshots, and files with data in their names are data disk snapshots. Data disk files also typically include a mount target identifier, such as xvdb or xvdc, to help distinguish them.
Can encrypted images be decrypted before export?
No, they cannot. Encryption is an irreversible operation. You cannot decrypt an encrypted image for export. The data remains encrypted and cannot be decrypted even after the image is exported.
To export data from an encrypted image, create an ECS instance from the image. On the instance, perform the necessary configurations and data migration. Then, create a new, unencrypted custom image from that instance and export the new image.