When you deploy services in the cloud, you can manually import image files of your own servers to Alibaba Cloud Elastic Compute Service (ECS) or have ECS images automatically generated for your servers. This topic describes the use scenarios and instructions of both methods.

Prerequisites

You must complete the following operations before you import an image:

Permissions required to import custom images

  • Access on OSS resources

    Use your Alibaba Cloud account to log on to the RAM console and grant access on OSS resources to ECS by attaching the AliyunECSImageImportDefaultRole role to ECS.

  • Operation permissions on OSS buckets
    If you are using a RAM user, ask the owner of the corresponding Alibaba Cloud account to grant operation permissions on OSS buckets to the RAM user before you import custom images. To grant operation permissions on OSS buckets to the RAM user, the Alibaba Cloud account must perform the following steps:
    1. Create a custom policy. For more information, see Create a custom policy on the JSON tab.
    2. Attach the policy to the RAM user. For more information, see Grant permissions to a RAM user. You can also grant read and write permissions on specific OSS buckets to your RAM user. For more information, see Tutorial: Use RAM policies to control access to OSS.
      Important In the preceding steps, make sure that the scope of permissions granted to the RAM user is account-wide instead of limited to a specific resource group. If the scope of permissions granted is limited to a specific resource group, make sure that the image to be imported belongs to the specified resource group.

Use scenarios

The following table describes the use scenarios of different image import features.
Feature Use scenario References
Auto-import Auto-import allows you to use Server Migration Center (SMC) to migrate one or more servers such as servers in Internet data centers (IDCs), virtual machines, or cloud servers from other cloud platforms to Alibaba Cloud. When your servers are migrated, SMC generates ECS images for the servers. Auto-import
Manual import The required operating system is unavailable in Alibaba Cloud. Examples:
  • The specified operating system type does not exist in Alibaba Cloud.
  • The specified operating system version has been discontinued in Alibaba Cloud.
  • The specified operating system is a custom operating system.

Manual import allows you to select a license type to activate the source operating system and reduce your image costs in the cloud. For more information about license types, see the table that describes parameters for image import in the following section.

Manual import

Auto-import

Perform the following operations to use SMC to migrate your server and generate an ECS image.

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Images.
  3. In the top navigation bar, select a region.
  4. In the upper-right corner of the Images page, click Online SMC Migration.
    You are redirected to the SMC console.
  5. Use SMC to migrate your server and generate an ECS image for the server.
    For more information, see Migration process. After you migrate a server, SMC generates a custom image for the server. The image name starts with IMAGE_FROM_SMC.

Manual import

Perform the following operations to manually import an image file from your computer to ECS:

Step 1: Create a bucket in the OSS console and upload an image file to the bucket

  1. Create a bucket in the OSS console.
    For more information, see Create buckets.
  2. Upload an image file from your computer to the OSS bucket.
    For more information, see Upload objects.
    Note
    • The image file that you want to upload by using the OSS console cannot exceed 5 GB in size. For information about how to upload an image file larger than 5 GB in size, see Multipart upload.
    • The image file must be in the RAW, VHD, or QCOW2 format and not be compressed.

Step 2: (Optional) Grant access on OSS resources to ECS

The first time that you import custom images, you must use your Alibaba Cloud account to log on to the RAM console and grant access on OSS resources to ECS by attaching the AliyunECSImageImportDefaultRole role to ECS. If ECS already has access on OSS resources, this step is automatically skipped.

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Images.
  3. In the left part of the top navigation bar, select a region.
    Important Make sure that the region of the bucket from which to import the image is selected.
  4. In the upper-right corner of the Images page, click Import Image.
  5. In the Cloud Resource Access Authorization dialog box, click Authorize.
    Authorize
  6. On the Cloud Resource Access Authorization page, AliyunECSImageImportDefaultRole and AliyunECSExportDefaultRole are displayed. Click Confirm Authorization Policy.

