How do I identify which volumes attached to my Amazon EC2 Linux instance are instance store (ephemeral) volumes?
I have an Amazon Elastic Compute Cloud (Amazon EC2) Linux instance with both Amazon Elastic Block Store (Amazon EBS) volumes and instance store (ephemeral) volumes attached to it. How do I identify which of my attached volumes are instance store volumes?
"I have an Amazon Elastic Compute Cloud (Amazon EC2) Linux instance with both Amazon Elastic Block Store (Amazon EBS) volumes and instance store (ephemeral) volumes attached to it. How do I identify which of my attached volumes are instance store volumes?Short descriptionTo 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 are supported and review the volume's information from the operating system (OS).Resolution1.    Verify what type of instance store volume (HDD, SSD, or NVMe SSD), if any, that your instance supports. See Instance store volumes to view the quantity, size, type, and performance optimizations of instance store volumes that are available for each supported instance type.2.    Determine which volumes attached to your instance are instance store volumes. The identification method that is used depends on whether you have NVMe SSD or HDD/SSD instance store volumes.NVMe SSD instance store volumes1.    Connect to your instance.2.    Install the NVMe command line package, nvme-cli, using the package management tools for your Linux distribution. For Amazon Linux instances, install the nvme-cli package using the yum install command. For download and installation instructions for other distributions, see the GitHub documentation for nvme-cli or see the documentation specific to your distribution.3.    Run the nvme list command as a privileged user.$ sudo nvme listThe Model column in the following output example lists whether 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 listNode             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   0HDD or SSD instance store volumesFor HDD or SSD instance store volumes, get the list of attached block devices from the OS, and then retrieve the block device mapping section that is contained in the instance metadata.1.    Connect to your instance.2.    Run the lsblk command. If the lsblk command isn't present, then install the util-linux package using 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 specific to your distribution.$ sudo lsblkThe following output example shows the list of block devices that are retrieved from an instance that has many drives and that is running on an instance type that supports SSD instance store volumes.$ sudo lsblkNAME    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTxvda    202:0    0     8G  0 disk└─xvda1 202:1    0     8G  0 part /xvdb    202:16   0 745.2G  0 diskxvdc    202:32   0 745.2G  0 diskxvdd    202:48   0 745.2G  0 diskxvde    202:64   0 745.2G  0 disk3.    To identify if xvdb, from the previous example output, is an ephemeral drive, retrieve the block-device-mapping metadata using 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/ephemeral0sdb$ ls -l /dev/sdblrwxrwxrwx 1 root root 4 Aug 27 13:07 /dev/sdb -> xvdbIn the previous example, the block device mapping for ephemeral0 is to sdb, which is a symbolic link to xvdb. So in this example, the xvdb is an ephemeral device.Or, you can automate the check to display the ephemeral devices attached to your instance by using the following set of commands.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 ephemeralThe following is an example of the three commands described previously, along with example 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 ephemeralephemeral0 is xvdbephemeral1 is xvdcephemeral2 is xvddephemeral3 is xvdeFollow"