Amazon EC2 instance root volume - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Amazon EC2 instance root volume

When you launch an instance, we create a root volume for the instance. The root volume contains the image used to boot the instance. Each instance has a single root volume. You can add storage volumes to your instances when you launch them or after they are running.

We reserve specific device names for root volumes. For more information, see Device names on Linux instances.

Root volume type

You can launch an instance from either 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. We recommend that you use AMIs backed by Amazon EBS, because these instances launch faster and use persistent storage.

Amazon EBS-backed instances

Instances that use Amazon EBS for the root volume 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, depending on the instance type.

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, change its size, 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. For more information, see Amazon EBS volumes.


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

You can't use st1 or sc1 EBS volumes as root volumes.

Instance failure

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 Create 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.

Instance store-backed instances

Instances that use instance stores for the root volume automatically have one or more instance store volumes available, with one volume serving as the root volume. When an instance is launched, the image that is used to boot the instance is copied to the root volume. Note that you can optionally use additional instance store volumes, depending on the instance type.

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). For more information, see Amazon EC2 instance store.


     Root volume on an Amazon EC2 instance store-backed instance
Requirement

Only the following instance types support an instance store volume as the root volume: C3, D2, G2, I2, M3, and R3.

Instance failure

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 critical data from your instance store volumes to persistent storage on a regular basis.

Choose an AMI by root volume type

The AMI that you specify when you launch your instance determines the type of root device volume that your instance has. You can view AMIs by root device type using one of the following methods.

Console
To choose an Amazon EBS-backed AMI using the console
  1. Open the Amazon EC2 console.

  2. In the navigation pane, choose AMIs.

  3. From the filter lists, select the image type (such as Public images). In the search bar, choose Platform to select the operating system (such as Amazon Linux) and Root device type to select the root volume type (ebs).

  4. (Optional) To get additional information to help you make your choice, choose the Preferences icon, toggle the columns to display, and choose Confirm.

  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, choose AMIs.

  3. From the filter lists, select the image type (such as Public images). In the search bar, choose Platform to select the operating system (such as Amazon Linux), and Root device type to select the root volume type (instance-store).

  4. (Optional) To get additional information to help you make your choice, choose the Preferences icon, toggle the columns to display, and choose Confirm.

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

Amazon CLI
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 Access Amazon EC2.

Determine the root device type of your instance

Console
To determine the root device type of an instance using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

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

  3. On the Storage tab, under Root device details, check the value of Root device type 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.

Amazon CLI
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 Access Amazon EC2.

Change the root volume to persist

By default, the root volume for an AMI backed by Amazon EBS is deleted when the instance terminates. You can change the default behavior to ensure that the volume persists after the instance terminates. To change the default behavior, set the DeleteOnTermination attribute to false using a block device mapping.

Configure the root volume to persist during instance launch

You can configure the root volume to persist when you launch an instance using the Amazon EC2 console or the command line tools.

Console
To configure the root volume to persist when you launch an instance using the console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation pane, choose Instances and then choose Launch instances.

  3. Choose an Amazon Machine Image (AMI), choose and instance type, choose a key pair, and configure your network settings.

  4. For Configure storage, choose Advanced.

  5. Expand the root volume.

  6. For Delete on termination, choose No.

  7. When you are finished configuring your instance, choose Launch instance.

Amazon CLI
To configure the root volume to persist when you launch an instance using the Amazon CLI

Use the run-instances command and include a block device mapping that sets the DeleteOnTermination attribute to false.

$ aws ec2 run-instances --block-device-mappings file://mapping.json ...other parameters...

Specify the following in mapping.json.

[ { "DeviceName": "/dev/sda1", "Ebs": { "DeleteOnTermination": false } } ]
Tools for Windows PowerShell
To configure the root volume to persist when you launch an instance using the Tools for Windows PowerShell

Use the New-EC2Instance command and include a block device mapping that sets the DeleteOnTermination attribute to false.

