Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a directory (my_dir) which has 20 sub directories. Every time I run 'ls' or try to autocomplete a file name in this directory my IO usage goes to 100% and it takes very long time (10 mins) to list 20 sub directories.

Here is some background for it. Some time ago, I created millions of small files in this directory (By mistake). Then I deleted those small files (all of them). But now I am seeing this problem.

How can I fix it ?

share|improve this question
Results fox fsck /dev/hda..? (Replace the device with your hard drive.) – Bart De Vos Feb 23 '12 at 12:07

Move everything in the directory in to another directory. Remove the original directory. Recreate the original directory. Move everything back.

You are using a filesystem that can't shrink directories.

There's always e2fsck -D which will optimize all directories on the filesystem.

share|improve this answer
+1 - Learn something new every day.. – Kyle Smith Feb 23 '12 at 12:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.