Custom images help you run ECS instances effectively by allowing you to create multiple ECS instances with identical OS and environment data to meet scaling requirements.
Custom images are based on ECS disk snapshots. You can set up identical or different configurations for ECS instances that are created from images.
Custom images are subject to the following restrictions:
- If the ECS used for creating a custom image expires, or the data is erased (that is, the system disk used for the snapshot expires or is released), the custom image and the ECS instances created from the custom image will not be affected. However, auto snapshots will be cleared when an ECS instance is released.
- You can upgrade the CPU, memory, bandwidth, hard drive, and, other configurations of ECS instances activated using a custom image.
- Custom images cannot be used across regions.
- A custom image applies to any ECS payment method, either yearly/monthly subscription or Pay-As-You-Go. Custom images for ECS instances under yearly/monthly subscription plans can be used to create Pay-As-You-Go instances, and vice versa.
When creating custom images on a Linux instance, adhere to the following:
- Do not load data disk information in the
/etc/fstabfile. Otherwise, instances created using this image will not start.
- It is recommended that you unmount all data disks before taking a snapshot and creating an image. Otherwise, ECS instances that are created based on this custom image may not start.
- Modifying the default logon user name root is not allowed (Linux OS only).
To create a custom image from a snapshot, perform the following:
Log on to the ECS console.
Click Snapshots > Snapshots in the left navigation bar.
Select your desired region.
Select a snapshot with the disk attribute of System Disk and click Create Custom Image.
Note: Data disks cannot be used to create custom images.
In the displayed dialog box, you can view the snapshot ID. Enter a name and description for the custom image.
(Optional) Click Add Data Disk Snapshot to select multiple snapshots of data disks for the image.
Note: If the snapshot disk capacity is left blank, an empty disk will be created with the default capacity of 5 GB. If you select available snapshots, the disk size is the same as the size of these snapshots.
Click Create. The custom image is successfully created.
(Optional) To view images you have created, select Images in the left navigation bar.
If /dev/hda5 is attached to /mnt/hda5, run any of the following three commands to detach the file system:
umount /dev/hda5 /mnt/hda5
/etc/fstab is an important configuration file in Linux. It contains file system details and storage devices attached at startup.
If you do not want to mount a specified partition when starting the VM, delete the corresponding lines from /etc/fstab. For example, you can delete the following statement to disconnect xvdb1 at startup:
/dev/xvdb1 /leejd ext4 defaults 0 0.
You must ensure that the auto attach data disk statement line has been deleted from the fstab file.
mount command to view information on all mounted devices. Ensure that the execution results do not contain the information of the data disk partition.
Before creating an image, ensure the key configuration files from the following table have not been modified; otherwise, the new instance will not be able to start.
|Configuration File||Purpose||Risks if changed|
|/etc/issue*, /etc/*-release, /etc/*_version||For system release and version||Modifying /etc/issue* will make the system release version unidentifiable, and cause instance creation failure.|
|/boot/grub/menu.lst, /boot/grub/grub.conf||For system boot||Modifying /boot/grub/menu.lst will result in kernel loading failure, and the system will not be able to start.|
|/etc/fstab||For mounting partitions during boot.||Modifying it will cause partition mounting failure, and the system will not be able to start.|
|/etc/shadow||For storing system passwords.||If this file is set to read-only, the password file cannot be edited, and instance creation will fail.|
|/etc/selinux/config||For system security policies||Modifying /etc/selinux/config and enabling SELinux will result in start failure.|