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. The illustration is as follows.
You can use a snapshot to create a custom image, including the operating system and data environment of the snapshot in the image. You can then use the custom mirror to create multiple instances with the same operating system and data environment, replicating instances easily.
You can also use an instance to create a image. See Create a custom image by using an instance.
To enhance the security of creating custom imags from snapshots, operation, Alibaba Cloud custom mirror security recommendations.
Considerations for Linux instances
- Do not load data disk information in the /etc/fstab file. Otherwise, instances created using this image will not start.
- We recommend that before taking a snapshot and creating an image, umount all data disks, and then create a snapshot to create a custom image. Otherwise, ECS instances that are created based on this custom image may not start.
- Do not upgrade the kernel or operating system version.
- Do not change the system disk partition. The system disk only support a single root partition.
- Check the availabe space of the the system disk to ensure that the system disk is not full.
- Do not modify critical system files such as /sbin, /bin and /lib etc.
- Do not modify the default logon user name root.
- Log on to the ECS console.
- Select a region.
- In the left-hand navigation pane, click Instances.
- Find the target instance, click the instance ID, or in the Actions column, click Manage.
- In the left-hand navigation pane, click Snapshots. Find the target system disk, in the Actions column, click Create Custom Image.
The snapshot must be created from Data disks cannot be used to create custom images.
You can also use create a custom image.and select a snapshot created from a system disk to
- In the pop-up Create a custom image dialog box, do the following:
- Confirm the snapshot ID.
- Specify the name and description of the custom image.
- Optional. Click Add Data Disk Snapshot to select multiple snapshots of data disks for the image. Click Add to add a data disk.
Remove sensitive data from the data disk before creating a custom image to avoid the risk of data security.
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. In the left-side navigation pane, select Snapshots & Images > Images to view images you have created.
FAQ for images of Linux instances
umounta disk and delete disk table data?
If /dev/hda5 is attached to /mnt/hda5, run any of the following three commands to detach the file system:
umount/dev/hda5 umount/mnt/hda5 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 upon 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.
Use the 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. As shown in the following table.
|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.|