1

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?

1

The device special is set by Linux and will always be sd# something. But it can change depending on the sequence that persistent disks are attached to the instance.

Setting an ID will cause a persistent link to be added in /dev/disk/by-id using that name that always refers to the disk. For instance, if you name the disk foo then you will get a link /dev/disk/by-id/google-foo which always points to the correct sd# device special. You can then use that link (and/or the corresponding partition links, after the disk is partitioned) to refer to the disk.

  • ha, won't let me upvote because my rep is < 15 – Alex Jul 30 '18 at 21:53
  • That's ok, you'll get it soon! – Michael Hampton Jul 30 '18 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.