amazon-ebs – How to Know Which Partition/Volume is Which EBS Volume?

amazon ec2amazon-ebsamazon-web-services

On an EC2 instance, I have a few partitions that look like these:

/dev/nvme1n1     15G   48M   15G   1% /data/mongo2
/dev/nvme2n1     15G  4.7G   11G  32% /data/docker
/dev/nvme3n1     15G  3.4G   12G  23% /data/mongo

And then the corresponding EBS volumes, one of which looks like this:

enter image description here

I'm trying to figure out which mounts map to which EBS volumes. It used to be the case that the "Attachment information" matched or was similar to the device, but it no longer seems to be the case with nve.

Is there any way to match these besides keeping track myself of the mounts? thanks

Best Answer

There are a few different methods depending on what OS you're using.

With Amazon Linux AMI 2017.09.01 or later (including Amazon Linux 2), you can run the ebsnvme-id command as follows to map the NVMe device name to a volume ID and device name

sudo /sbin/ebsnvme-id /dev/nvme1n1

Which will provide output like this:

Volume ID: vol-01324f611e2463981
/dev/sdf

For Linux kernels 4.2 and later you can do the following:

First, install nvme-cli. It is the NVMe command line package. Next you can run a command similar to this:

sudo nvme id-ctrl -v /dev/nvme1n1

NVME Identify Controller:
vid : 0x1d0f
ssvid : 0x1d0f
sn : vol01234567890abcdef
mn : Amazon Elastic Block Store
...
0000: 2f 64 65 76 2f 73 64 6a 20 20 20 20 20 20 20 20 "/dev/sdf..."

The links below provide additional details.

References

NVME EBS Volumes
How to Find EBS Volume ID for NVME Volume