To create an Amazon EBS-backed Linux AMI, start from an instance that you've launched from an existing Amazon EBS-backed Linux AMI. After you've customized the instance to suit your needs, create and register a new AMI, which you can use to launch new instances with these customizations.
If you need to create an Amazon EBS-backed Windows AMI, see Creating an Amazon EBS-Backed Windows AMI in the Amazon EC2 User Guide for Microsoft Windows Instances.
The AMI creation process is different for instance store-backed AMIs. For more information about the differences between Amazon EBS-backed and instance store-backed instances, and how to determine the root device type for your instance, see Storage for the Root Device. If you need to create an instance store-backed Linux AMI, see Creating an Instance Store-Backed Linux AMI.
The following diagram summarizes the creation process for Amazon EBS-backed AMIs.
First, launch an instance from an AMI that's similar to the AMI that you'd like to create. You can connect to your instance and customize it. When the instance is set up the way you want it, it's best to stop the instance before you create an AMI to ensure data integrity. Then, you can create the image. When you create an Amazon EBS-backed AMI, we automatically register it for you.
Amazon EC2 powers down the instance before creating the AMI to ensure that everything on the instance is stopped and in a consistent state during the creation process. If you're confident that your instance is in a consistent state appropriate for AMI creation, you can tell Amazon EC2 not to power down and reboot the instance. Some file systems, such as xfs, can freeze and unfreeze activity, making it safe to create the image without rebooting the instance.
During the AMI creation process, Amazon EC2 creates snapshots of your instance's root volume and any other Amazon EBS volumes attached to your instance. If any volumes attached to the instance are encrypted, the new AMI will only launch successfully on instances that support Amazon EBS encryption. For more information, see Amazon EBS Encryption.
AMIs with encrypted volumes cannot be copied using the AWS Management Console. Instead, you must copy each volume's snapshot to the target region and create a new AMI in that region using the copied snapshots in the block device mappings.
Depending on the size of the volumes, it may take several minutes for the entire AMI creation process to complete (sometimes up to 24 hours). To help speed up this process, we recommend that you create snapshots of your volumes immediately before creating an AMI. For more information, see Creating an Amazon EBS Snapshot.
After the process completes, you have a new AMI and snapshot created from the root volume of the instance. When you launch an instance using the new AMI, we create a new Amazon EBS volume for its root volume using the snapshot. Both the AMI and the snapshot incur charges to your account until you delete them. For more information, see Deregistering Your AMI.
If you add instance-store volumes or Amazon EBS volumes to your instance in addition to the root device volume, the block device mapping for the new AMI contains information for these volumes, and the block device mappings for instances that you launch from the new AMI automatically contain information for these volumes. The instance-store volumes specified in the block device mapping for the new instance are new and don't contain any data from the instance store volumes of the instance you used to create the AMI. The data on Amazon EBS volumes persists. For more information, see Block Device Mapping.
You can create an AMI using the AWS Management Console or the command line.
To create an AMI from an instance using the console
Open the Amazon EC2 console.
If you don't have a running instance that uses an Amazon EBS volume for the root device, you must launch one. For instructions, see Launching an Instance.
(Optional) Connect to the instance and customize it. For example, you can install software and applications, copy data, or attach additional Amazon EBS volumes. For more information about connecting to an instance, see Connect to Your Linux Instance.
(Optional) Create snapshots of all the volumes attached your instance. This may help reduce the time it takes to create the AMI. For more information about creating snapshots, see Creating an Amazon EBS Snapshot.
In the navigation pane, click Instances and select your instance. Click Actions, and then click Create Image.
If this option is disabled, your instance isn't an Amazon EBS-backed instance.
In the Create Image dialog box, specify the following, and then click Create Image.
A unique name for the image.
(Optional) A description of the image, up to 255 characters.
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 if you don't want your instance to be shut down.
If you select No reboot, we can't guarantee the file system integrity of the created image.
(Optional) You can modify the root volume, Amazon EBS volumes, and instance store volumes as follows:
To change the size of the root volume, locate the Root volume in the Type column, and fill in the Size field.
To suppress an Amazon EBS volume specified by the block device mapping of the AMI used to launch the instance, locate the EBS volume in the list and click Delete.
To add an Amazon EBS volume, click Add New Volume, select EBS from the Type list, and fill in the fields. When you then launch an instance from your new AMI, these additional volumes are automatically attached to the instance. Empty volumes must be formatted and mounted. Volumes based on a snapshot must be mounted.
To suppress an instance store volume specified by the block device mapping of the AMI used to launch the instance, locate the volume in the list and click Delete.
To add an instance store volume, click Add New Volume, select Instance Store from the Type list, and select a device name from the Device list. When you launch an instance from your new AMI, these additional volumes are automatically initialized and mounted. These volumes don't contain data from the instance store volumes of the running instance from which you based your AMI.
Click AMIs in the navigation pane to view the status of your AMI. While the
new AMI is being created, its status is
pending. This process typically takes a few minutes
to finish, and then the status of your AMI is
(Optional) Click Snapshots in the navigation pane to view the snapshot that was created for the new AMI. When you launch an instance from this AMI, we use this snapshot to create its root device volume.
If you have a snapshot of the root device volume of an instance, you can create an AMI from this snapshot using the AWS Management Console or the command line.
To create an AMI from a snapshot using the console
Open the Amazon EC2 console.
In the navigation pane, under Elastic Block Store, click Snapshots.
Select the snapshot, and then select Create Image from the Actions list.
In the Create Image from EBS Snapshot dialog box, do the following:
Select the architecture from the Architecture list (
i386 for 32-bit
x86_64 for 64-bit).
Select the AKI from the Kernel ID list. If you select the default AKI or don't select an AKI, you'll be required to 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.