Cannot mkdir: Too many links
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
Related videos on Youtube
huggie
Updated on September 18, 2022Comments
-
huggie over 1 year
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.
-
JdeBP almost 13 yearsYou'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.)
-