Add instance store volumes to an Amazon EC2 AMI (original) (raw)

You can create an AMI with a block device mapping that includes instance store volumes.

If you launch an instance that supports non-NVMe instance store volumes using an AMI that specifies instance store volume block device mappings, the instance includes the instance store volumes. If the number of instance store volume block device mappings in the AMI exceeds the number of instance store volumes available to the instance, the additional instance store volume block device mappings are ignored.

If you launch an instance that supports NVMe instance store volumes using an AMI that specifies instance store volume block device mappings, the instance store volume block device mappings are ignored. Instances that support NVMe instance store volumes get all of their supported instance store volumes, regardless of the block device mappings specified in the instance launch request and the AMI. The device mapping of these volumes depends on the order in which the operating system enumerates the volumes.

Considerations

Console

To add instance store volumes to an Amazon EBS-backed AMI
  1. Open the Amazon EC2 console athttps://console.aws.amazon.com/ec2/.
  2. In the navigation pane, choose Instances and select the instance.
  3. Choose Actions, Image and templates,Create image.
  4. On the Create image page, enter a meaningful name and description for your image.
  5. For each instance store volume to add, choose Add volume, from Volume type select an instance store volume, and fromDevice select a device name.
  6. Choose Create image.

AWS CLI

To add instance store volumes to an AMI

Use the create-image command with the --block-device-mappings option to specify a block device mapping for an EBS-backed AMI. Use the register-image command with the --block-device-mappings option to specify a block device mapping for an instance store-backed AMI.

--block-device-mappings file://mapping.json

The following block device mapping adds two instance store volumes.

[
    {
        "DeviceName": "/dev/sdc",
        "VirtualName": "ephemeral0"
    },
    {
        "DeviceName": "/dev/sdd",
        "VirtualName": "ephemeral1"
    }
]

PowerShell

To add instance store volumes to an AMI

Use the New-EC2Image cmdlet with the -BlockDeviceMapping parameter to specify a block device mapping for an EBS-backed AMI. Use the Register-EC2Image cmdlet with the -BlockDeviceMapping parameter to specify a block device mapping for an instance store-backed AMI.

-BlockDeviceMapping $bdm

The following block device mapping adds two instance store volumes.

$bdm = @()

$sdc = New-Object -TypeName Amazon.EC2.Model.BlockDeviceMapping
$sdc.DeviceName = "/dev/sdc"
$sdc.VirtualName = "ephemeral0" <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>b</mi><mi>d</mi><mi>m</mi><mo>+</mo><mo>=</mo></mrow><annotation encoding="application/x-tex">bdm += </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">b</span><span class="mord mathnormal">d</span><span class="mord mathnormal">m</span><span class="mord">+</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>sdc

$sdd = New-Object -TypeName Amazon.EC2.Model.BlockDeviceMapping
$sdd.DeviceName = "/dev/sdd"
$sdd.VirtualName = "ephemeral1" <span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>b</mi><mi>d</mi><mi>m</mi><mo>+</mo><mo>=</mo></mrow><annotation encoding="application/x-tex">bdm += </annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.7778em;vertical-align:-0.0833em;"></span><span class="mord mathnormal">b</span><span class="mord mathnormal">d</span><span class="mord mathnormal">m</span><span class="mord">+</span><span class="mspace" style="margin-right:0.2778em;"></span><span class="mrel">=</span></span></span></span>sdd