How do I identify which volumes attached to my Amazon EC2 Linux instance are instance store (ephemeral) volumes?

4 minute read
0

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

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

  1. Connect to your instance.

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

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

  1. Connect to your instance.

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

  4. (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
AWS OFFICIAL
AWS OFFICIALUpdated 7 months ago
2 Comments

What about Windows instances?

replied 2 months ago

Thank you for your comment. We'll review and update the Knowledge Center article as needed.

profile pictureAWS
MODERATOR
replied 2 months ago