Create Custom AMIs
Creating a Linux AMI from an instance
To create an AMI from an instance using the console
- You need to create an Instance. See Create an EC2 Instance
- While instance is running, connect to it. You can do any actions on yours instance to customize it:
- Install software and applications
- Copy data
- Reduce start time by deleting temporary files, defragmenting your hard drive, and zeroing out free space
- Attach additional Amazon EBS volumes
- (Optional) Create snapshots of all the volumes attached to your instance. For more information about creating snapshots, see Creating Amazon EBS Snapshots.
- In the navigation pane, choose Instances, select your instance, and then choose Actions, Image, Create Image.
Tip: If this option is disabled, your instance isn’t an Amazon EBS-backed instance.
- In the Create Image dialog box, specify the following information, and then choose Create Image.
- Image name: A Unique name for the image.
- Image description: An optional description of the image, up to 255 characters.
- No reboot:This option is not selected by default. Amazon EC2 shuts down the instance, takes snapshots of any attached volumes, creates and registers the AMI, and then reboots the instance. Select No reboot to avoid having your instance shut down.
Warning: If you select No reboot, we can’t guarantee the file system integrity of the created image.
- Instance Volumes: The fields in this section enable you to modify the root volume, and add additional Amazon EBS and instance store volumes. For information about each field, pause on the i icon next to each field to display field tooltips. Some important points are listed below.
- To change the size of the root volume, locate Root in the Volume Type column, and for Size (GiB), type the required value.
- If you select Delete on Termination, when you terminate the instance created from this AMI, the EBS volume is deleted. If you clear Delete on Termination, when you terminate the instance, the EBS volume is not deleted.
- To add an Amazon EBS volume, choose Add New Volume (which adds a new row). For Volume Type, choose EBS, and fill in the fields in the row. When you launch an instance from your new AMI, additional volumes are automatically attached to the instance. Empty volumes must be formatted and mounted. Volumes based on a snapshot must be mounted.
- To view status of your AMi while it is being created, in the navigation pane, choose AMIs.
(Optional) To view the snapshot that was created for the new AMI, choose Snapshots. When you launch an instance from this AMI, we use this snapshot to create its root device volume.
- Launch an instance from your new AMI. See Create an EC2 Instance.
- In the left bar, choose My AMIs and select the AMI that we have created.
- The new running instance contains all of the customizations that you applied in previous steps.
To create an AMI from an instance using the command line
You can use one of the following commands.
Creating a Linux AMI from a snapshot
To create an AMI from a snapshot using the console
- Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
- In the navigation pane, under Elastic Block Store, choose Snapshots.
- Choose the snapshot and choose Actions, Create Image.
- In the Create Image from EBS Snapshot dialog box, complete the fields to create your AMI, then choose Create. If you’re re-creating a parent instance, then choose the same options as the parent instance.
- Architecture: Choose i386 for 32-bit or x86_64 for 64-bit.
- Root device name: Enter the appropriate name for the root volume. For more information, see Device Naming on Linux Instances.
- Virtualization type: Choose whether instances launched from this AMI use paravirtual (PV) or hardware virtual machine (HVM) virtualization. For more information, see Linux AMI virtualization types.
- (PV virtualization type only) Kernel ID and RAM disk ID: Choose the AKI and ARI from the lists. If you choose the default AKI or don’t choose an AKI, you must specify an AKI every time you launch an instance using this AMI. In addition, your instance may fail the health checks if the default AKI is incompatible with the instance.
- (Optional) Block Device Mappings: Add volumes or expand the default size of the root volume for the AMI.
To create an AMI from a snapshot using the command line
You can use one of the following commands.