| Did this page help you? Yes No Tell us about it... |
Topics
When Amazon EC2 was first introduced, all AMIs were backed by Amazon EC2 instance store, which means the root device for an instance launched from the AMI is created from a template stored in Amazon S3. After we introduced Amazon EBS, we also introduced AMIs that are backed by Amazon EBS snapshots. This means that the root device for an instance launched from the AMI is on an Amazon EBS volume created from an Amazon EBS snapshot. You can choose between Amazon EC2 instance store and Amazon EBS as the root device for your AMI. We recommend using AMIs backed by EBS, because they launch faster and use persistent storage.
An Amazon EC2 instance can be launched from one of two types of AMIs: an
Amazon EC2 instance store-backed AMI or an Amazon EBS-backed AMI. The description of an AMI includes type of AMI
it is (you'll see the root device referred to in some places as either ebs (for
Amazon EBS-backed) or instance store (for Amazon EC2 instance store-backed). This is important
because there are significant differences between what you can do with each type of AMI. For a
discussion of these differences, see Basics of Amazon EBS-Backed AMIs and Instances.
Instances that use Amazon S3 for the root device automatically have instance stores available on them with a separate root partition. When an instance is launched, an Amazon S3 image is copied to the root partition. This image is used to boot the instance. Any data on the instance stores persists as long as the instance is running and is deleted when the instance fails or terminates.

After an EC2 instance store-backed instance fails or terminates, it cannot be restored. If you plan to use Amazon EC2 instance store-backed instances, we highly recommend that you distribute the data on your instance stores across multiple Availibility Zones. You should also have a plan for backing up the data on your instance stores to Amazon S3 on a regular basis.
Instances that use Amazon EBS for the root device automatically have an Amazon EBS volume attached. When an Amazon EBS-backed instance is launched, an EBS volume is created for each EBS snapshot referenced by the AMI. You must have at least one snapshot that denotes the root device; the others are optional and denote additional volumes to be created from other snapshots.
An Amazon EBS-backed instance can be stopped and later restarted without affecting data stored in the attached volumes. There are various instance- and volume-related tasks you can do when an Amazon EBS-backed instance is in a stopped state. For example, you can modify the properties of the instance, you can change the size of your instance or update the kernel it is using, or you can attach your root volume to a different running instance for debugging or any other purpose.

