attaching persistent disk with a device name to an instance

336 views
Skip to first unread message

Alex

unread,
Jul 30, 2018, 4:31:05 PM7/30/18
to gce-discussion
I have a persistent disk named `foo` that I would like to attach to an instance I create. I run the following command

    gcloud beta compute --project=myproject instances create myinstance --machine-type=n1-standard-4 --disk=device-name=foo,name=foo

However, when I look at the instances and run `sudo lsblk` the disk appears under name `sdb` instead of `foo`. What am I doing wrong?

Navi Aujla (Google Cloud Support)

unread,
Jul 31, 2018, 1:21:42 PM7/31/18
to gce-discussion
Hello Alex, 

"--device-name" parameter flag is helpful in referencing GCE disk names to Linux device name. '/dev/sda', '/dev/sdb' and so on are the logical device names

The name of the disk reference using the parameter: "--device-name" can be verified using the following command: 

ls -l /dev/disk/by-id

For example:

Created the instance using the following command:

gcloud beta compute --project=xxxxxx instances create vm1 -disk=name=disk-2,device-name=disk-2

Login to the instance and verify:

ls -l /dev/disk/by-id
total 0
lrwxrwxrwx 1 root root  9 Jul 31 16:09 google-disk-2 -> ../../sdb

This way users can reference their disks using the /dev/disk/by-id/aliases. You can refer to this Medium.com thread providing more insight. 

I hope it clarifies. 

Alex

unread,
Aug 1, 2018, 4:45:43 PM8/1/18
to gce-discussion
Thanks, this makes perfect sense and works exactly as you describe!
Reply all
Reply to author
Forward
0 new messages