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 device volume
When you launch an instance, the root device volume contains the
image used to boot the instance. When you launch a Windows instance, a root EBS volume is
created from an EBS snapshot and attached to the instance.
By default, the root volume is deleted when the instance terminates (the
DeleteOnTermination
attribute is true
). Using the console, you
can change DeleteOnTermination
when you launch an instance. To change this
attribute for an existing instance, you must use the command line.
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
-
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Instances and then choose
Launch instances.
-
On the Choose an Amazon Machine Image (AMI) page,
select the AMI to use and choose Select.
-
Follow the wizard to complete the Choose an Instance Type
and Configure Instance Details pages.
-
On the Add Storage page, deselect Delete On
Termination for the root volume.
-
Complete the remaining wizard pages, and then choose
Launch.
- 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
.
C:\>
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...
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.
- New console
-
To confirm that a root volume is configured to persist using the Amazon EC2 console
-
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Instances and then select
the instance.
-
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.
- Old console
-
To confirm that a root volume is configured to persist using the Amazon EC2 console
-
Open the Amazon EC2 console at
https://console.amazonaws.cn/ec2/.
-
In the navigation pane, choose Instances and then select
the instance.
-
In the Description tab, choose the entry for
Root device. If Delete on termination is
False
, 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
.
C:\>
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.
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.