Task at hand

After a virtual disk has been added to a Linux VM on vSphere 5, we need to identify the disks in order to automate the LVM storage provision.

The virtual disks may reside on different datastores (e.g. sas or flash) and although they may be of the same size, their speed may vary. So I need a method to map the vSphere disks to Linux devices.


Through the vSphere API, I am able to get the device info:

Data Object Type: VirtualDiskFlatVer2BackingInfo
Parent Managed Object ID: vm-230
Property Path: config.hardware.device[2000].backing  


Name Type Value 
ChangeId string Unset 
contentId string "d58ec8c12486ea55c6f6d913642e1801" 
datastore ManagedObjectReference:Datastore datastore-216 (W5-CFAS012-Hybrid-CL20-004) 
deltaDiskFormat string "redoLogFormat" 
deltaGrainSize int Unset 
digestEnabled boolean false 
diskMode string "persistent" 
dynamicProperty DynamicProperty[] Unset 
dynamicType string Unset 
eagerlyScrub boolean Unset 
fileName string "[W5-CFAS012-Hybrid-CL20-004] l****9-000001.vmdk" 
parent VirtualDiskFlatVer2BackingInfo parent 
split boolean false 
thinProvisioned boolean false 
uuid string "6000C295-ab45-704e-9497-b25d2ba8dc00" 
writeThrough boolean false 

And on Linux I may read the uuid strings:

[root@lx***** ~]# lsscsi -t
[1:0:0:0]    cd/dvd  ata:                            /dev/sr0
[2:0:0:0]    disk    sas:0x5000c295ab45704e          /dev/sda
[3:0:0:0]    disk    sas:0x5000c2932dfa693f          /dev/sdb
[3:0:1:0]    disk    sas:0x5000c29dcd64314a          /dev/sdc

As you can see, the uuid string of disk /dev/sda looks somehow familiar to the string that is visible in the VMware API. Only the first hex digit is different (5 vs. 6) and it is only present to the third hyphen. So this looks promising...

Alternative idea

Select disks by controller. But is it reliable that the ascending SCSI Id also matches the next vSphere virtual disk? What happens if I add another DVD-ROM drive / USB Thumb drive? This will probably introduce new SCSI devices in between. Thats the cause why I think I will discard this idea.


  1. Does someone know an easier method to map vSphere disks and Linux devices?
  2. Can someone explain the differences in the uuid strings? (I think this has something to do with SAS adressing initiator and target... WWN like...)
  3. May I reliably map devices by using those uuid strings?
  4. How about SCSI virtual disks? There is no uuid visible then...
  5. This task seems to be so obvious. Why doesn't Vmware think about this and simply add a way to query the disk mapping via Vmware Tools?
  • 1
  • 1
    Thank you for the link. The KB article is mostly based on identifiying disks directly on the ESX hosts. My mission is to identify it from within the virtual machine. Apr 17, 2013 at 12:10
  • Um. You could simply expose / provide this information through a proxy service accessible by the guest OS. Dump it to text files on a web server, if you must.
    – the-wabbit
    Apr 17, 2013 at 12:40
  • I have only access to the vSphere system via the Vmware API. Also I do not know exactly where a VM is located. They may reside on different hosts and spread over different datastores. Apr 17, 2013 at 14:14
  • esxcli is using the VMWare API. You can target individual ESXi systems as well as your vCenter host with it - see pubs.vmware.com/vsphere-50/…. I am not quite sure what you are aiming at - is it that you do not want to use esxcli and want the property name to retrieve the disk's WWN using the API?
    – the-wabbit
    Apr 17, 2013 at 14:35

1 Answer 1


Use the SCSI ID to identify the virtual disk. You seem to be under the impression that the SCSI ID is dynamically assigned when the VM powers on. This is not the case. In the properties of the VM, you can set the ID for your virtual disk to whatever you want, and it will not change unless you want it to.

  • Background: The automation is for a large scale deployment (>100 VMs; some of them are new VMs, others may already exist and will get multiple VMDKs added by the Vmware API). I know that Vmware will usually stick with the drive order once the machine is setup. But how do I distinguish all the disks on the VM when there may be additional disks raw device mapped or manually added to the VM because there was a ticket to increase some filesystem before our deployment starts. With the Vmware API I could get a list of existing disks and could get meta data of all new LUNs that I would add to them. Apr 17, 2013 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .