While doing a “mini-healthcheck” at a customer site I noticed a specific Datastore with less than 2% of free diskspace. After a bit of research an orphaned VMDK was found. Orphaned vmdk’s are virtual hard-disks that are not connected to a VM. Probably because they were removed from the inventory without deleting the files.
You can easily find these orphaned vmdk’s via the Service Console:
find -iname “*-flat.vmdk” -mtime +7
For those that don’t like using the Service Console you can also check this with Powershell Ad van Bokhoven created a nice script which he describes as follows:
This script asks the virtual center what the disk are of each VM and puts this into an array. After this, it reads all files on all datastores. If the file is a vmdk file, it will check wheter this file is in the array. If it’s not, you’ve found a orphaned vmd.
I would advise to regularly check your environment on orphaned disks, it can save precious diskspace.
Arnim says
If you have multiple clusters you can use plink.exe to execute this script on each cluster and redirect output to a file. You can also schedule this task if you like.
mpoore says
I was going to work out how to do this today. It’s like you read my mind. Thank you.
Duncan Epping says
You can use plink indeed… or just the powershell script.
Garry says
find -iname “*-flat.vmdk” -mtime +7
This could find some valid vmdk from VMs that haven’t been power on in a week,doesn’t it?
Duncan says
that’s correct, you will need to verify the list. but it’s a good indication.
Garry says
Yes, anyway, that command is a VERY good indication
ToddH says
What should I see for an output? When I run the command on all our ESX Hosts I am dropped back to #.
Duncan says
No result means no orphaned vmdk’s!
ToddH says
Great — then call me “lucky”.
bsr says
Hai,
I want find the vmdk files alignment status from one of my cluster environment. The cluster having 110 VMs. So how can i find the all VMDK file alignment status from virtual center console .
If any share this its great help …..
Thanks & Regards,
BSR Krishna
bsr says
How to check the un aligned vmdk status from virtual center console
bsr says
How to check the un aligned multiple vmdk status from a data store .
bsr says
How to check the un aligned multiple vmdk status from a data store and Virtual center console
Rgds,
BSR
raj says
what about template vmdk?
John White says
One consideration is that this will also find vmdk’s on VM’s with a 1+ week old snapshot present.
Not that that’s a bad thing since finding and removing old snapshots is great, just be warned that the output of this command won’t give you a confirmed list of junk vmdk’s. Check before you delete!
M. Langhard (@Langhard) says
This is still relevant, so thank you for that post!
Just be careful with the quotation marks. You may need to replace these “ with these ” to make this command work on your machine.