Well, actually I know how the directory (on my ext4 partiton) got to be this way but I was interested in the technical details behind it. I was running many network simulations, each one generating a packet trace file. I was going to parse these offline but the simulations ended up making 163GB of small trace files before I ran out of disk space! [I have since changed my scripts to pipe the traces to the analyzer, eliminating the problem.] After deleting the traces, which took about 20 minutes, a `ls -la .` shows that the directory is 60MB large while containing just 300kB of files. I suspect that some remnants of the links to the trace files remain in the directory inode. Why weren't they removed? Will they get "garbage collected" in the future?
Thanks for your insights,
Jevin
1. e2fsck -D /your/partition
The -D option directs fsck to optimize the directories. Basically, it rebuilds the directory inode.
2. mkdir tmp && mv big_folder/* tmp/ && rmdir big_folder && mv tmp big_folder
This actually moves the files to a new, small directory, and deletes the old, big one before renaming back to the original name.
[1] This thread discusses the problem and some potential online solutions http://lkml.org/lkml/2009/5/14/362