Identify Virtual Machine Locks & Find ESXi Hosts by its MAC Address
I recently had one issue which was one drive missing.it was not possible to identify which ESXi host holds the lock.
Connect to any ESXi host with access to the datastore where the virtual machine is located.
# cd /vmfs/volumes
# /vmfs/volumes/] cd datastore name
run the below command
ls | while read x; do vmfsfilelockinfo -p $x| grep -i "is locked"; done
==============================================================
[root@esxi1.com/vmfs/volumes/datastore name/Testvm] ls | while read x; do vmfsfilelockinfo -p $x| grep -i "is locked"; done
"Testvm-0c6be5b7.vswp" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm-flat.vmdk" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm.nvram" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm.vmx" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm.vmx.lck" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm.vmx~" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm_1-flat.vmdk" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm_2-flat.vmdk" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm_3-flat.vmdk" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"vmware.log" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
"Testvm-208397751-1.vswp" is locked in Exclusive mode by host having mac address ['00:25:b5:06:a1:0e']
=================================================================
PowerCLI Script to find an ESXi host by its MAC address
> connect-viserver
> enter the vCetner name and provide credentials.
> run the below command
"Get-VMHostNetworkAdapter |? {$_.Mac -eq "00:25:b5:06:a1:0e"} | select VMhost, Name, Mac"
-----------------------------------------------------------------------
PS C:\> Get-VMHostNetworkAdapter |? {$_.Mac -eq "00:25:b5:06:a1:0e"} | select VMhost, Name, Mac
VMHost Name Mac
------ ---- ---
esxi1.com vmnic0 00:25:b5:06:a1:0e
esxi1.com vmk0 00:25:b5:06:a1:0e
----------------------------------------------------------------------
No comments: