VMware Cloud Community
airfrog7
Enthusiast
Enthusiast

Unable to Delete VMDK File

I recently deleted a VM with a large (1.4TB) VMDK file attached. When I checked the datastore a few weeks later a there was still a "vmname-flat.vmdk" file left over. However when I tried to delete it via the vSphere client I got an error saying "cannot delete file [DATASTORE_NAME] vmname-flat.vmdk". I connected to an ESXi host in the cluster and tried to delete it from there. Running "rm vmname-flat.vmdk" resulted in the error:

"rm: can't remove 'vmname-flat.vmdk': Bad address"

At the same time the following event was logged in vmkernel.log:

"2015-08-27T11:09:02.904Z cpu7:18223819)Fil3: 8848: Truncating <FD c157 r32> failed: Invalid address"

I have tried from a few different ESXi hosts, all with the same result. running lsof shows that the file is not locked by any process.

How can I delete this file?

15 Replies
sakthivelramali
Enthusiast
Enthusiast

Hi

To resolve this issue, you must locate the virtual machine that has this .vmdk mounted and then unmount it. To do so Search for references to the .vmdk file in the settings files (.vmx files) of the other virtual machine's on the datastore. You can automate the search with a command like this

    find /vmfs/volumes/* -name *.vmx -exec grep -Hi <name-of-the-file.vmdk> {} \;

    where <name-of-the-file.vmdk> is the .vmdk you're trying to delete.

After you have located the virtual machine which has mounted the .vmdk, remove it. Select that virtual machine and go to Edit Settings > Hard Disk > Remove.

Thanks Sakthivel R
Reply
0 Kudos
akblpatel
Enthusiast
Enthusiast

Hi!

As far as i know there is no way to see what is locking up your files.

We had a simillar issue. Our solutions was to restart every host in our cluster once at a time. After the 7 host out of 9 we were able to delete the files... 

This can be done without down time...  Try it out.

Use vmware-cmd tool from service console

for example

vmware-cmd /vmfs/volumes/......../vmname/vmname.vmx getstate - current state of your virtual machine

vmware-cmd /vmfs/volumes/......../vmname/vmname.vmx stop(reset) - stop or reset vm

than try to remove files.

Reply
0 Kudos
brunofernandez1

do you have a backup solution like VDP or Veeam that mounts the vmdks to backup the systems?

if yes, check your proxy vms and look if they have the vmdk mounted...

------------------------------------------------------------------------------- If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards from Switzerland, B. Fernandez http://vpxa.info/
Reply
0 Kudos
a_p_
Leadership
Leadership

IMO the "Bad address" error could be caused by a file system (VMFS) issue. In this case I'd recommend you open a support call with VMware to reslove the issue, rather than risking further issue with other VMs on the same datastore.

Maybe one of the commands in http://kb.vmware.com/kb/2019003 will help determine what's wrong.

André

Reply
0 Kudos
continuum
Immortal
Immortal

Sometimes such undeletable vmdks can be renamed.
Sometimes deleting the renamed vmdk then magically is possible after a short while.

Make sure that the vmdk-name does not appear in /dev/deltadisks
I also grep the vmware.log of backup-appliances for the vmdk-name - sometimes those appliances still have vmdks mounted that should be no longer in use.


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

Reply
0 Kudos
airfrog7
Enthusiast
Enthusiast

Thanks for the replies, and sorry for the delay in updating this thread. I have finally had the chance to go through and reboot every ESXi host which has access to that datastore. However, I am still unable to delete the VMDK file. I have renamed the VMDK file and moved it to a different folder, but was still unable to delete it after this. The VMDK is about 1.5TB in size (which is why I am keen to get rid of it). It was only in place temporarily for testing and was never backed up.

Reply
0 Kudos
Parveen1988
Enthusiast
Enthusiast

Found a simple workaround, rename the .vmdk to some other extension, say .vmx.

Then delete the files. Worked in my case.

Reply
0 Kudos
continuum
Immortal
Immortal

If renaming helps that is indeed a good tip.
But unfortunately the "Bad address" error can be caused by very different cases. There is no single workaround that helps in all cases.
- delete from other host in the cluster
- try to release a lock
- rename it
- patch heartbeat section
- sometimes even resizeing it to a single MB can do the trick


________________________________________________
Do you need support with a VMFS recovery problem ? - send a message via skype "sanbarrow"
I do not support Workstation 16 at this time ...

beegandhi
Contributor
Contributor

@continuum This solutions works:

Thank you!!

Reply
0 Kudos
sushobhan
Contributor
Contributor

Did not work et al. I am having the issue with other VM file types.

Reply
0 Kudos
FOXAHR
Contributor
Contributor

Thanks, check the Veeam Proxy, and right i have the disk attachet yet, i removed the disk and i can delete the vmdk, thanks for the tip

Reply
0 Kudos