| « PreviousNext » | |
![]() ![]() ![]() | Did this page help you? Yes | No | Tell us about it... |
When you launch an Amazon EC2 instance, the root device volume contains the image used to boot the instance. When we introduced Amazon EC2, all AMIs were backed by Amazon EC2 instance store, which means the root device for an instance launched from the AMI is an instance store volume created from a template stored in Amazon S3. After we introduced Amazon EBS, we introduced AMIs that are backed by Amazon EBS. This means that the root device for an instance launched from the AMI is an Amazon EBS volume created from an Amazon EBS snapshot. You can choose between AMIs based by Amazon EC2 instance store and AMIs backed by Amazon EBS. We recommend that you use AMIs backed by Amazon EBS, because they launch faster and use persistent storage.
Topics
You can launch an instance 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 more
information about these differences, see Storage for the Root Device.
Instance Store-backed Instances
Instances that use instance stores for the root device automatically have instance store volumes available, with one serving as the root device volume. When an instance is launched, the image that is used to boot the instance is copied to the root volume (typically sda1). Any data on the instance store volumes persists as long as the instance is running and is deleted when the instance is stopped, terminated, or fails (such as if an underlying drive fails).

After an 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 Availability Zones. You should also back up the data on your instance store volumes to Amazon S3 on a regular basis.
For more information, see Amazon EC2 Instance Store.
Amazon EBS-backed Instances
Instances that use Amazon EBS for the root device automatically have an Amazon EBS volume attached. When you launch an Amazon EBS-backed instance, we create an Amazon EBS volume for each EBS snapshot referenced by the AMI you use. You can optionally use other Amazon EBS volumes or instance store volumes.

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 Amazon EBS volumes attached when you launch an Amazon EBS-backed instance are automatically deleted when the instance terminates. For information about how to change this behavior when you launch an instance, see Changing the Root Device Volume to Persist.
By default, any Amazon EBS volumes that you attach to a running instance are detached with their data intact when the instance terminates. You can attach a detached volume to any running instance.
If an Amazon EBS-backed instance fails, you can restore your session by following one of these methods:
Stop and then start again.
Automatically snapshot all relevant volumes and create a new AMI. For more information, see Creating Amazon EBS-Backed Linux AMIs.
Attach the volume to the new instance by following these steps:
Create a snapshot of the root volume.
Register a new AMI using the snapshot.
Launch a new instance from the new AMI.
Detach the remaining Amazon EBS volumes from the old instance.
Reattach the Amazon EBS 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 Amazon EBS-backed AMI or while you launch the Amazon 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. The increased size of the root device is not apparent yet. This is because the file system does not recognize the increased size on the root device. |
|
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 now shows the increased size. |
|
11 |
[Optional] Delete the old Amazon 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 Amazon 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. Note Use this volume to create a snapshot of the root partition of an Amazon EC2 instance store-backed AMI. The resulting snapshot is the same size as the root partition; the maximum size of the root partition in an Amazon EC2 instance store-backed AMI is 10GiB. |
|
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 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 must first convert the Amazon EC2 instance store-backed AMI to an Amazon EBS-backed AMI and then launch an Amazon EBS-backed instance with increased root storage.
Note
This conversion procedure works with a Linux AMI, but step 6 fails with a Windows AMI.
Converting an Amazon EC2 instance store-backed AMI to an Amazon EBS-backed AMI (Linux only)
|
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. Use this volume to create a snapshot of the root partition of the Amazon EC2 instance store-backed AMI. The resulting snapshot is the same size as the root partition; the maximum size of the root partition in an Amazon EC2 instance store-backed AMI is 10GiB. |
|
3 |
Attach the volume to the running instance using either the AWS Management Console or the command line interface. |
|
4 |
Format the volume with a file system. |
|
5 |
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 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. To change the default behavior, set the
DeleteOnTermination flag to false in the instance's block device
mapping.
To change the root device volume to persist when you launch an instance
Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.
From the Amazon EC2 console dashboard, click Launch Instance.
On the Create a New Instance page, click Classic Wizard.
On the CHOOSE AN AMI page, choose the AMI to use and click Select.
Follow the wizard to complete the first and second INSTANCE DETAIL pages.
On the third INSTANCE DETAIL page, under Storage Device Configuration, click Edit.
Deselect Delete On Termination on the Root Volume tab, click Save, and then click Continue.

Complete the remaining wizard pages, and then click Launch Instance.
You can verify the setting by viewing details for the root device volume on the instance's details pane
in the AWS Management Console. Under Block Devices, click the entry for the root
device volume. By default, Delete on termination is Yes. If you change the default behavior,
Delete on termination is No.

Use the ec2-run-instances command, and 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). The 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 must 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
request and response, and confirm that the deleteOnTermination value is set to false, as shown here.
...
<blockDeviceMapping>
<item>
<deviceName>/dev/sda1</deviceName>
<ebs>
<deleteOnTermination>false</deleteOnTermination>
</ebs>
</item>
</blockDeviceMapping>
...For more information, see ec2-run-instances.