Menu
Amazon Elastic Compute Cloud
User Guide for Linux Instances

Amazon EC2 Root Device Volume

When you launch an 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 backed 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.

Root Device Storage Concepts

You can launch an instance from one of two types of AMIs: an instance store-backed AMI or an Amazon EBS-backed AMI. The description of an AMI includes which 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 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, but this data is deleted when the instance is terminated (instance store-backed instances do not support the Stop action) or if it fails (such as if an underlying drive has issues).

Root device on an Amazon EC2 instance store-backed instance

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 persistent storage 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 Amazon EBS snapshot referenced by the AMI you use. You can optionally use other Amazon EBS volumes or instance store volumes.

Root device volume and other Amazon EBS volumes of an Amazon EBS-backed instance

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 (try this method first).

  • Automatically snapshot all relevant volumes and create a new AMI. For more information, see Creating an Amazon EBS-Backed Linux AMI.

  • Attach the volume to the new instance by following these steps:

    1. Create a snapshot of the root volume.

    2. Register a new AMI using the snapshot.

    3. Launch a new instance from the new AMI.

    4. Detach the remaining Amazon EBS volumes from the old instance.

    5. Reattach the Amazon EBS volumes to the new instance.

Choosing an AMI by Root Device Type

The AMI that you specify when you launch your instance determines the type of root device volume that your instance has.

To choose an Amazon EBS-backed AMI using the console

  1. Open the Amazon EC2 console.

  2. In the navigation pane, click AMIs.

  3. From the filter lists, select the image type (such as Public images). In the search bar click Platform to select the operating system (such as Amazon Linux), and Root Device Type to select EBS images.

  4. (Optional) To get additional information to help you make your choice, click the Show/Hide Columns icon, update the columns to display, and click Close.

  5. Choose an AMI and write down its AMI ID.

To choose an instance store-backed AMI using the console

  1. Open the Amazon EC2 console.

  2. In the navigation pane, click AMIs.

  3. From the filter lists, select the image type (such as Public images). In the search bar, click Platform to select the operating system (such as Amazon Linux), and Root Device Type to select Instance store.

  4. (Optional) To get additional information to help you make your choice, click the Show/Hide Columns icon, update the columns to display, and click Close.

  5. Choose an AMI and write down its AMI ID.

To verify the type of the root device volume of an AMI using the command line

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

Determining the Root Device Type of Your Instance

To determine the root device type of an instance using the console

  1. Open the Amazon EC2 console.

  2. In the navigation pane, click Instances, and select the instance.

  3. Check the value of Root device type in the Description tab as follows:

    • If the value is ebs, this is an Amazon EBS-backed instance.

    • If the value is instance store, this is an instance store-backed instance.

To determine the root device type of 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.

Changing the Root Device Volume to Persist

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 attribute to false using a block device mapping.

Changing the Root Volume to Persist Using the Console

Using the console, you can change the DeleteOnTermination attribute when you launch an instance. To change this attribute for a running instance, you must use the command line.

To change the root device volume of an instance to persist at launch using the console

  1. Open the Amazon EC2 console.

  2. From the Amazon EC2 console dashboard, click Launch Instance.

  3. On the Choose an Amazon Machine Image (AMI) page, choose the AMI to use and click Select.

  4. Follow the wizard to complete the Choose an Instance Type and Configure Instance Details pages.

  5. On the Add Storage page, deselect the Delete On Termination check box for the root volume.

  6. Complete the remaining wizard pages, and then click Launch.

You can verify the setting by viewing details for the root device volume on the instance's details pane. Next to Block devices, click the entry for the root device volume. By default, Delete on termination is True. If you change the default behavior, Delete on termination is False.

Changing the Root Volume of an Instance to Persist Using the AWS CLI

Using the AWS CLI, you can change the DeleteOnTermination attribute when you launch an instance or while the instance is running. The root device is typically /dev/sda1 (Linux) or xvda (Windows).

Example at Launch

Use the run-instances command to preserve the root volume by including a block device mapping that sets its DeleteOnTermination attribute for to false.

$ aws ec2 run-instances --image-id ami-1a2b3c4d --block-device-mappings '[{"DeviceName":"/dev/sda1","Ebs":{"DeleteOnTermination":false}}]' other parameters...

You can confirm that DeleteOnTermination is false by using the describe-instances command and looking for the BlockDeviceMappings entry for /dev/sda1 in the command output, as shown here.

...
"BlockDeviceMappings": [
    {
        "DeviceName": "/dev/sda1",
        "Ebs": {
            "Status": "attached",
            "DeleteOnTermination": false,
            "VolumeId": "vol-1234567890abcdef0",
            "AttachTime": "2013-07-19T02:42:39.000Z"
        }
    }              
...

Example While the Instance is Running

Use the modify-instance-attribute command to preserve the root volume by including a block device mapping that sets its DeleteOnTermination attribute to false.

$ aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --block-device-mappings  '[{"DeviceName":"/dev/sda1","Ebs":{"DeleteOnTermination":false}}]'