Step 3: Import the 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 left part of the top navigation bar, select a region.
    Important Make sure that the region of the bucket from which to import the image is selected.
  4. In the upper-right corner of the Images page, click Import Image.
  5. In the Import Image dialog box, configure the parameters described in the following table.
    Parameter Required Description
    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 the region of the bucket from which to import the image is selected.
    OSS Object Address Yes Paste the URL of the image object that you obtained from the OSS console. For information about how to obtain the URL of an object, see Share objects.
    Take note of the following items:
    • You must use the same Alibaba Cloud account to obtain the URL of the image object and import the image.
    • If you are using a RAM user, ask 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 Permissions required to import custom images section in this topic.
    • The URL of the image object must be the public URL generated when you share the object in OSS. Internal URLs provided by OSS cannot be used to import images. If you use an internal URL to import an image, an error occurs. For information about the internal endpoint of OSS, see Obtain the internal endpoint of OSS.
    Image Name Yes Enter a name for the new 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.
    Operating System/Platform Yes Configure Operating System/Platform based on the attributes of the image that you want to import from OSS.
    • Operating System:

      Select the operating system type of the image that you want to import. Valid values: Windows and Linux.

      If your image is a non-standard platform image, select Linux.

    • Platform:
      The valid values of Platform vary based on the Operating System value that you selected. Select an operating system platform that your image supports.
      • Valid values when Operating System is set to Windows: Windows Server 2003, Windows Server 2008, Windows Server 2012, Windows Server 2016, Windows Server 2019, and Windows Server 2022.
      • Valid values when Operating System is set to Linux: CentOS, SUSE, openSUSE, Ubuntu, Debian, FreeBSD, CoreOS, Aliyun, Anolis, Red Hat, CentOS Stream, AlmaLinux, Rocky Linux, Customized Linux, Kylin, UnionTech OS, and Others Linux. Submit a ticket to check whether Others Linux images can be imported.
      • If the operating system of your image is a custom distribution based on the Linux kernel, Submit a ticket.
    Architecture Yes Configure Architecture based on the operating system of the image that you want to import.
    • Select x86_64 for 64-bit operating systems.
    • Select i386 for 32-bit operating systems.
    • Select arm64 for 64-bit operating systems for ARM.
    System Disk Size (GiB) No Specify the system disk size. The system disk can range from 5 to 500 GiB in size and cannot be smaller than the image file.
    Image Format No Valid values: Auto-detect, RAW, QCOW2, and VHD. Select the format of the image that you want to import from OSS.
    • If you do not know the image format, you can select Auto-detect to allow the system to determine the image format.
    • If you want to select an image format, we recommend that you select the QCOW2 or VHD format, which has a smaller transmission footprint.
    Note
    License Type No Select a license type to activate the source operating system after the image is imported. Default value: Auto. Valid values:
    • 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 and Windows licenses, see Overview and Microsoft licenses and Software Assurance.

    • Aliyun: the license allocated by Alibaba Cloud. If this value is selected, a license allocated by Alibaba Cloud is applied based on your selected platform.
    • Auto: 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 platform, and then performs an operation based on the check result.
      • If a license has been allocated by Alibaba Cloud for the specified operating system platform, the system allocates the license to the imported image.
      • If no license has been allocated by Alibaba Cloud for the specified operating system platform, the system switches the license type to BYOL.
    Description No Enter a description for the new custom image.
    Add Data Disk Image No You can add images that contains data from data disks.
    1. Select Add Data Disk Image.
    2. Click Add.
    3. Configure parameters.
      • OSS Object Address: Enter the URL of the image object for a data disk. Obtain the URL of a data disk image object from the OSS console in the same way as you would do with a system disk image object.
      • Image Format: Valid values: Auto-detect, RAW, QCOW2, and VHD. Select the format of the image that you want to import from OSS.
      • Device: Specify the device name of the data disk.
      • Disk Size: The data disk can range from 5 to 2,000 GiB and cannot be smaller than the image file.
    Resource Group No Specify a resource group for the new custom image to simplify management.
    Important If the scope of permissions granted to your RAM user is limited to a specific resource group, select that resource group.
    Tag No Specify tags to add to the new custom image. You can use tags to classify images for easy search and batch operations.
  6. Confirm that your configurations are correct and click OK.
    The system then creates a task to import the image.

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

  • View the image import task
    You can access the custom image list of the specified region to view the progress of the image import task.
    Note The amount of time it takes to import a custom image depends on the image file size and the number of concurrent ongoing import tasks.

    When you import an image, snapshots are automatically generated. You can view the information of the snapshots on the Snapshots page in the ECS console. While the image import task is in progress, the state of the snapshots is displayed as Failed. When the image import task is completed, the snapshots enter the Successful state and the image enters the Available state. The total size of the snapshots is equal to the size of the imported image file, regardless of the system disk size that you set when you import the image. Snapshots are billed based on the amount of storage space they occupy. For more information, see Snapshots.

  • Cancel the image import task
    Before the image import task is completed, you can cancel the task on the Task Logs page.
    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.

What to do next

You can use the imported custom image to create instances that have the same operating system, applications, and data. For more information, see Create an instance by using a custom image.