Add instance store volumes to your EC2 instance - Amazon Elastic Compute Cloud

Add instance store volumes to your EC2 instance

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, G2, 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

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 root volume of an instance store-backed instance is mounted automatically.

Consideration for root volumes

A block device mapping always specifies the root volume for the instance. The root volume is either an Amazon EBS volume or an instance store volume. The root volume is mounted automatically. 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 Storage for the root device.

Add instance store volumes to an AMI

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.

Considerations
  • 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.

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

New console
To add instance store volumes to an Amazon EBS-backed AMI using the console
  1. Open the Amazon EC2 console at https://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 from Device select a device name. (For more information, see Device names on Linux instances.) The number of available instance store volumes depends on the instance type. For instances with NVMe instance store volumes, the device mapping of these volumes depends on the order in which the operating system enumerates the volumes.

  6. Choose Create image.

AWS CLI
To add instance store volumes to 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.

Add non-NVME instance store volumes to an instance

When you launch an instance that supports non-NVMe instance store volumes you must specify block device mappings for the instance store volumes to attach. 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.

Considerations
  • For M3 instances, you might receive instance store volumes even if you do not specify them in the block device mapping for the instance.

To specify block device mappings in the instance launch request, use one of the following methods.

Amazon EC2 console
  1. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

  2. From the dashboard, choose Launch instance.

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

  4. In the Configure storage section, the Instance store volumes section lists the instance store volumes that can be attached to the instance. The number of available instance store volumes depends on the instance type.

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

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

Command line

You can use one of the following options commands with the corresponding option.

Make instance store volumes available on your instance

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

For Linux instances, many instance store volumes are pre-formatted with the ext3 file system. SSD-based instance store volumes that support TRIM instruction are not pre-formatted with any file system. However, you can format volumes with the file system of your choice after you launch your instance. For more information, see Instance store volume TRIM support. For Windows instances, we reformat the instance store volumes with the NTFS file system.

You can confirm that the instance store devices are available from within the instance itself using instance metadata. For more information, see View the instance block device mapping for instance store volumes.

For Linux instances, you can view and mount the instance store volumes as described in the following procedure.

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.

  2. 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% /
  3. 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
  4. 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
    2. Create a directory on which to mount the device using the mkdir command.

      $ sudo mkdir /data
    3. Mount the device on the newly created directory using the mount command.

      $ sudo mount /dev/nvme1n1 /data

For instructions on how to mount an attached volume automatically after reboot, see Automatically mount an attached volume after reboot in the Amazon EBS User Guide.