Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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'm trying to untar several tar files. I encountered something like this

tar: NCBI_SRA_Metadata_Full_20110601/SRA037312: Cannot mkdir: Too many links

Is there a limit to the number of files that can exist in a directory? I checked du -i the IFree is still 51M. So it doesn't looks to me like inode is running out.

share|improve this question
You've asked the wrong question. You're making a subdirectory, as the error message tells you. You should therefore be asking about limits on subdirectories within a directory, not on files. (There are limits on files. But the EMLINK error here results from a different limit on subdirectories.) – JdeBP Jun 18 '11 at 13:03
up vote 6 down vote accepted

Yes, there is a limit to the number of files that can exist in a directory. That limit depends on what file system you're using though, and potentially on what options were used when you formatted the file system.

By default on ext3 (and I believe ext2 as well), the limit is 32,000 files.

EDIT: Further reading, as well as my own testing, suggest that the 32,000 file limit is no longer an issue in modern kernels with ext3. However, there is still a 32,000 sub-directory limit, so while JdeBP's comments are technically correct, that huggie asked, and I answered the wrong question... the gist of the answer is the same.

Consider this test:

$ mkdir asdf
$ for x in $(seq 1 32000); do mkdir $x; done
mkdir: cannot create directory `31999': Too many links
mkdir: cannot create directory `32000': Too many links
share|improve this answer
See this discussion from December 2001 for ext2. Note, by the way, that you've answered the wrong question. The limit you're talking about is a limit on subdirectories within a directory (resulting from the limit on the link count of the parent directory which is increased for each subdirectory) not on files within a directory. – JdeBP Jun 18 '11 at 13:01

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.