VMware Cloud Community
fusebox
Enthusiast
Enthusiast

Script To Kill Stale PIDs Accessing The VMDK Files Of A Deleted VM

I have been seeing lot of people facing issues deleting the vmdk files of a deleted vm from the datastore (either via VC Gui or CLI ) or vmdk locking issues when the vm itself has been deleted from the VC ,not able to delete the VM related files from the datastore or such similar issues. I am attaching the cleanup script for all those people who are new to esx or not comfortable with the CLI. But, want to fix such issue(s) in hassle free way which is void of entering any commands.

So, I have written a simple interactive script which will take the name of the deleted VM whose VMDK files you want to delete to free up the space in your datastore and then it will kill the stale pid which is accessing these files which was preventing you from deleting those files by giving you a very infamous error, "The device or resource is being accessed or busy".

Make sure you run this as root and give it executable permissions to run it (chmod u+x killstalepid.sh)

Hope you folks find it helpful.

Message was edited by: fusebox

Reply
0 Kudos
0 Replies