

# Add instance store volumes to an EC2 instance
<a name="add-instance-store-volumes"></a>

For instance types with **NVMe instance store volumes**, all of the supported instance store volumes are automatically attached to the instance at launch. They are automatically enumerated and assigned a device name on instance launch.

For instance types with **non-NVMe instance store volumes**, such as C1, C3, M1, M2, M3, R3, D2, H1, I2, X1, and X1e, you must manually specify the block device mappings for the instance store volumes that you want to attach at launch. Block device mappings can be specified in the instance launch request or in the AMI used to launch the instance. The block device mapping includes a device name and the volume that it maps to. For more information, see [Block device mappings for volumes on Amazon EC2 instances](block-device-mapping-concepts.md)

**Important**  
Instance store volumes can be attached to an instance only when you launch it. You can't attach instance store volumes to an instance after you've launched it.

After you launch an instance, you must ensure that the instance store volumes for your instance are formatted and mounted before you can use them. The instance store root volume is mounted automatically.

**Consideration for root volumes**  
A block device mapping always specifies the root volume for the instance. The root volume is always mounted automatically.

**Linux instances** – The root volume is either an Amazon EBS volume or an instance store volume. For instances with an instance store volume for the root volume, the size of this volume varies by AMI, but the maximum size is 10 GB. For more information, see [Root volume type](ComponentsAMIs.md#storage-for-the-root-device).

**Windows instances** – The root volume must be an Amazon EBS volume. Instance store is not supported for the root volume.

**Topics**
+ [

# Add instance store volumes to an Amazon EC2 AMI
](adding-instance-storage-ami.md)
+ [

# Add instance store volumes to an EC2 instance during launch
](adding-instance-storage-instance.md)
+ [

# Make instance store volume available for use on an EC2 instance
](making-instance-stores-available-on-your-instances.md)

# Add instance store volumes to an Amazon EC2 AMI
<a name="adding-instance-storage-ami"></a>

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**
+ The number of available instance store volumes depends on the instance type. For more information, see [Available instance store volumes](instance-store-volumes.md#available-instance-store-volumes).
+ You must specify a device name for each block device. For more information, see [Device names for volumes on Amazon EC2 instances](device_naming.md).
+ When you launch an instance, you can omit non-NVMe instance store volumes specified in the AMI block device mapping or add instance store volumes.
+ For M3 instances, specify instance store volumes in the block device mapping of the instance, not the AMI. Amazon EC2 might ignore instance store volume block device mappings in the AMI.

------
#### [ Console ]

**To add instance store volumes to an Amazon EBS-backed AMI**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. In the navigation pane, choose **Instances** and select the instance.

1. Choose **Actions**, **Image and templates**, **Create image**.

1. On the **Create image** page, enter a meaningful name and description for your image.

1. For each instance store volume to add, choose **Add volume**, from **Volume type** select an instance store volume, and from **Device** select a device name. 

1. Choose **Create image**.

------
#### [ AWS CLI ]

**To add instance store volumes to an AMI**  
Use the [create-image](https://docs.aws.amazon.com/cli/latest/reference/ec2/create-image.html) command with the `--block-device-mappings` option to specify a block device mapping for an EBS-backed AMI. Use the [register-image](https://docs.aws.amazon.com/cli/latest/reference/ec2/register-image.html) command with the `--block-device-mappings` option to specify a block device mapping for an iAmazon S3-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](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Image.html) cmdlet with the `-BlockDeviceMapping` parameter to specify a block device mapping for an EBS-backed AMI. Use the [Register-EC2Image](https://docs.aws.amazon.com/powershell/latest/reference/items/Register-EC2Image.html) cmdlet with the `-BlockDeviceMapping` parameter to specify a block device mapping for an Amazon S3-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"
$bdm += $sdc

$sdd = New-Object -TypeName Amazon.EC2.Model.BlockDeviceMapping
$sdd.DeviceName = "/dev/sdd"
$sdd.VirtualName = "ephemeral1"
$bdm += $sdd
```

------

# Add instance store volumes to an EC2 instance during launch
<a name="adding-instance-storage-instance"></a>

When you launch an instance type with **non-NVMe instance store volumes**, such as C1, C3, M1, M2, M3, R3, D2, H1, I2, X1, and X1e, you must specify the block device mappings for the instance store volumes that you want to attach at launch. The block device mappings must be specified in the instance launch request or in the AMI used to launch the instance.

If the AMI includes block device mappings for the instance store volumes, you do not need to specify block device mappings in the instance launch request, unless you need more instance store volumes than is included in the AMI.

If the AMI does not include block device mappings for instance store volumes, then you must specify the block device mappings in the instance launch request.

For instance types with NVMe instance store volumes, all of the supported instance store volumes are automatically attached to the instance at launch.

**Considerations**
+ The number of available instance store volumes depends on the instance type. For more information, see [Available instance store volumes](instance-store-volumes.md#available-instance-store-volumes).
+ You must specify a device name for each block device. For more information, see [Device names for volumes on Amazon EC2 instances](device_naming.md).
+ For M3 instances, you might receive instance store volumes even if you do not specify them in the block device mapping for the instance.

------
#### [ Console ]

**To specify a block device mapping in an instance launch request**

1. Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/).

1. From the dashboard, choose **Launch instance**.

1. In the **Application and OS Images** section, select the AMI to use.

1. In the **Configure storage** section, the **Instance store volumes** section lists the instance store volumes that can be attached to the instance.

1. For each instance store volume to attach, for **Device name**, select the device name to use.

1. Configure the remaining instance settings as needed, and then choose **Launch instance**.

------
#### [ AWS CLI ]

**To specify a block device mapping in an instance launch request**  
Use the [run-instances](https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html) command with the `--block-device-mappings` option.

```
--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 specify a block device mapping in an instance launch request**  
Use the [New-EC2Instance](https://docs.aws.amazon.com/powershell/latest/reference/items/New-EC2Instance.html) cmdlet with the `-BlockDeviceMapping` option.

```
-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"
$bdm += $sdc

$sdd = New-Object -TypeName Amazon.EC2.Model.BlockDeviceMapping
$sdd.DeviceName = "/dev/sdd"
$sdd.VirtualName = "ephemeral1"
$bdm += $sdd
```

------

# Make instance store volume available for use on an EC2 instance
<a name="making-instance-stores-available-on-your-instances"></a>

After you launch an instance with attached instance store volumes, you must mount the volumes before you can access them.

## Linux instances
<a name="view-instance-store-linux"></a>

You can format volumes with the file system of your choice after you launch your instance.

**To make an instance store volume available on Linux**

1. Connect to the instance using an SSH client. For more information, see [Connect to your Linux instance using SSH](connect-to-linux-instance.md).

1. Use the `df -h` command to view the volumes that are formatted and mounted.

   ```
   $ df -h
   Filesystem      Size  Used Avail Use% Mounted on
   devtmpfs        3.8G   72K  3.8G   1% /dev
   tmpfs           3.8G     0  3.8G   0% /dev/shm
   /dev/nvme0n1p1  7.9G  1.2G  6.6G  15% /
   ```

1. Use the `lsblk` to view any volumes that were mapped at launch but not formatted and mounted.

   ```
   $ lsblk
   NAME          MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
   nvme0n1       259:1    0    8G  0 disk
   ├─nvme0n1p1   259:2    0    8G  0 part /
   └─nvme0n1p128 259:3    0    1M  0 part
   nvme1n1       259:0    0 69.9G  0 disk
   ```

1. To format and mount an instance store volume that was mapped only, do the following:

   1. Create a file system on the device using the `mkfs` command.

      ```
      $ sudo mkfs -t xfs /dev/nvme1n1
      ```

   1. Create a directory on which to mount the device using the `mkdir` command.

      ```
      $ sudo mkdir /data
      ```

   1. Mount the device on the newly created directory using the `mount` command.

      ```
      $ sudo mount /dev/nvme1n1 /data
      ```

## Windows instances
<a name="view-instance-store-windows"></a>

For Windows instances, we reformat the instance store volumes with the NTFS file system.

You can view the instance store volumes using Windows Disk Management. For more information, see [List non-NVMe disks](windows-list-disks.md#windows-disks).

**To manually mount an instance store volume**

1. Choose **Start**, enter **Computer Management**, and then press **Enter**.

1. In left-hand panel, choose **Disk Management**.

1. If you are prompted to initialize the volume, choose the volume to initialize, select the required partition type depending on your use case, and then choose **OK**.

1. In the list of volumes, right-click the volume to mount, and then choose **New Simple Volume**.

1. On the wizard, choose **Next**.

1. On the Specify Volume Size screen, choose **Next** to use the maximum volume size. Alternatively, choose a volume size that is between the minimum and maximum disk space.

1. On the Assign a Drive Letter or Path screen, do one of the following, and choose **Next**.
   + To mount the volume with a drive letter, choose **Assign the following drive letter** and then choose the drive letter to use.
   + To mount the volume as a folder, choose **Mount in the following empty NTFS folder** and then choose **Browse** to create or select the folder to use.
   + To mount the volume without a drive letter or path, choose **Do not assign a drive letter or drive path**.

1. On the Format Partition screen, specify whether or not to format the volume. If you choose to format the volume, choose the required file system and unit size, and specify a volume label.

1. Choose **Next**, **Finish**.