C:\> $ebs = New-Object Amazon.EC2.Model.EbsBlockDevice C:\> $ebs.DeleteOnTermination = $false C:\> $bdm = New-Object Amazon.EC2.Model.BlockDeviceMapping C:\> $bdm.DeviceName = "dev/xvda" C:\> $bdm.Ebs = $ebs C:\> New-EC2Instance -ImageId ami-0abcdef1234567890 -BlockDeviceMapping $bdm ...other parameters...

Configure the root volume to persist for an existing instance

You can configure the root volume to persist for a running instance using the command line tools only.

Amazon CLI
To configure the root volume to persist for an existing instance using the Amazon CLI

Use the modify-instance-attribute command with a block device mapping that sets the DeleteOnTermination attribute to false.

aws ec2 modify-instance-attribute --instance-id i-1234567890abcdef0 --block-device-mappings file://mapping.json

Specify the following in mapping.json.

[ { "DeviceName": "/dev/xvda", "Ebs": { "DeleteOnTermination": false } } ]
Tools for Windows PowerShell
To configure the root volume to persist for an existing instance using the Amazon Tools for Windows PowerShell

Use the Edit-EC2InstanceAttribute command with a block device mapping that sets the DeleteOnTermination attribute to false.

C:\> $ebs = New-Object Amazon.EC2.Model.EbsInstanceBlockDeviceSpecification C:\> $ebs.DeleteOnTermination = $false C:\> $bdm = New-Object Amazon.EC2.Model.InstanceBlockDeviceMappingSpecification C:\> $bdm.DeviceName = "/dev/xvda" C:\> $bdm.Ebs = $ebs C:\> Edit-EC2InstanceAttribute -InstanceId i-1234567890abcdef0 -BlockDeviceMapping $bdm

Confirm that a root volume is configured to persist

You can confirm that a root volume is configured to persist using the Amazon EC2 console or the command line tools.

Console
To confirm that a root volume is configured to persist using the Amazon EC2 console
  1. Open the Amazon EC2 console at https://console.amazonaws.cn/ec2/.

  2. In the navigation pane, choose Instances and then select the instance.

  3. In the Storage tab, under Block devices, locate the entry for the root volume. If Delete on termination is No, the volume is configured to persist.

Amazon CLI
To confirm that a root volume is configured to persist using the Amazon CLI

Use the describe-instances command and verify that the DeleteOnTermination attribute in the BlockDeviceMappings response element is set to false.

$ aws ec2 describe-instances --instance-id i-1234567890abcdef0
... "BlockDeviceMappings": [ { "DeviceName": "/dev/sda1", "Ebs": { "Status": "attached", "DeleteOnTermination": false, "VolumeId": "vol-1234567890abcdef0", "AttachTime": "2013-07-19T02:42:39.000Z" } } ...
Tools for Windows PowerShell
To confirm that a root volume is configured to persist using the Amazon Tools for Windows PowerShell

Use the Get-EC2Instance and verify that the DeleteOnTermination attribute in the BlockDeviceMappings response element is set to false.

C:\> (Get-EC2Instance -InstanceId i-i-1234567890abcdef0).Instances.BlockDeviceMappings.Ebs

Change the initial size of the root volume

By default, the size of the root volume is determined by the size of the snapshot. You can increase the initial size of the root volume using the block device mapping of the instance as follows.

  1. Determine the device name of the root volume specified in the AMI, as described in View the EBS volumes in an AMI block device mapping.

  2. Confirm the size of the snapshot specified in the AMI block device mapping.

  3. Override the size of the root volume using the instance block device mapping, as described in Update the block device mapping when launching an instance, specifying a volume size that is larger than the snapshot size.

For example, the following entry for the instance block device mapping increases the size of the root volume, /dev/xvda, to 100 GiB. You can omit the snapshot ID in the instance block device mapping because the snapshot ID is already specified in the AMI block device mapping.

{ "DeviceName": "/dev/xvda", "Ebs": { "VolumeSize": 100 } }

For more information, see Block device mappings.