I have an Amazon Elastic Compute Cloud (Amazon EC2) Linux instance with Amazon Elastic Block Store (Amazon EBS) volumes and instance store volumes attached. I want to identify the attached volumes that are instance store volumes.
Short description
To identify instance store volumes on Amazon EC2 Linux instances, first check if the instance type supports instance store volumes. If the instance supports instance store volumes, then check the type of instance store volumes that it supports. After that, review the volume's information from the operating system (OS).
Resolution
- Verify the type of instance store volume (HDD, SSD, or NVMe SSD), if any, that your instance supports. Check the quantity, size, type, and performance optimizations of instance store volumes that are available for each supported instance type.
- Determine which of your instance's attached volumes are instance store volumes. The identification method depends on whether you have NVMe SSD or HDD/SSD instance store volumes.
NVMe SSD instance store volumes
-
Connect to your instance.
-
Install the NVMe command line package, nvme-cli. Use the package management tools for your Linux distribution. For Amazon Linux instances, use the yum command to install the nvme-cli package. For download and installation instructions for other distributions, see the GitHub documentation for nvme-cli, or see the documentation for your distribution.
-
Run the nvme list command as a privileged user:
$ sudo nvme list
The Model column in this output example lists if each attached device is Amazon Elastic Block Store or Amazon EC2 NVMe Instance Storage. The example output is from an instance type that supports one NVMe SSD device:
$ sudo nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 vol0923757ba05df9515 Amazon Elastic Block Store 1 0.00 B / 8.59 GB 512 B + 0 B 1.0
/dev/nvme1n1 AWS1A4FC25FB16B79F76 Amazon EC2 NVMe Instance Storage 1 50.00 GB / 50.00 GB 512 B + 0 B 0
HDD or SSD instance store volumes
For HDD or SSD instance store volumes, get the list of attached block devices from the operating system. Then, retrieve the block device mapping section from the instance metadata.
-
Connect to your instance.
-
Run the lsblk command. If the lsblk command isn't present, then install the util-linux package from the package management tools for your Linux distribution. For Amazon Linux instances, install the util-linux package using the yum install command. For download and installation instructions for other distributions, refer to the documentation for your distribution:
$ sudo lsblk
This output example shows the list of block devices from an instance that has many drives. This instance runs on an instance type that supports SSD instance store volumes:
$ sudo lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 8G 0 disk
└─xvda1 202:1 0 8G 0 part /
xvdb 202:16 0 745.2G 0 disk
xvdc 202:32 0 745.2G 0 disk
xvdd 202:48 0 745.2G 0 disk
xvde 202:64 0 745.2G 0 disk
-
Identify if xvdb, from the previous example output, is an ephemeral drive. To do this, retrieve the block-device-mapping metadata. Use the base URL for all instance metadata requests (http://169.254.169.254/latest/meta-data/block-device-mapping):
$ curl http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0
sdb
$ ls -l /dev/sdb
lrwxrwxrwx 1 root root 4 Aug 27 13:07 /dev/sdb -> xvdb
In this example, the block device mapping for ephemeral0 is to sdb. This is a symbolic link to xvdb. This means that xvdb is an ephemeral device.
-
(Optional) You can also use these commands to automate the process to show your instance's ephemeral devices:
Identify the OS block devices:
OSDEVICE=$(sudo lsblk -o NAME -n | grep -v '[[:digit:]]' | sed "s/^sd/xvd/g")
Set the block device mapping URL:
BDMURL="http://169.254.169.254/latest/meta-data/block-device-mapping/"
Loop through OS devices and find the mapping in the block device mapping:
for bd in $(curl -s ${BDMURL}); do MAPDEVICE=$(curl -s ${BDMURL}/${bd}/ | sed "s/^sd/xvd/g"); if grep -wq ${MAPDEVICE} <<< "${OSDEVICE}"; then echo "${bd} is ${MAPDEVICE}"; fi; done | grep ephemeral
This example shows these three commands and an output:
$ OSDEVICE=$(sudo lsblk -o NAME -n | grep -v '[[:digit:]]' | sed "s/^sd/xvd/g")
$ BDMURL="http://169.254.169.254/latest/meta-data/block-device-mapping/"
$ for bd in $(curl -s ${BDMURL}); do MAPDEVICE=$(curl -s ${BDMURL}/${bd}/ | sed "s/^sd/xvd/g"); if grep -wq ${MAPDEVICE} <<< "${OSDEVICE}"; then echo "${bd} is ${MAPDEVICE}"; fi; done | grep ephemeral
ephemeral0 is xvdb
ephemeral1 is xvdc
ephemeral2 is xvdd
ephemeral3 is xvde