3

How can I list the actual block-device name(s) of ephemeral storage available in my EC2 instance?

After some trials and errors, it appears that such devices are connected as /dev/xvdn (and /dev/xvdm if there are two) -- is there some way to reliably list them from inside the instance?

fdisk -l lists all devices -- without anything obviously distinctive about /dev/xvdn. Same goes for output of lsblk. (We aren't using Amazon's own AMI-instances, so there is no -p flag for lsblk...)

Request for http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0 returns sdj, but there is no /dev/sdj, so that seems useless... Is there anything better?

The minor device-number seems to be 208 -- can one rely on that?

Mikhail T.
  • 2,338
  • 1
  • 24
  • 55

2 Answers2

1

I don't have the setup to check if this this specific to Amazon Linux AMIs, but on my setup here, /dev/sdX is symlinked to the corresponding /dev/xvdX device.

curl http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0 --> sdb

[ec2-user@ip-172-31-61-112 ~]$ ls -lrt /dev/sd*
lrwxrwxrwx 1 root root 4 Jun 24 01:06 /dev/sdb -> xvdb
lrwxrwxrwx 1 root root 4 Jun 24 01:07 /dev/sda -> xvda
lrwxrwxrwx 1 root root 5 Jun 24 01:07 /dev/sda1 -> xvda1
lrwxrwxrwx 1 root root 4 Jun 24 02:09 /dev/sdf -> xvdf
[ec2-user@ip-172-31-61-112 ~]$ 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   30G  0 disk [SWAP]
Jamie W
  • 396
  • 3
  • 4
0

Request for http://169.254.169.254/latest/meta-data/block-device-mapping/ephemeral0 returns sdj, but there is no /dev/sdj, so that seems useless... Is there anything better?

The above is your best bet. The reason you don't see an sdj device is due to a discrepancy between how AWS refers to the devices they attach to your instance and how your OS names those devices. Amazon is saying that it's sdj, which in your case, is actually /dev/xvdj.

EEAA
  • 109,363
  • 18
  • 175
  • 245