3

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?

  • You can try to see if there are any locks on the files in directory with lsof. – Danila Ladner Jul 28 '13 at 18:47
  • Just did that. There aren't any. – Zulakis Jul 28 '13 at 18:56
  • what esxi? 5.0? Can you afford rebooting the box? Also which folder did you try to delete with this command? A single VM's folder or the complete datastore folder? Please provide the full command you ran? – Danila Ladner Jul 28 '13 at 19:24
  • It's a single VM folder. All other vm-files have been deleted. ESXI version is 5.1 – Zulakis Jul 28 '13 at 20:00
  • 1
    Why are you messing around at the command line anyway, ESXi isn't a general purpose *nix-based OS, don't treat it like one as it'll let you down if you do. Use it as it's meant to be used. – Chopper3 Jul 28 '13 at 20:57
2

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.

  • rm IPCop-cf065eb0.vswp results in rm: can't remove 'IPCop-cf065eb0.vswp': No such file or directory. Rebooting didn't help either. – Zulakis Jul 28 '13 at 21:01
  • You could also try using unlink on it if that's available in esxi 5.1 (I forget). Otherwise, there isn't an easy way to get rid of the file. – Falcon Momot Jul 28 '13 at 21:02
  • Nope, unlink isn't available. As it exists within 2 folders it kind of bothers me, but having to migrate, format and remigrate is a little much of work I guess. – Zulakis Jul 28 '13 at 21:05
  • Then don't. Junk files on a vmfs partition have almost no effect. I really wouldn't bother (see my last paragraph), but you could if you really felt it was necessary. – Falcon Momot Jul 28 '13 at 21:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.