By default, the root device volume and the other volumes created when an Amazon
EBS-backed instance is launched are automatically deleted when the instance terminates (in other
words, their DeleteOnTermination flags are set to true by default).
You can change the default behavior by setting the DeleteOnTermination flag to the
value you want when you launch the instance. For an example of how to change the flag at launch
time, see Using Amazon EC2 Root Device Storage.
However, any volumes that you attach after the instance is
running (their DeleteOnTermination flags are set to false by default)
are detached with their data intact on instance termination. These volumes can later be
reattached to any running instance.
If an Amazon EBS-backed instance fails, you can restore your session by following one of these methods:
You can stop and then start again.
You can use CreateImage to automatically snapshot all the relevant
volumes and create a new AMI. For more information, see Creating Amazon EBS-Backed AMIs.
You can attach the volume to the new instance by following these steps:
Snapshot just the root volume.
Register a new AMI using the snapshot.
Launch a new instance from the new AMI.
Detach the remaining volumes from the old instance.
Reattach the volumes to the new instance.
We recommend using either the first or the second method for failed instances with normal volume size and the third method for failed instances with large volumes.
You can implement Amazon EBS backed AMIs by creating a set of snapshots and registering an AMI that uses those snapshots. The AMI publisher controls the default size of the root device through the size of the snapshot. The default size can be increased up to 1TiB to accommodate the requirements of the application either at the time you register the EBS-backed AMI or while you launch the EBS-backed instance.
Launching an Amazon EBS-backed Instance with Increased Root Device Storage Disk Size
|
1 |
Select an Amazon EBS-backed AMI to launch your instance from. | |||
|
2 |
Check the root device size and note the AMI ID. | |||
|
3 |
Using the command line interface, launch the instance by specifying the AMI ID and the mapping of the root device with the increased size. | |||
|
4 |
Connect to the instance. | |||
|
5 |
Check the size of the root device on the instance.
| |||
|
6 |
Resize the file system. | |||
|
7 |
Check the size of the root device. | |||
|
8 |
The root device of the newly launched instance now shows the increased size. |
![]() | Note |
|---|---|
You cannot decrease the size of your root device to less than the size of the AMI. To decrease the size of your root device, create your own AMI with the desired size for the root device and then launch an instance from that AMI. |
Increasing the Size of the Root Device on an Amazon EBS-Backed Running Instance
|
1 |
Get the Amazon EBS volume ID and the Availability Zone of a running instance for which you want to increase the root storage size. |
|
2 |
Stop the instance. |
|
3 |
Detach the original volume from the instance. |
|
4 |
Create a snapshot of the detached volume. |
|
5 |
Create a new volume from the snapshot by specifying a larger size. |
|
6 |
Attach the new volume to the stopped instance. |
|
7 |
Start the instance and get the new IP address/hostname. |
|
8 |
Connect to the instance using the new IP address/hostname. |
|
9 |
Resize the root file system to the extent of the new Amazon EBS volume. |
|
10 |
Check the size of the root device. The root device nows shows the increased size. |
|
11 |
[Optional] Delete the old EBS volume, if you no longer need it. |
The following list describes the tasks for creating a snapshot of the root device of an Amazon EC2 instance store-backed instance. The snapshot is created using an Amazon EBS volume. You can use this snapshot to create a new EBS-backed AMI or to launch another instance.
Creating a Snapshot of the Root Device of an Amazon EC2 instance store-backed Instance
|
1 |
Launch an instance from an Amazon EC2 instance store-backed AMI. | |||
|
2 |
Create a 10GiB Amazon EBS volume in the same Availability Zone as that of your newly launched instance.
| |||
|
3 |
Attach the volume to the running instance using either the AWS Management Console or the command line tools. | |||
|
4 |
Format the volume with a file system. | |||
|
5 |
[For Linux Users] Create a directory and then mount the volume on the newly created directory. | |||
|
6 |
Copy the data on the root storage device to the newly attached EBS volume. | |||
|
7 |
Unmount and detach the volume from the instance. | |||
|
8 |
Create a snapshot of the volume. |
Amazon EC2 instance store-backed AMIs are limited to 10GiB storage for the root device. If you require additional storage on your root device, you will have to first convert the Amazon EC2 instance store-backed AMI to an Amazon EBS-backed AMI and then launch an EBS-backed instance with increased root storage.
Converting an instance store-backed AMI to an Amazon EBS-backed AMI
|
1 |
Launch an instance from an Amazon EC2 instance store-backed AMI. | |||
|
2 |
Create a 10GiB Amazon EBS volume in the same Availability Zone as that of your newly launched instance.
| |||
|
3 |
Attach the volume to the running instance using either the AWS Management Console or the Command Line Tools. | |||
|
4 |
Format the volume with a file system. | |||
|
5 |
[For Linux Users] Create a directory and then mount the volume on the newly created directory. | |||
|
6 |
Copy the data on the root storage device to the newly attached EBS volume. | |||
|
7 |
Unmount and detach the volume from the instance. | |||
|
8 |
Create a snapshot of the volume. | |||
|
9 |
Register the snapshot of the volume as an AMI. |
By default, the root device volume for an AMI backed by Amazon EBS is deleted when the instance terminates. This section describes how to change the default behavior of the root device volume.
Topics
In this section, we show you how to set the DeleteOnTermination flag to false in the instance's block device
mapping at launch time. You can't currently do this in the AWS Management Console; you must use the command
line tools or Amazon EC2 API. You can verify the change in the console, however.
To change the DeleteOnTermination flag at launch time
In your ec2-run-instances request, include a block device mapping that
sets the deleteOnTermination flag for the root device to false.
Include the -v option to run the command in verbose mode.
PROMPT>ec2-run-instancesami_id-broot_device_name=::falseother parameters...-v
The root device is typically /dev/sda1, or xvda (for Windows). Following is an example.
PROMPT>ec2-run-instances ami-1a2b3c4d -b /dev/sda1=::falseother parameters...-v
If you're using the command line tools on a Windows system, you need to put quotation marks around the block device mapping value.
PROMPT>ec2-run-instances ami-1a2b3c4d -b "xvda=::false"other parameters...-v
By running the command in verbose mode, you can see the underlying SOAP
request, and confirm that the deleteOnTermination value is set to
false. The following XML snippet is from the SOAP request sent to Amazon
EC2.
...
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<deleteOnTermination>false</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
...You can also verify the setting after the instance launches by viewing the instance's details in the AWS Management Console.
To change the DeleteOnTermination flag at launch time
Issue the following Query request to include a block device mapping that sets the
deleteOnTermination flag for the root device to false. If it's a
Windows AMI, use xvda instead of /dev/sda1 as the root device name.
https://ec2.amazonaws.com/ ?Action=RunInstances &ImageId=ami-1a2b3c4d &BlockDeviceMapping.1.DeviceName=/dev/sda1 &BlockDeviceMapping.1.Ebs.DeleteOnTermination=false &...auth parameters...
You can confirm the setting by using DescribeInstances. The following example snippet
from the XML response shows that the flag is set to false for the instance's root device.
...
<rootDeviceName>/dev/sda1</rootDeviceName>
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<volumeId>vol-818843e8</volumeId>
<status>attached</status>
<attachTime>2010-02-22T20:36:18.000Z</attachTime>
<deleteOnTermination>false</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
...You can also verify the setting by viewing the instance's details in the AWS Management Console. For more information, see Viewing Block Device Mappings.