|« PreviousNext »|
|Did this page help you? Yes | No | Tell us about it...|
To create an instance store-backed Linux AMI, start from an instance that you've launched from an existing instance store-backed Linux AMI. After you've customized the instance to suit your needs, bundle and register a new AMI, which you can use to launch new instances with these customizations.
If you'd prefer to create an instance store-backed Windows AMI, see Creating an Instance Store-Backed Windows AMI in the Amazon Elastic Compute Cloud Microsoft Windows Guide.
The AMI creation progress is different for instance store-backed AMIs. For more information about the differences between Amazon EBS-backed and instance store-backed instances, see Storage for the Root Device. To create an Amazon EBS-backed Linux AMI, see Creating an Amazon EBS-Backed Linux AMI.
The following diagram summarizes the process of creating an AMI from an instance store-backed instance.
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, you can bundle the volume. It takes several minutes for the bundling process to complete. After the process completes, you have an image manifest and image files. You upload these files to your Amazon S3 bucket and then register your AMI.
When you launch an instance using the new AMI, we create the root volume for the instance using the image files you uploaded to Amazon S3. Both the AMI and the files in Amazon S3 incur charges to your account until you delete them. For more information, see Deregistering Your AMI.
If you add instance-store volumes or 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. For more information, see Block Device Mapping.
Before you can create the AMI, you must complete the following tasks:
Install the AMI tools. For more information, see Set Up the AMI Tools.
Install the API tools. For more information, see Setting Up the Amazon EC2 Command Line Interface Tools on Linux/UNIX.
Ensure that you have an Amazon S3 bucket for the image files. To create an Amazon S3 bucket, open the Amazon S3 console and click Create Bucket.
Ensure that you have the following credentials:
Your AWS account ID. To retrieve your account ID, go to Your Security Credentials and expand Account Identifiers.
An X.509 certificate and private key. If you need to create an X.509 certificate, go to Your Security Credentials, expand X.509 Certificates, and click Create New Certificate.
Your access key ID. If you need to retrieve or create an access key ID, go to Your Security Credentials, and expand Access Keys.
Your secret access key. You can't retrieve your secret access key. Therefore, if you can't find your secret access key, you'll need to create a new one. To create a secret access key, go to Your Security Credentials, expand Access Keys, and click Create New Access Key.
Connect to your instance and customize it. For example, you can install software and applications, copy data, delete temporary files, and modify the Linux configuration.
To create an AMI from an instance
Upload your credentials to your instance. We use these credentials to ensure that only you and Amazon EC2 can access your AMI.
Create a temporary directory on your instance for your credentials as follows:
This enables you to exclude your credentials from the created image.
Grant write permissions to this directory as follows:
sudo chmod 777 /tmp/cert
Copy your X.509 certificate and private key from your computer to the
using a secure copy tool such as scp.
scp -i gsg-keypair pk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem email@example.com:/tmp/certpk-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem 100% 717 0.7KB/s 00:00 cert-HKZYKTAIG2ECMXYIBH3HXV4ZBEXAMPLE.pem 100% 685 0.7KB/s 00:00
Prepare the image files to upload to Amazon S3 using the ec2-bundle-vol command.
Be sure to specify the
-e option to exclude the directory where your credentials are stored.
By default, the bundle process excludes files that might contain sensitive information.
These files include
To include all of these files, use the
To include some of these files, use the
ec2-bundle-vol -k /tmp/cert/
my-key-pair.pem -c /tmp/cert/cert-
your_aws_account_id-r x86_64 -e /tmp/cert
It can take a few minutes to create the image. When this command completes,
tmp directory contains the image files (
image.manifest.xml, plus multiple
Upload your image to Amazon S3 using the ec2-upload-bundle command. Note that if the folders don't exist in the bucket, this command creates them.
ec2-upload-bundle -b my-s3-bucket/images/
image_name-m /tmp/image.manifest.xml -a
(Optional) After the image is uploaded to Amazon S3, you can remove the image files from the
on the instance using the following rm command:
rm -rf /tmp/im*
Register your AMI using the ec2-register command.
Note that you don't need to specify the
-W options if
you've set the
You can convert an instance store-backed Linux AMI to an Amazon EBS-backed Linux AMI.
You can't convert an instance store-backed Windows AMI to an Amazon EBS-backed Windows AMI.
To convert an instance store-backed AMI to an Amazon EBS-backed AMI
Launch an instance from an Amazon EBS-backed AMI.
Install the AMI tools on your Amazon EBS-backed instance.
Create an empty Amazon EBS volume, attach it to your Amazon EBS-backed instance, and format it.
sudo mkfs -t ext3
Download the image for your instance store-based AMI to
using the ec2-download-bundle command.
Unbundle the image to
/mnt using the ec2-unbundle command.
Copy the image to the Amazon EBS volume.
sudo dd if=/mnt/image of=
Mount the Amazon EBS volume.
Remove any entries for instance store volumes from
Unmount the volume and detach it from the instance.
sudo unmount -d
Create an image from the volume as follows.
Open the Amazon EC2 console.
In the navigation pane, under Elastic Block Store, select Volumes.
Select the volume you just unmounted, click Actions, and then click Create Snapshot.
In the Create Snapshot dialog box, specify the required information and click Yes, Create.
In the navigation pane, under Elastic Block Store, click Snapshots. Select the snapshot you just created and click Create Image.
In the Create Image from EBS Snapshot dialog box, specify the required information and click Yes, Create.
(Optional) Delete the Amazon EBS volume.