All Products
Search
Document Center

Elastic Compute Service:Import custom images

Last Updated:Jun 21, 2024

When you deploy services in the cloud, you can import on-premises image files in the Alibaba Cloud Elastic Compute Service (ECS) console or have ECS images automatically generated for your servers by using Server Migration Center (SMC). This topic describes the use scenarios and operation procedures of the preceding methods.

Prerequisites

Before you import an image in the ECS console, complete the following operations:

  • Make sure that both your Alibaba Cloud account and Resource Access Management (RAM) user have the permissions that are required to import custom images.

    • You can log on to the RAM console by using your Alibaba Cloud account. Then, attach the AliyunECSImageImportDefaultRole role to ECS to grant access permissions on Object Storage Service (OSS) resources to ECS.

    • If you use a RAM user, contact the owner of the corresponding Alibaba Cloud account to grant operation permissions on OSS buckets to the RAM user before you proceed. For more information, see the Grant permissions for different scenarios section of the "Upload image files to OSS" topic.

  • Obtain the URL of the image file that you want to import in the OSS console. For more information, see Use object URLs.

  • Familiarize yourself with the usage limits and requirements of images. For more information, see Instructions for importing images.

Scenarios

The following table describes the scenarios of the methods that are used to import custom images.

Method

Scenario

Import a custom image in the ECS console

You can import custom images in the ECS console in the following scenarios:

  • Import on-premises image files to Alibaba Cloud.

  • Import image files from servers of third-party cloud service providers to Alibaba Cloud.

Import a custom image by using SMC

This method allows you to use SMC to migrate one or more servers such as servers in Internet data centers, virtual machines, or cloud servers from other cloud platforms to Alibaba Cloud. When your servers are migrated, SMC generates ECS images for the servers.

Import a custom image in the ECS console

Video tutorial

The following video shows how to import a custom image in the ECS console.

To import an image file from your on-premises machine to ECS, perform the following steps.

Step 1: Import a custom image in the ECS console

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Images.

  3. In the upper-left corner of the top navigation bar, select a region.

    Important

    Make sure that you select the region of the OSS bucket where the image file is stored.

  4. In the upper-right corner of the Images page, click Import Image in the Import Image section.

    image.png

  5. In the Prepare Before Import step, check whether the preparations are completed and click Next.

  6. (Conditionally required) Grant ECS the permissions to access OSS resources.

    If you import an image for the first time and did not grant ECS permissions to access OSS resources, you can perform operations in the Import Image dialog box.

    1. In the Upload Image File to OSS section of the Prepare Before Import step, click AliyunECSImageImportDefaultRole.

    2. On the Cloud Resource Access Authorization page, view the AliyunECSImageImportDefaultRole and AliyunECSImageExportDefaultRole roles and click Confirm Authorization Policy.

  7. In the Import Image dialog box, click Next.

  8. Click Confirm.

  9. In the Import Image File step, configure the parameters that are described in the following table.

    Parameter

    Required

    Description

    Current Region

    Yes

    This parameter is automatically set to the current region. To change the region, close the Import Image dialog box and select a different region in the left part of the top navigation bar. Then, click Import Image to re-open the Import Image dialog box and continue to configure other parameters.

    Important

    Make sure that you select the region of the OSS bucket where the image file is stored.

    Image File URL

    Yes

    Enter the URL of the image file.

    Image Name

    Yes

    Enter a name for the custom image. The name must be 2 to 128 characters in length and can contain letters, digits, periods (.), underscores (_), colons (:), and hyphens (-). It must start with a letter.

    OS Type

    Yes

    Select the operating system type of the image that you want to import from OSS.

    Valid values: windows and linux. If your image is a non-standard platform image, select linux.

    OS Version

    Yes

    Select the operating system version of the image that you want to import from OSS.

    Architecture

    Yes

    Select an architecture based on the operating system of the image that you want to import from OSS. Valid values:

    • 32-bit OS

    • 64-bit OS

    • Arm 64-bit OS

    Image Check

    No

    Optional. The image check feature checks whether imported custom images are valid and whether the images can be used to create full-featured ECS instances.

    By default, Check After Creation is selected, and the image check feature checks the custom image immediately after the image is created. After the image is checked, you view the check results in the Check Results column corresponding to the image on the Custom Images tab and resolve issues by using the repair feature of Image Builder or based on the solutions that are provided in the check results. For information about check items and solutions to image issues, see Overview.

    Note

    Only specific operating systems support the image check feature. For information about the operating systems that do not support the image check feature, see Operating system limits for image check.

    Boot Mode

    No

    Select the boot mode of the image that you want to import from OSS. Valid values: BIOS and UEFI. For information about boot modes, see Best practices for ECS instance boot modes.

    Image Format

    No

    Select the format of the image that you want to import from OSS. Valid values: Auto-detect, RAW, QCOW2, and VHD.

    • If you do not know the image format, you can select Auto-detect to allow the system to identify the image format.

    • If you want to select an image format, we recommend that you select QEMU Copy-On-Write version 2 (QCOW2) or Virtual Hard Disk (VHD) which generates a smaller transmission footprint.

    Note

    License Type

    No

    Select a license type to activate the source operating system after the image is imported. Valid values:

    • Auto (default): Alibaba Cloud checks the source operating system and allocates a license. If this value is selected, the system checks whether a license has been allocated by Alibaba Cloud for your specified operating system version, and then performs an operation based on the check result.

      • If a license has been allocated by Alibaba Cloud for the specified operating system version, the system allocates the license to the imported image.

      • If no license has been allocated by Alibaba Cloud for the specified operating system version, the system switches the license type to BYOL.

    • Alibaba Cloud License: the license allocated by Alibaba Cloud. If this value is selected, a license allocated by Alibaba Cloud is applied based on your selected operating system version.

    • BYOL: the license that comes with the source operating system. If this value is selected, make sure that your license key can be used in Alibaba Cloud.

      For information about Red Hat Cloud Access, see Overview. For information about Windows licenses, see Microsoft licenses and Software Assurance.

    Disk Configurations

    No

    Specify the system disk size and add image files that contain data from data disks.

    1. Select Configure Disk Attributes.

    2. You need to only specify the system disk size. Retain default values for other system disk parameters. The size of the system disk ranges from 1 GiB to 2,048 GiB. The disk size that you specify cannot be smaller than the size of the image file.

      Note

      The image file size is the size of the image file that you want to import from OSS. You can view the image file size in the OSS console.

    3. Click increasesData Disk and configure the parameters.

      • Image File URL: Enter the URL of a data disk image file. Obtain the URL of the data disk image file by using the same method as for the system disk image file.

      • Mount Point: The parameter is set by the system.

      • Image Format: Select the format of the image file that you want to import from OSS. Valid values: Auto-detect, RAW, QCOW2, and VHD.

      • Disk SizeGiB: The size of a disk ranges from 1 GiB to 2,048 GiB and must be larger than or equal to the size of the image file.

        Note

        The image file size is the size of the image file that you want to import from OSS. You can view the image file size in the OSS console.

    Image Description

    No

    Enter a description for the custom image.

    Tag

    No

    Add tags to the new custom image. You can use tags to classify images for simple search operations and batch operations.

    Resource Group

    No

    Specify a resource group for the custom image to simplify management.

    Important

    If you use an Alibaba Cloud account to attach policies to a RAM user and the permissions granted are limited to a specific resource group, select that resource group.

  10. Confirm that your configurations are correct and click OK.

    Then, the system creates a task to import the image.

Step 2: (Optional) View or cancel the image import task

  • View the image import task

    You can go to the Custom Images tab on the Images page or to the Task Management page to view the progress of the image import task.

    Note

    The amount of time required to import a custom image varies based on the image file size and the number of concurrent import tasks.

    • When you import an image, a snapshot is automatically generated. You can view information about the snapshot on the Snapshots page in the ECS console. When the image import task is in progress, the status of the snapshot is Failed. When the image import task is completed, the snapshot enters the Successful state and the image enters the Available state. The total size of the snapshot is equal to the size of the imported image file, regardless of the system disk size that you specified when you imported the image. The snapshot service is a paid service. For more information, see Snapshots.

    • After the image check feature is enabled and checks the custom image, you can view the check details in the Check Result column of the custom image list. If specific image check items need to be handled, click Repair to automatically repair the image by using Image Builder or manually repair the image based on the recommended solutions. For information about the check items and the recommended solutions, see the "Image check items" section of the Overview topic.

    • You may fail to import an image because unexpected errors occur when the image file is verified during the image import process. The errors may affect your subsequent operations such as instance creation. You can perform the following operations to troubleshoot the issues.

      1. View the error codes of the issues on the Task Management page in the ECS console or by calling the DescribetaskAttribute operation.

      2. View the error code details and resolve the issues based on the corresponding solutions described in the following table.

        Error code details

        Error code

        Cause

        Cause identification

        Recommended solution

        UNKNOWN_IMAGE_FORMAT

        The image format is not supported.

        Run the qemu-img check command to view the image format.

        Convert the image format to RAW or VHD.

        Note

        We recommend that you use the qemu-img tool for format conversion and use the default parameter values during conversion. For more information, see Convert the format of an image.

        IMAGE_SIZE_EXCEEDS_LIMIT

        The image file is overlarge.

        Run the qemu-img info command to view the size of the image file.

        • Reduce the size of the image file.

        • Convert the image format to RAW or VHD.

          Note

          We recommend that you use the qemu-img tool for format conversion and use the default parameter values during conversion. For more information, see Convert the format of an image.

        INVALID_IMAGE_SIZE

        The correct image size cannot be obtained.

        Call the GetObject operation to check whether information about the image file can be returned from OSS.

        Reupload the image file to an OSS bucket.

        IMAGE_FILE_NOT_FOUND

        The source of the image file cannot be found.

        Call the GetObject operation to check whether information about the image file can be returned from OSS.

        • Do not delete the image file from OSS before the import task is completed.

        • Do not use special characters in the name of the image file that is stored as an OSS object. For more information, see Object naming conventions.

        • Reupload the image file to an OSS bucket.

  • Cancel the image import task

    Before the image import task is completed, you can cancel the task by using one of the following methods:

    • Method 1: On the Custom Images tab of the Images page, find the image that is being imported and click Cancel Import in the Actions column.

    • Method 2: On the Task Management page, cancel the image import task.

      1. In the left-side navigation pane, choose Maintenance & Monitoring > Tasks.

      2. Find the image import task that you want to cancel and click Cancel in the Actions column.

Import a custom image by using SMC

To generate an ECS image for your server by using SMC, perform the following steps:

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Images.

  3. In the upper-left corner of the top navigation bar, select a region.

  4. In the upper-right corner of the Images page, click SMC in the Import Image section.

    You are directed to the SMC console.

  5. In the SMC console, download the SMC client. Extract the SMC client, upload the SMC client to the source server, and then run the SMC client. Then, import information about the source server to the SMC console.

  6. Create and start a migration job in the SMC console. Select ECS Image as the destination type.

    For more information, see Create a server migration job.

    After the migration job is completed, SMC generates a custom image for your source server. The image name starts with IMAGE_FROM_SMC. You can create an ECS instance from the image in the ECS console.