Linux – fast Linux directory tree removal


rm -rf mydir

is painfully slow for a directory tree with 100000 files (in sub-directories) on a reiserfs file system.

Any ideas for faster removal of directory trees (even risking rare corruption) ?

Best Answer

The only solution I can think of is to have all your files on a separate files system. The file system can live on disk partition or in a file.

Instead of deleting the files you could wipe out the partition or delete the file.

I can sympathize with you because I have project with > 200 000 files on NTFS and deleting the tree is really a pain. If I could, I would

  • use another file system (reiserfs, in your case, is pretty good with lots of files anyway IIRC)
  • avoid having so many files (e.g. use a database)
Related Question