VMware Cloud Community
pfuhli
Enthusiast
Enthusiast

Unable to delete VMDK

Hello,

after removing a VM from VirtualCenter the VMDKs and delta VMDKs have been left on the datastore. Trying to remove them manually I end up with:


 
 [root@mrzs160240 Inoris]# ll
 
total 15810560
 
-rw-------    1 root     root     83886080 Oct 15 12:05 Inoris-000001-delta.vmdk
 
-rw-------    1 root     root     16106127360 Oct 15 12:07 Inoris-flat.vmdk
 
[root@mrzs160240 Inoris]# vmkfstools -U Inoris-flat.vmdk
 
Failed to delete virtual disk: Device or resource busy  1048585
 
[root@mrzs160240 Inoris]# rm -rf Inoris-flat.vmdk
 
rm: cannot remove `Inoris-flat.vmdk': Device or resource busy
 
[root@mrzs160240 Inoris]#
 
 

Does anybody have an idea how to remove the files?

Thanks in advance!

Regards,

daniel

0 Kudos
6 Replies
kucharski
Commander
Commander

Looking at the message that says Device or Resource busy tells me that another virtual machine has this vmdk associated with it. I mean if you go into the properties of another vm, is this hard drive listed in the properties. So go one by one into the properties of all the vm running and see if the hard drive is associated. Once you find the vm you will need to power down the vm and remove the hard drive from the list in the properties and then power on the vm and then you will be able to delete this vmdk file.

Michael

0 Kudos
mbrkic
Hot Shot
Hot Shot

Or you can (assuming that you have just the one ESX host - if you have more that see this disk you should check them all in the same way):

# cd /vmfs/volumes

# grep Inoris //*.vmx

to see if there are any VMs that reference this disk file. Once you hopefully identify the VM you should be able to find it and kill it, so you can delete the disks.

pfuhli
Enthusiast
Enthusiast

Hi guys,

thanks for the suggestions but it won't help me out. No more references in *.vmx or other files. No running machine using this vmdk. Nevertheless there seems to be a process holding a file handle to these two files.

Another idea?

0 Kudos
mweiss
Contributor
Contributor

did you ever find out how to delete these files that are not in use from the datastore?

have the same problem...

thanks,

Michelle

0 Kudos
pfuhli
Enthusiast
Enthusiast

Hi Michelle,

I opened an SR with VMware Support and that was the statement:

There are two basic commands to use:

+ ps -ef|grep+

Or

+ lsof |grep+

If either of these were to return a PID, then we could kill it. However, sometimes the process that is keeping the file open is vmkernel, which can't be killed and a reboot is the only option.

There was no VM holding locks on these files so I assumed that it was vmkernel which was locking the file.

After rebooting all of our ESX hosts I was able to remove the file.

HTH

daniel

0 Kudos
jccoca
Hot Shot
Hot Shot

Hi,

Try this:

service mgmt-vmware restart

0 Kudos