Identifying virtual disks pointing to Raw Device Mappings (RDMs) on ESX
Purpose
This article provides advanced users with a method to list all of the virtual disks pointing to a physical disk (Raw Device Mapping, or RDM) from PowerCLI and from the ESX/ESXi host console.
This method does not explicitly state the virtual machine which is using the raw device mapping pointer file, though it can be inferred from the directory name. It will instead provide the LUN to RDM mapping. To obtain a list of registered virtual machines and the associated RDMs, see Identifying virtual machines with Raw Device Mappings (RDMs) using PowerCLI (2001823).
Note: This method is generally time-consuming, as all Datastores must be searched iteratively for VMDK files. If those VMDK files are locked, such as by a running virtual machine, inquiring for the target device fails. In this case, it is better to search for registered virtual machines.
Resolution
To list all virtual disks pointing to an RDM device using PowerCLI:
This operation is generally time-consuming, as PowerCLI must iteratively inquire about the disk type of every VMDK file on the remote hosts. Checking locked files adds a few seconds of delay. The device which the RDM points to cannot be determined without a virtual machine attached.
- Open the vSphere PowerCLI command-line. For more information, see the vSphere PowerCLI Documentation.
- Run the command:
Get-Datastore | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | Select "Filename","CapacityKB" | fl
Example output:
Filename : [DatastoreName] DirectoryName/virtualrdm.vmdk
CapacityKB : 5760
Note: The mapped device is not exposed, only the existence of the RDM. To determine the target device which it is mapped to, add this virtual disk to a virtual machine or use the console method.
To list all virtual disks pointing to an RDM device using the local console:
This operation is generally quick, as there is no overhead of network communication.
- Open a console to the ESX or ESXi host. For more information, see Unable to connect to an ESX host using Secure Shell (SSH) (1003807) or Using Tech Support Mode in ESXi 4.1 (1017910).
- Run the command:
#find /vmfs/volumes/ -type f -name '*.vmdk' -size -1024k -exec grep -l '^createType=.*RawDeviceMap' {} \; > /tmp/rdmsluns.txt
#for i in `cat /tmp/rdmsluns.txt`; do vmkfstools -q $i; done
Example output:
- Virtual Mode RDM:
Disk /vmfs/volumes/.../virtualrdm.vmdk is a Non-passthrough Raw Device Mapping
Maps to: vml.02000000006006048000019030091953303030313253594d4d4554
- Physical Mode RDM:
Disk /vmfs/volumes/.../physicalrdm.vmdk is a Passthrough Raw Device Mapping
Maps to: vml.02000000006006048000019030091953303030313253594d4d4554
Note: For more information on identifying the mapped device, see Identifying disks when working with VMware ESX/ESXi (1014953).
- Virtual Mode RDM:
Additional Information
Maps to: vml.02000000006006048000019030091953303030313253594d4d4554
Write down script
#!/bin/sh if [ -f /tmp/rdm_vmdk_maps.txt ] if [ -f /tmp/rdm_scsi_luns.txt ] #query system scsi device and mpath list for i in `grep vml /tmp/rdm_vmdk_maps.txt | awk '{print $3}'` echo "Download /tmp/rdm_scsi_luns.txt and /tmp/rdm_vmdk_maps.txt for maping RDM disk naming" |