Vmware esxi – Can’t delete directory, not even with rm -rf

rmvmware-esxi

I am trying to delete a directory but it's not working.

When using rm -rf IPCop I get the error message rm: can't remove 'IPCop': Directory not empty.

Another thing I noticed was, when executing ls in this directory I get this output: ls: ./IPCop-cf065eb0.vswp: No such file or directory. So there seems to be a faulty file entry in it.

How can I delete the directory?

Best Answer

I suspect that ./IPCop-cf065eb0.vswp is a broken symlink. You should be able to remove that using rm, and then rmdir the directory.

However, it's possible that filesystem corruption is also the cause. This is very annoying in esxi, because there is no fsck for VMFS (the usual solution to this problem if it's not a broken symlink is to reboot in single-user mode and run fsck; this can't be done in esxi for VM partitions). You could try rebooting the hypervisor, but I am not sure that will fix it; if it doesn't, you'd have to migrate all the VMs off the backing store with the folder in it, and reformat it.

I'd personally suggest that it's not worthwhile to go through all that just to keep things "tidy", though if you suspect a bad disk or frequent power issues might be the cause you should investigate them.