Cannot Mkdir: Too Many Links

Cannot Mkdir: Too Many Links

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.

1

1 Answer

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
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

James H. Sterling
Author

James H. Sterling

James Sterling reports on renewable energy developments, climate policy, ecological conservation, and green tech innovations around the globe.