Slow directory removal (rm -rf) on Max OS X

1

Can anyone help me diagnose why removing a directory would be so slow on my Mac?

$ du -hs mydir/
606M    mydir/
$ find mydir/ -type f -print | wc -l
   12720
$ date
Tue Sep 10 10:59:27 PDT 2013
$ rm -Rf mydir
$ date
Tue Sep 10 11:01:44 PDT 2013

This is my local machine, which is a pretty beefy Mac Pro with OS X 10.8. The directory has a lot of files and is pretty big, but over two minutes to delete it? Would this be expected?

Is there anyway I can figure out what, if anything, is making this process slow?

Thanks in advance!

Sean Adkinson

Posted 2013-09-10T18:08:56.757

Reputation: 1 975

Besides storage type, speed may also depend on filesystem. What filesystem type is the area with the files? bfs or local? a journaling filesystem has more overhead for deletions. – Rich Homolka – 2014-07-03T22:05:48.640

A lot of files to delete and the bottleneck is the harddrive. – justbrowsing – 2013-09-10T19:23:32.390

If you need to create and delete a lot of small files often, I'd suggest either a SSD or if you have sufficient RAM, storing the files in a ramdisk. – justbrowsing – 2013-09-10T19:25:04.490

Answers

0

No matter what OS you are running, from Windows to OSX (Darwin / Unix) to Linux, and no matter the speed of your HDD or SSD, there is always the possibility for a bottleneck on file manipulations.

If the directory is very large, it is entirely possible to take over a full minute (or two!) to delete the directory.

If the directory (or any files, and possible sym-links) are stored on the network, this can cause a massive slowdown during basic file manipulation.

Furthermore, as you are aware, each device will take a different amount of time to delete files, etc. based on it's hardware and software specifications.

How big was this directory you were deleting? If you do not remember, keep a close watch for future file manipulation lags, as this can be a sign of a failing hard drive. The occasional lag is understandable, however. You may want to run a hard drive diagnostic to check for bad sectors on the drive, or on a Mac, verify (and repair) any permissions issues, via Disk Utility.

Joseph Orlando

Posted 2013-09-10T18:08:56.757

Reputation: 1