Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link between specified EBS volume name and actual device name in Linux system

I have EC2 instance with EBS volume attached, so that describe-instances command prints:

     "DeviceName": "/dev/sdf",
     "Ebs": {   "Status": "attached",
                "DeleteOnTermination": false,
                "VolumeId": "vol-04bfa2fab8e57a3dc",
                "AttachTime": "2016-09-26T09:39:08.000Z"   }

As per documentation:

Depending on the block device driver of the kernel, the device might be attached with a different name than what you specify

In my case actual name of this volume is /dev/xvdf.

Is it possible from within an instance to know which name was specified for a volume in Amazon console?

Or vice versa - to know which actual name will be used by linux for a volume outside an instance?

like image 713
XZen Avatar asked Oct 17 '16 19:10

XZen


People also ask

How do I name my EBS volume?

To edit this, klick on your EBS volume, go to "Tags" in the lower panel and you will already find a tag "Name" there. Fill in your desired name as the value and it will also show up in the overview panel. Show activity on this post. The "Name" that shows up in the AWS console is just a tag.

How do I connect an EBS volume to an instance?

To attach an EBS volume to an instance using the console Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/ . In the navigation pane, choose Elastic Block Store, Volumes. Select an available volume and choose Actions, Attach Volume. For Instance, start typing the name or ID of the instance.

What is EBS volume tied to?

You can attach an EBS volume to any EC2 instance in the same Availability Zone. After you attach a volume, it appears as a native block device similar to a hard drive or other physical device. At that point, the instance can interact with the volume just as it would with a local drive.

What is the volume name used to attach to AWS instance?

When you attach a volume to your instance, you include a device name for the volume. This device name is used by Amazon EC2. The block device driver for the instance assigns the actual volume name when mounting the volume, and the name assigned can be different from the name that Amazon EC2 uses.


1 Answers

This has been driving me nuts with Nitro-based instances, where the device names on the instance may not be ordered in the same sequence as shown in the AWS console. Luckily, per the AWS documentation, the serial number of the device on the instance is set to the EBS volume ID. So just run

lsblk -o +SERIAL

and it will give you the volume ID as shown in the console.

like image 144
gareth_bowles Avatar answered Sep 28 '22 08:09

gareth_bowles