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

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

Note

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

You can also view the instance store volumes using Windows Disk Management. For more information, see List disks using Disk Management.

To manually mount an instance store volume
  1. Choose Start, enter Computer Management, and then press Enter.

  2. In left-hand panel, choose Disk Management.

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

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

  5. On the wizard, choose Next.

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

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

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

  9. Choose Next, Finish.

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.