Amazon Elastic Compute Cloud
User Guide (API Version 2012-04-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Creating Amazon EBS-Backed AMIs

You can create an AMI that uses an Amazon EBS volume as its root device with Windows or Linux/UNIX operating systems.

The process is simple. You start with an Amazon EBS-backed AMI (for example, one of the public AMIs that Amazon provides), and modify it to suit your particular needs. You can't create an Amazon EBS-backed AMI starting with an Amazon EC2 instance store-backed instance.

[Important]Important

You cannot delete a snapshot of the root device of a registered EBS-backed AMI. You must first de-register the AMI before you can delete the snapshot.

[Note]Note

You cannot register an image where a secondary (non-root) snapshot has AWS Marketplace product codes.

For an overview of the AWS Marketplace, go to https://aws.amazon.com/marketplace/help/200900000. For details on how to use the AWS Marketplace, see AWS Marketplace.

If the AMI you start with doesn't already have the storage devices you want attached, you can add them by creating EBS volumes or using block device mapping. To create EBS volumes, use ec2-create-volume and ec2-attach-volume or CreateVolume and AttachVolume. You also can call ec2-run-instances or RunInstances with block device mapping information for the devices you want to add. For more information about block device mapping, see Block Device Mapping.

[Important]Important

If you customize your instance with ephemeral storage devices or additional EBS volumes besides the root device, the new AMI contains block device mapping information for those storage devices and volumes. When you then launch an instance from your new AMI, the instance automatically launches with the additional devices and volumes.

When you have a running instance in the state you want, use ec2-create-image or CreateImage and specify the instance ID. Amazon EC2 powers down the instance, takes images of any volumes that were attached, creates and registers the AMI, and then reboots the instance. It takes several minutes for the entire process to complete. If you customized the local instance with storage devices or additional EBS volumes besides the root device, the new AMI contains block device mapping information for those storage devices. When you launch an instance from your new AMI, the instance automatically launches with the additional devices. The instance stores, also called ephemeral stores, are new and don't contain any data from the instance store of the original instance used to create the AMI.

The reason Amazon EC2 powers down the instance before creating the AMI is 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 add the --no-reboot flag to ec2-create-image or CreateImage that tells Amazon EC2 not to power down and reboot the instance. You can't specify this flag when creating the AMI in the AWS console. With this flag, the instance remains running throughout the AMI creation process. Some file systems, such as xfs, can freeze and unfreeze activity, making it safe to create the image without rebooting the instance.

[Note]Note

Amazon EBS-backed instances are stored as Amazon EBS data. Standard storage rates apply.

Sysprep does not automatically run for Amazon EBS-backed Windows instances.

Process for Creating Amazon EBS-Backed AMIs

The following diagram and table describe the process for creating an Amazon EBS-backed AMI. The information is applicable to both Linux/UNIX and Windows AMIs.

Process to create Amazon EBS-backed AMI

General Tasks in Creating Amazon EBS-Backed AMIs

1

Start by launching an instance of an Amazon EBS-backed AMI that is similar to the AMI you want to create. For example, you might take a public AMI that uses the operating system you want to use for your AMI.

The instance must be from an Amazon EBS-backed AMI; you can't start with an instance of an Amazon EC2 instance store-backed AMI.

2

When the instance is running, customize it as you want. For example, you could attach additional Amazon EBS volumes, or load applications or data on to the instance.

[Important]Important

If you customize your instance with ephemeral storage devices or additional EBS volumes besides the root device, the new AMI contains block device mapping information for those storage devices and volumes. When you then launch an instance from your new AMI, the instance automatically launches with the additional devices and volumes.

3

When the instance is set up the way you want it, create an image from that instance.


Special Cases

In some cases, the general tasks in creating Amazon EBS-backed AMIs don't apply:

  • You don't have the original AMI to launch instances from.

    In this case, you can create an Amazon EBS-backed AMI by registering a snapshot of a root device. You must own the snapshot and it must be a Linux/UNIX system (this process is not available for Windows instances). For more information about creating an AMI this way, see Launching an Instance from a Snapshot.

  • You have an Amazon EC2 instance store-backed Linux/UNIX AMI.

    In this case, you can convert the AMI to be backed by Amazon EBS. You cannot convert a Windows AMI backed by instance store. For more information about converting a Linux/UNIX AMI, see Converting Amazon EC2 instance store-backed AMIs to EBS-Backed AMIs.

How to Create Amazon EBS-Backed AMIs

You perform the tasks of creating an Amazon EBS-backed AMI by using the AWS Management Console, the command line tools, or the API. The following section describes the steps using these tools and interface.

AWS Management Console

For instructions that use the AWS Management Console, see Creating an Image from a Running Instance.

Command Line Tools

To create an Amazon EBS-backed AMI

  1. Enter the following command to create an image:

    PROMPT>  ec2-create-image -n your_image_name  instance_id

    For example:

    PROMPT>  ec2-create-image -n "My AMI" i-eb977f82

    Amazon EC2 creates an image and returns an AMI ID.

    IMAGE ami-8675309 
  2. If you want to check whether the AMI is ready, enter the following command:

    $  ec2-describe-images -o self  

    Amazon EC2 returns information about the AMI.

API

To create an Amazon EBS-backed AMI

  • Construct the following Query request to create an image:

    https://ec2.amazonaws.com/
    ?Action=CreateImage
    &InstanceId=instance_id
    &Name=My_Ami
    &...auth parameters...

    In the following example response, Amazon EC2 creates the image and returns its AMI ID.

    <CreateImageResponse xmlns="http://ec2.amazonaws.com/doc/2012-04-01/">
      <imageId>ami-8675309</imageId>
    </CreateImageResponse>

    AMI creation can take time. You can check whether the AMI is ready by using .

Converting Amazon EC2 instance store-backed AMIs to EBS-Backed AMIs

There's no simple API or button in the AWS Management Console that converts an existing Amazon EC2 instance store-backed AMI to an Amazon EBS-backed AMI.

[Important]Important

It isn't possible to convert an Amazon EC2 instance store-backed Windows AMI. You need to take a public Amazon EBS-backed Windows AMI, modify it to meet your specifications, and then create an image from it. For information, see Creating an Image from a Running Instance.

You can convert Amazon EC2 instance store-backed Linux/UNIX AMIs to EBS-backed systems. The following table describes the process.

Process for Converting a Linux/UNIX Amazon EC2 instance store-backed AMI to an EBS-Backed AMI

1

Copy the AMI's root device information to an Amazon EBS volume. For more information, see the related task list in Amazon EC2 Root Device Storage Usage Scenarios

2

Create a snapshot of that volume. For more information, see Creating an Amazon EBS Snapshot.

3

Register the image with a block device mapping that maps the root device name of your choice to the snapshot you just created. For an example of how to register an image, see Automatically Attaching Volumes.


You might find it useful to refer to available blog posts that discuss conversion. The following are two example blogs; AWS, however, takes no responsibility for the completeness or accuracy of the content: