2

Is there a way to map the disks allocated to a VM in GCP to the disks shown at the OS-level in Windows? In Linux, there are pointers that correspond to the naming we provision in GCP. In Azure, we can use the LUN IDs provided in the Azure portal to map to the corresponding IDs in Windows. However, in GCP, if I allocate two disks of the same size, I cannot tell which is which. This makes it difficult if I have to expand one later for example. Right now, I increment the size by 1GB to tell the difference, but this is less than ideal.

When on linux, a symbolic user-friendly link is created like /dev/disk/by-id/google-. However, in Windows, I do not see an equivalent.

The scenario would be like this:

In the GCP console, I provision a windows box, with 3 additional disks, each 100GB. Let's say one is for "software," one is for "data," one is for "temp" and they have been named that way in the GCP console. When the VM is provisioned, I can see all 3 disks, but cannot tell which one corresponds to the ones I have named in the GCP console since they look identical to the Windows OS. So I would need to guess and call one of them "software" at the OS level. If I run out of space on what I called "software" at the OS level, then go to the GCP console and expand the "software" disk, I may find that I expanded "temp" instead from the Windows point of view.

Brian S
  • 31
  • 2

2 Answers2

0

I don't think this is possible. In GCP you can add a custom name to the disk (like in the picture I added) and also you can use Labels for your resources but both of those options are in GCP side, either you can use them or Call them by using the console or in CLI.

enter image description here

Once you login to the Windows VM the disk will be attached but will appear in blank, you need to use the Disk Management tool to provide it with a name.

enter image description here

I would suggest you to add one disk at a time (if you are going to add disks of the same size), then login to the VM, open the Disk management tool and name it as you want.

grimmjow_sms
  • 340
  • 3
  • 14
0

You can do this by using the instance metadata information

Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/instance/disks/"

This will return a list of all the disk numbers connected to the instance

0/
1/
2/

If you know how many disks you have, it's simple since you can just iterate it and process each. You can use the device name property used in the attachment to identify each number to each disk

Invoke-RestMethod -Headers @{"Metadata-Flavor" = "Google"} -Uri "http://metadata.google.internal/computeMetadata/v1/instance/disks/{id}/device-name"

Once you know the id, you can use it in the Get-Disk {id} command

I haven't done this, so I'm not 100% sure if the id in the path is the same as the id in Windows - but there is also a index property available in the URL above (sibling to device-name) which may serve for it if the previous doesn't always work...