All Products
Search
Document Center

Elastic Compute Service:Import custom images

Last Updated:Oct 18, 2024

You can import on-premises image files to Alibaba Cloud to generate custom images. Then, you can use the custom images to quickly create Elastic Compute Service (ECS) instances that have specific operating system settings and provisioned applications. This improves deployment efficiency. This topic describes how to import a custom image.

Note

You can also use Server Migration Center (SMC) to migrate servers from self-managed data centers, on-premises virtual machines (VMs), or third-party cloud service providers to Alibaba Cloud. Then, you can generate custom images from these servers and use the custom images to create ECS instances. For more information, see Migrate a server to an ECS instance.

Prerequisites

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

  • To avoid compatibility issues, make sure that the image file that you want to import meets the import requirements. For more information, see Instructions for importing images.

  • Make sure that the image file is in the RAW, Virtual Hard Disk (VHD), or QEMU Copy-On-Write version 2 (QCOW2) format. If your image file is in a format other than the preceding formats, convert the image file to one of the preceding formats before you import the image file. For more information, see Convert the format of an image.

  • Make sure that you have the permissions to import custom images.

    • Use your Alibaba Cloud account to go to the Cloud Resource Access Authorization page of the Resource Access Management (RAM) console, follow the on-screen instructions to complete authorization, and grant ECS access to Object Storage Service (OSS) resources. By default, ECS uses the AliyunECSImageImportDefaultRole role to import images.

    • If you use a RAM user and do not have the preceding permissions, you must contact the Alibaba Cloud account owner to grant the RAM user the operation permissions on OSS buckets.

      Grant a RAM user the permissions on OSS buckets

      1. Create a custom policy.

      2. Attach the custom policy to the RAM user. For more information, see Grant permissions to a RAM user.

Video tutorial

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

Procedure

Step 1: Upload an image file to an OSS bucket

Upload an on-premises image file to an OSS bucket and obtain the file URL. For more information, see Get started by using the OSS console. You do not need to perform the operations described in the "Download objects" section of the referenced topic.

Note

If you want to incorporate data disk data in an image when you import the image, you must separately prepare image files for the system disk and data disks and upload the files to an OSS bucket. When you import the image to ECS, you can specify the image files of the system disk and data disks. This way, ECS instances created from the image will contain both system disk data and data disk data.

Step 2: 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

    The selected region must be the same as the region of the OSS bucket in which the image file is stored.

    Description of Alibaba Finance Cloud regions

    A Finance Cloud region has different names in ECS and OSS.

    • The China East 2 Finance region (cn-shanghai-finance-1) in ECS corresponds to the oss-cn-shanghai-finance-1-pub region in OSS.

    • The China South 1 Finance region (cn-shenzhen-finance-1) in ECS corresponds to the oss-cn-szfinance region in OSS.

    • The China North 2 Finance region (cn-beijing-finance-1) in ECS corresponds to the oss-cn-beijing-finance-1 region in OSS.

  4. On the Images page, choose Import Image > Import Image in the upper-right corner.

    image.png

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

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

    If you import an image for the first time and do not grant ECS access permissions on OSS resources, you can grant ECS the preceding permissions 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, check whether the AliyunECSImageImportDefaultRole role exists. If the role exists, click Confirm Authorization Policy.

      Note

      After the operation is complete, the system automatically creates the AliyunECSImageImportDefaultRole role and grants permissions to the role.

  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.

    Image File URL

    Yes

    Enter the URL of the image file that you obtained in Step 1.

    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 file that you want to import. The operating system type must be the same as that of the image file.

    Valid values: windows and linux. If the operating system of the image that you want to import is not supported by Alibaba Cloud, select linux.

    OS Version

    Yes

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

    If the operating system of the image that you want to import is not supported by Alibaba Cloud, you can perform one of the following operations:

    • Select Customized Linux: Make sure that you have manually added the parsing script to ensure that the image is usable. For more information, see Customize Linux images.

    • Select Others Linux: ECS does not process the instances that are created from the imported image. After you create an ECS instance from the imported image, you must configure the IP addresses, routes, and password of the instance.

    • If the operating system of the image that you want to import is customized based on the Linux kernel, submit a ticket for custom configurations.

    Architecture

    Yes

    Select an architecture based on the operating system of the image that you want to import. 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 Import is selected, and the image check feature checks the custom image immediately after the image is imported. After the image check is complete, you can view the detailed check result in the Check Result column corresponding to the image in the custom image list. If you want to repair an item, you can click Repair or manually repair the item based on the suggestions in the Image Details section of the Image Check Results panel.

    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. Valid values: BIOS and UEFI.

    The boot mode specifies how the system disk is started during the creation of an ECS instance. We recommend that you use the same boot mode as the boot mode of the image file. A boot mode inconsistency may cause the ECS instance created from the custom image to fail to start.

    Image Format

    No

    The format of the image file. Valid values: Auto-detect (default), RAW, QCOW2, and VHD. We recommend that you select the same format as the image file that you want to import.

    If you do not know the image format, select Auto-detect. The system automatically sets the image format to the image format of the image that you want to import.

    Note

    To import an ISO file to ECS, make sure that the ISO file is converted to an image format supported by ECS. For more information, see the How do I convert ISO files to image formats that are supported by ECS? section of the "FAQ about image lifecycle" topic.

    License Type

    No

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

    • Auto: Alibaba Cloud automatically checks whether the source operating system has a license provided by Alibaba Cloud and performs the following operations:

      • If a license provided by Alibaba Cloud is allocated to the source operating system, this license is assigned to the imported image.

      • If no license provided by Alibaba Cloud is allocated to the source operating system, the system switches the license type to BYOL, which represents Bring Your Own License.

    • Alibaba Cloud License: Use the license provided by Alibaba Cloud for the source operating system. You are charged for image license fees for the instances created from the image. The license of the image is automatically activated.

    • BYOL: Use the license that comes with the source operating system. You are not charged for image license fees for the instances created from the image. The license of the image is not activated.

    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 obtained in Step 1. Obtain the URL of the data disk image file by using the same method as for the system disk image file.

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

      • Image Format: Select Auto-detect, RAW, QCOW2, or VHD. The format must be the same as the format of the image file.

      • Disk SizeGiB: The size of a disk ranges from 1 GiB to 2,048 GiB and must be greater 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.

(Optional) Step 3: View or cancel the import task

  • View the image import task

    You can go to the Custom Images tab on the Images page or go to the Task Management page by choosing Maintenance & Monitoring > Tasks 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 is completed, you can view the detailed check result in the Check Result column corresponding to the image in the custom image list. If you want to repair an item, you can click Repair or manually repair the item based on the suggestions displayed in the Image Details section of the Image Check Results panel. 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 checked 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

        Suggestion

        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 image 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 image 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 an image file that is stored as an OSS object. For more information, see Object naming conventions.

        • Reupload the image file to an OSS bucket.

        INVALID_IMAGE_FORMAT

        The image format is not valid.

        The format declared in the header file is not supported.

        Check the image format. Convert it to RAW or VHD.

        Note

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

  • Cancel an 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.