I'm trying to clean up a directory that contains a lot of data (more that 1 TB), with many of the files hard linked to save space. For some context, this is the drive where we keep our builds, and we have a lot media (several GBs) of media in each build, so we hard link a file if it is identical to a previous build product. I've noticed that trying to delete these directories is extraordinarily slow (~5 items per second).

My guess is that the delete is taking so long because of the large number of hard links to each file. Is there anything I can do to speed up this process, or am I stuck deleting several million items at 5/sec?

  • you want to delete more than one directory (i.e., removing all references to the file) or just one directory (and won't gain that much space, since hard links will still exist) ? – woliveirajr Dec 5 '13 at 18:14
  • I'm trying to delete most or all of the directories with the duped files. – Eric Andres Dec 5 '13 at 18:16
  • You want to ensure that you leave one of each file, though? – vgoff Dec 6 '13 at 12:44
  • Are you deleting or moving to the recycle bin? (Assuming Windows because ntfs.) – Bob Dec 6 '13 at 12:44

find . -inum [inode-number] -exec rm -i {} \;

This command will find the inode number which you can then remove, which will free the data referenced.

I have given the interactive flag so that you can test it.

Oh, to get the inode number, you can do ls -il which will return the name and the inode number together.

If you could remove the file by inode directly that would be an improvement, but I don't know a way to do so.

  • Sorry, NTFS, and thus Windows. – Eric Andres Dec 6 '13 at 15:11
  • That isn't "windows" only, so no assumption. I added a tag for Windows though. Thanks. – vgoff Dec 6 '13 at 16:45
  • Do you have to install cygwin to do something like this on windows, or is there a standalone find tool on windows? – Eric Andres Dec 6 '13 at 19:23

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.