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) ?
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) ? | |||
|
feedback
|
|
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
| ||||
feedback
|
|
It's pretty much always a bad idea having a zillion files in a directory. But it happens to me all the time. Old filesystems got unusable because delete was O(n) in the number of files. I don't think any current Linux filesystems are bad that way. (Not positive about ReiserFS, but I'd be surprised if it was). But even with a good filesystem, the shell tools do too much work when removing files. They're stating files, explicitly testing permissions, creating large command lines, etc. One workaround is to do a very low level delete, just calling the unlink() system call. Here's some quick-and-dirty Python that has let me delete a million files when rm failed me:
| |||
feedback
|
|
XFS does deletes a lot faster. ext{2,3,4} are the worst, I don't know where reiserfs is between them. | |||
|
feedback
|
find mydir -deleteto remove it.findis heavily optimized - maybe it's faster thanrm -rf? – Johannes Schaub - litb Sep 15 '09 at 16:52rmtookuser 0m0.130s sys 0m11.913swhilefindtookuser 0m0.057s sys 0m0.597s. the hierarchy was around 7000 files and that many directories, consisting of depth 2 (files are in subdirs). – Johannes Schaub - litb Sep 15 '09 at 17:27