Thursday, March 20, 2014

Associating RDMs to the corresponding VMs

In order to decommission an older SAN, I had to migrate all the LUNs off. The process to migrate LUNs associated with datastores is easy - create new datastores on the new SAN, attach to the same ESXi hosts and then svMotion all the VMDKs over.

The other scenario involved LUNs that were mapped as RDMs to the VMs. While the process to move the RDMs over were just as straight forward (shutdown VM, detach an remove RDM LUN from all hosts, migrate RDMs onto new SAN, reconnect RDM into the same VM in the same SCSI bus location), I found it difficult to identify which VM the RDM was connected to given the device identifier. Fortunately, the following PowerCLI line of code will find the VM that a specific RDM is connected to given the device ID:

Get-Cluster "<cluster-name>" | Get-VM | Get-HardDisk -DiskType "RawPhysical","RawVirtual" | where { $_.ScsiCanonicalName -eq "<device id>"} | Select Parent,Name,DiskType,ScsiCanonicalName,DeviceName | fl

No comments:

Post a Comment