Help Center/ Image Management Service/ Getting Started/ Scenario 2: Creating a Linux System Disk Image from an External Image File
Updated on 2024-08-29 GMT+08:00

Scenario 2: Creating a Linux System Disk Image from an External Image File

You can import a local image or a system disk image from another cloud platform. After an image is imported, you can use it to create an ECS or reinstall the OS of an existing ECS.

This guide describes how to create a Linux system disk image from an external image file.

Preparations

  1. Sign up for Huawei Cloud and complete real-name authentication.

    Before using IMS, sign up for a HUAWEI ID, enable Huawei Cloud services, and complete real-name authentication.

    If you have enabled Huawei Cloud services and completed real-name authentication, skip this step.

  2. Top up your account.

    Creating a private image is free, but you will be charged for the OBS bucket you use to store the uploaded image file. Ensure that your account has sufficient balance. If not, top up your account.

Step1: Prepare an Image File

You need to prepare an image file that meets the following requirements:

  • OS: SUSE, Oracle Linux, Red Hat, Ubuntu, etc. (32-bit or 64-bit)
  • Image format: VMDK, VHD, QCOW2, RAW, VHDX, QED, VDI, QCOW, ZVHD2, or ZVHD
  • Image size: no larger than 128 GB. If the image size is between 128 GB and 1 TB, convert the image file into RAW or ZVHD2 and import it using fast import.
  • Network: Files in the network rule directory are deleted and DHCP is configured for the NICs.
  • Tools: Cloud-Init has been installed.
  • Drivers: Native Xen and KVM drivers have been installed.
  • File system: The disk identifier in the GRUB configuration file and fstab file are set to UUID.

    Click here to learn more about the file restrictions and how to check and configure an image file.

Step 2: Upload the Image File

You are advised to use OBS Browser+ to upload external image files to an OBS bucket. For details, see OBS Browser+ Best Practices.

For how to download OBS Browser+, see Downloading OBS Browser+.

Figure 1 Uploading an image file

Step 3: Register the Image File as a Private Image

  1. Log in to the management console. In the service list, choose Compute > Image Management Service.
  2. In the image list, click Create Image in the upper right corner.
  3. In the Image Type and Source area, select Import Image for Type and System disk image for Image Type. Select the bucket storing the image file from the list and then select the image file.
    Figure 2 Importing an image file
    Figure 3 Image information
    Table 1 Image parameters

    Parameter

    Example Value

    Description

    Enable automatic configuration

    Enable

    If you select this option, the system will automatically check and optimize the image file. For details, see What Will the System Do to an Image File When I Use the File to Register a Private Image?

    Function

    ECS system disk image

    This parameter specifies whether the image is used to create ECSs or BMSs. The value can be ECS system disk image or BMS system disk image.

    Architecture

    x86

    The value can be x86 or ARM.

    • If the system identifies that the architecture in the image file is different from what you set here, the identified architecture prevails.
    • If the system fails to identify an architecture, the architecture you set will be used.

    Boot Mode

    BIOS

    This parameter is optional. The value can be BIOS or UEFI. For details about the differences between them, see How Is BIOS Different from UEFI?

    For details about which OSs support UEFI boot, see OSs supporting UEFI Boot Mode.

    The boot mode must be the same as that in the image file. You need to confirm which boot mode is used in the image file. After you select the right boot mode, the boot mode will be configured for the image at the background. Select the right boot mode, or ECSs created using the image will not be able to boot up.

    OS

    Ubuntu

    20.04 server 64bit

    To ensure that the image can be created and used properly, select an OS consistent with that in the image file. If you do not select an OS, the system attempts to automatically identify the OS in the image file.

    NOTE:
    • If the system identifies that the OS in the image file is different from the one you select here, the identified OS prevails.
    • If the system fails to identify an OS, the OS you select will be used.
    • If the OS you selected or identified by the system is inconsistent with the actual one, ECSs created from the image file may not work properly.

    System Disk (GB)

    40

    The system disk capacity (value range: 40 GB to 1024 GB). Ensure that this value is not less than the system disk capacity in the image file.

    NOTE:

    If the uploaded VHD image is generated using qemu-img or similar tools, check the system disk capacity based on What Do I Do If the System Disk Capacity in a VHD Image File Exceeds the One I Have Specified on the Management Console When I Use This File to Register a Private Image?

    Data Disk (GB)

    Not add

    You can also add data disks to the image. You need to obtain an image file containing data disks in advance. This function is used to migrate VMs and data disks from other platforms to the current platform.

    To add data disks, click , configure the data disk capacity, and click Select Image File. In the displayed dialog box, select the target bucket and then the target image file containing the data disk.

    A maximum of three data disks can be added.

    Name

    UbuntuImage

    Enter a name for the image.

    Encryption

    Not select

    (Optional) If you want to encrypt the image, select KMS encryption and select the key to be used from the key list. After you select KMS encryption, the system will create a default key ims/default for you. You can also select a key from the key list.

    For how to encrypt an image, see Creating Encrypted Images.

    NOTE:

    If the encrypted image needs to be shared with other tenants, use a custom key to encrypt it. Otherwise, the key cannot be authorized to other tenants, causing the sharing failure.

    Enterprise Project

    default

    Select an enterprise project from the drop-down list. This parameter is available only if you have enabled enterprise projects or your account is an enterprise account.

    An enterprise project provides central management of cloud resources on a project.

    Tag

    Key: usage

    Value: project

    (Optional) Set a tag key and a tag value for the image to make identification and management of your images easier. You are advised to create predefined tags in TMS. For details, see Creating Predefined Tags .

    NOTE:

    If your organization has configured tag policies for images, you need to add tags to your images based on the policies. If you add a tag that does not comply with the tag policies, images may fail to be created. Contact the organization administrator to learn more about the tag policies.

    • Each tag consists of a key and a value. The key contains a maximum of 36 characters, and the value contains a maximum of 43 characters. The key cannot be left blank or be an empty string. The value cannot be left blank but can be an empty string.
    • An image can have a maximum of 10 tags.

    Description

    imageTest

    (Optional) Enter a description of the image.

  4. Read and agree to the image disclaimer. Click Next.
  5. Confirm the parameter settings and click Submit.
  6. Go back to the private image list. When the image status changes to Normal, the image is created successfully.

Follow-up Procedure

After a system disk image is created, you can use it to create an ECS or change the OS of an existing ECS. This way, you can migrate data from a server to another. For details, see:

For more information, see Creating a Linux System Disk Image from an External Image File.