VMware Cloud Community
tdubb123
Expert
Expert

command to check if vmdk is in use

I got a folder with a bunch of vmdk files in there. Is thee a command to see if the vmdk files are in use or belong to another vm?

Reply
0 Kudos
4 Replies
admin
Immortal
Immortal

Run the command vmkfstools -D  <vmdk name> to see if there is Host holding a lock on the vmdk, if there is then the vmdk might be in use by a VM. The below KB details on how to find the same.

VMware KB: Investigating virtual machine file locks on ESXi/ESX

Thanks,

Avinash

Reply
0 Kudos
a_p_
Leadership
Leadership

I think RVTools will also be helpful in finding out which vmdk belongs to which VM.

André

Reply
0 Kudos
tdubb123
Expert
Expert

i tried the vmkfstools method on a vm on both the flat vmk and vmdk file and got 2 differen results

/vmfs/volumes/4d7e59d8-461ac5dc-1281-0024e85c1299/wintest # vmkfstools -Dv10 wintest-flat.vmdk

Lock [type 10c00001 offset 68831232 v 17, hb offset 3170304

gen 529, mode 1, owner 525643f9-e4498242-3af7-0025b5110a4c mtime 26965

num 0 gblnum 0 gblgen 0 gblbrk 0]

Addr <4, 147, 1>, gen 2, links 1, type reg, flags 0, uid 0, gid 0, mode 600

len 42949672960, nb 8049 tbz 0, cow 0, newSinceEpoch 8049, zla 3, bs 2097152

OBJLIB-LIB : ObjLib cleanup done.

/vmfs/volumes/4d7e59d8-461ac5dc-1281-0024e85c1299/wintest # vmkfstools -Dv10 wintest.vmdk

Lock [type 10c00001 offset 68833280 v 55, hb offset 3170304

gen 529, mode 0, owner 00000000-00000000-0000-000000000000 mtime 38350

num 0 gblnum 0 gblgen 0 gblbrk 0]

Addr <4, 147, 2>, gen 3, links 1, type reg, flags 0, uid 0, gid 0, mode 600

len 543, nb 1 tbz 0, cow 0, newSinceEpoch 1, zla 2, bs 65536

OBJLIB-LIB : ObjLib cleanup done.

/vmfs/volumes/4d7e59d8-461ac5dc-1281-0024e85c1299/wintest #

the command on the flat file shows the mac address of the vm. but the command on the vmdk config file does not. why is that?

Reply
0 Kudos
admin
Immortal
Immortal

Hello,

The vmdk is just a pointer and hence returning with owner 00000000-00000000-0000-000000000000, it

check who is the owner of this MAC address 0025b5110a4c, SSH into host and run the command vim-cmd vmsvc/getallvms - check if the VM is running or you can even grep the hostd.log for the flat.vmdk



Thanks,

Avinash

Reply
0 Kudos