Amazon Elastic Compute Cloud
User Guide for Linux (API Version 2014-09-01)
« PreviousNext »
View the PDF for this guide.Go to the AWS Discussion Forum for this product.Go to the Kindle Store to download this guide in Kindle format.Did this page help you?  Yes | No |  Tell us about it...

Creating an Amazon EBS-Backed Linux AMI

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.

Overview of the Creation Process for Amazon EBS-Backed AMIs

The following diagram summarizes the creation process for Amazon EBS-backed AMIs.

Creating an Amazon EBS-backed AMI

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.

Note

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.

Creating the AMI from an Instance

You can create an AMI using the AWS Management Console or the command line.

To create an AMI from an instance using the console

  1. Open the Amazon EC2 console.

  2. 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.

  3. (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.

  4. (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.

  5. In the navigation pane, click Instances and select your instance. Click Actions, and then click Create Image.

    Tip

    If this option is disabled, your instance isn't an Amazon EBS-backed instance.

  6. In the Create Image dialog box, specify the following, and then click Create Image.

    1. A unique name for the image.

    2. (Optional) A description of the image, up to 255 characters.

    3. 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.

      Warning

      If you select No reboot, we can't guarantee the file system integrity of the created image.

    4. (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.

  7. 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 available.

  8. (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.

To create an AMI from an instance using the command line

You can use one of the following commands. For more information about these command line interfaces, see Accessing Amazon EC2.

Creating an AMI from a Snapshot

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

  1. Open the Amazon EC2 console.

  2. In the navigation pane, under Elastic Block Store, click Snapshots.

  3. Select the snapshot, and then select Create Image from the Actions list.

  4. In the Create Image from EBS Snapshot dialog box, do the following:

    1. Select the architecture from the Architecture list (i386 for 32-bit or x86_64 for 64-bit).

    2. 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.

    3. Click Create.

To create an AMI from a snapshot using the command line

You can use one of the following commands. For more information about these command line interfaces, see Accessing Amazon EC2.