how to delete a vmdk from Vmware esx 4.1 when you are unable to do it.

Today, I walked into an issue about deleting a vmdk file from the datastore of Vmware ESX4.1.

“Cannot delete file [DATASTORE] myfile.vmdk”

I got to times this issue due i tried to convert a mechanical machine into a virtual one.
To solve this issue i found out that you have to kill the process of the converted file.  You have to use the following commands. This command you need to use SSH enabled otherwise you have to reboot your ESX server to release the processes. An SSH program you can use Putty or equal.

lsof | grep <startfilename>
< you get a result with the file name in it and it has also the PID of the locked file>

Use the follow command to view the processes.

ps -ef

Now you can see that locks the file. with the follow command you can release the file again.

Kill <PID>

After this you can. go to the store of the file.

cd .\vmfs\volume\<store id / name >

Once you have done this you can restart you conversion.. but i noticed the server which i converted. had many defragmentation needed and also some chkdsk warnings. So as a TIP look first for this issues before migrating to a virtual machine

2 thoughts on “how to delete a vmdk from Vmware esx 4.1 when you are unable to do it.”

  1. Just as an FYI, i had same errors after upgrading from ESX4i to 4.1i. During the upgrade the templates were ‘lost’ from the Vcenter. I tried deleting the no longer needed ones directly form the storage and received this error. In my case all I had to do was to add the template back to the inventory and then Remove from Disk. Files were then deleted.

  2. This was beautiful. Exactly what I needed to get out of a sticky situation. I was getting set to learn a lot more about ESXi than I wanted to based on a lot of other postings I saw. I was so happy when it worked! Thanks so much for posting

Leave a Reply to Gabor KissCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.