How to reliably map vSphere disks <-> Linux devices

Posted by brianmcgee on Server Fault See other posts from Server Fault or by brianmcgee
Published on 2013-04-17T08:57:15Z Indexed on 2014/06/02 15:32 UTC
Read the original article Hit count: 196

Filed under:
|
|

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.

Ideas

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  

Properties

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.

Questions

  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?

© Server Fault or respective owner

Related posts about linux

Related posts about storage