VMware Cloud Community
WMPatrik
Contributor
Contributor

Check if VMDK is in use

Hi all

Can i check if vmdk files is in use by some host?

We found files that's not belong to vm:s

Regards Patrik

0 Kudos
5 Replies
TheButcher
Enthusiast
Enthusiast

Hi Patrick,

You can use the command:

find /vmfs/volumes -iname "*-flat.vmdk" -mtime +7 -ls

This command will show all vmdk's that are not used for the last 7 days. You can change the 7 for every other number you want.

Mart

0 Kudos
Texiwill
Leadership
Leadership

Hello,

There are a couple of things here.

Last time used, the find command will work, as will checking boot times for VMs.

Orphaned VMDK files? That is a different question. You would need to find all the VMDK files and match them up to all the VMX files on the system.

Orphaned VMs? That is also a different question. You would need to find all the VMX files and compare that list to the one output by vmware-cmd -l.

On a single system this is easy, on a cluster this becomes difficult so use of some scripting tool like PowerShell is recommended.


Best regards,

Edward L. Haletky

VMware Communities User Moderator

====

Author of the book 'VMWare ESX Server in the Enterprise: Planning and Securing Virtualization Servers', Copyright 2008 Pearson Education.

CIO Virtualization Blog: http://www.cio.com/blog/index/topic/168354

As well as the Virtualization Wiki at http://www.astroarch.com/wiki/index.php/Virtualization

--
Edward L. Haletky
vExpert XIV: 2009-2023,
VMTN Community Moderator
vSphere Upgrade Saga: https://www.astroarch.com/blogs
GitHub Repo: https://github.com/Texiwill
0 Kudos
WMPatrik
Contributor
Contributor

Hi

This command works perfect to me!

best regards

/Patrick

0 Kudos
Neth66
Enthusiast
Enthusiast

I know this is answered, but I had the same issue this weekend, and VMware support had me do this

vmkfstools -D diskname.vmdk

tail /var/log/vmkernel

Nov 22 15:48:06 hostname vmkernel: 11:02:15:40.479 cpu2:1037)FS3: 130:

Nov 22 15:48:06 hostname vmkernel: 11:02:15:40.479 cpu2:1037)Lock [type 10c00001 offset 55169024 v 55, hb offset 3846656

Nov 22 15:48:06 hostname vmkernel: gen 3484, mode 0, owner 00000000-00000000-0000-000000000000 mtime 1009775]

Nov 22 15:48:06 hostname vmkernel: 11:02:15:40.479 cpu2:1037)Addr

If the "owner" is all 0s as shown above, then the VMDK is not in use. (I think the VM in question needs to be powered on)

0 Kudos
Neth66
Enthusiast
Enthusiast

I checked my last post with a different VM, and the information I was given appears to be incorrect. The "owner" info is all 0s on the VM I tested and I know the VMDK is in use by the powered on VM.

0 Kudos