VMware Cloud Community
lamw
Community Manager
Community Manager

Script to find RDMs on ESX Hosts or VC

Is it possible to go through a set of hosts and find which ESX Host have a Virtual Machine that is using an RDM (Raw Disk Mapping), I would like to be able to keep track of the RDM's that have been allocated, especially at multiple sites/clusters. From the Virtual Machines that currently have RDM's, theres no real way of telling if it's using an RDM, as there is no unique flag or file that specifies it's an RDM. I remember reading about RDMs and how it has a proxy file, but I believe thats probably embedded on the VMFS which is not viewable on the Service Console, unless someone knows how I can query that information through a batch script. I have not dived into the VCDB to see if this information can be queried.

Thanks in advanced.

0 Kudos
11 Replies
dominic7
Virtuoso
Virtuoso

I'm zctuzlly writing a script to do this now. I'll have it done next week some time. The script will be written in perl and use the VIPerl API. If my pans don't pan out for this evening it might be done sooner 😜

0 Kudos
lamw
Community Manager
Community Manager

That's awesome, I was hoping I might be able to find this information using vimsh, but I have not dug too deep, I just wanted to be sure it was not possible by just examing certain files before I go down the route of finding an alternative method.

0 Kudos
sthoppay_wipro
Enthusiast
Enthusiast

vimsh -n -e '/vmsvc/device.getdevices 32'

shows the RDM LUNs used by that VM.

0 Kudos
lamw
Community Manager
Community Manager

Is the command specific to 3.0.x or 3.5? I know there's been some updates for vimsh on ESX 3.5 that do not exist in 3.0.2. I assume "32" is the vmid?

0 Kudos
sthoppay_wipro
Enthusiast
Enthusiast

My server is ESX 3.5

Yes, 32 is the VMID.

0 Kudos
petedr
Virtuoso
Virtuoso

xtravirt has a good document on vimsh for 3.5

http://www.xtravirt.com/index.php?option=com_remository&Itemid=75&func=fileinfo&id=21

www.thevirtualheadline.com www.liquidwarelabs.com
0 Kudos
BeelS
Contributor
Contributor

How is that Perl script coming along to find RDMs on VC and Hosts

0 Kudos
lamw
Community Manager
Community Manager

It hasn't actually, haven't had too much time looking into it. We don't use RDM extensively and we have dedicated LUNs, I know at other locations it may be nice to have but I just haven't found an easy way of finding out whether it's an RDM or normal disk. I would love to hear if anyone else has looked at this, but I get the impression it isn't sought after to know which VMs are using RDMS, most peolpe have an idea which VMs are using RDMs.

0 Kudos
admin
Immortal
Immortal

Dominic,

Did you ever get a chance to finish that perl script? I've got a student in class this week looking for something that will scan the ESX server looking for all of the RDMs.

Thanks,

Chris

0 Kudos
lamw
Community Manager
Community Manager

First off, thanks to for finding this method of locating RDM information other than using the VIC, I had not thought about checking out "device.getdevices". I've gone ahead and taken that idea and came up with a quick/dirty script that can run on both ESX 3.5+ and ESXi (requires SSH Console) and loops through all virtual machines and printing out the ones that contain an RDM (Raw Disk Mapping). This task was motivated by Duncan's earlier post about locating virtual machines that contain RDM, but that solution would require a Windows system and powershell. I know this was a task I had for another project and it would be nice to have few other options.

The output will contain:

Virtual Machine Name

VM's Hard Disk Label for the RDM

VM's Datastore + it's VMDK

LUN UUID

LUN #

Compatibility Mode (Phys/Virt)

Disk Mode

RDM Size (in GB)

You can find the script at:

http://www.engr.ucsb.edu/~duonglt/rdm/

For some reason the format output is slight off on ESXi, I assume its just the limited Busybox toolset compared to the full blown RHEL SC.

0 Kudos
CITITECHS
Contributor
Contributor

My coworker came up with the following as the posted one didnt work with 3.0.1

find /vmfs/volumes///-rd.vmdk | uniq | egrep -v /vmfs/volumes/[[:digit:]]

0 Kudos