Max total files in a directory in FreeBSD 6 ufs?
Is there an upper limit to the total number of files stored in a single subdirectory in FreeBSD 6?
The filesystem is ufs
This was discussed on the freebsd-questions list in November 2008. To quote from Erik Trulsson:
Each i-node on the disk contains a field telling how many hard-links point to that inode. This field is a (signed) 16-bit value, meaning the maximum number of hardlinks allowed is 32767. Each subdirectory created contains a hardlink ('..') to its parent, thus limiting the number of subdirectories to a single directory to less than 32767.
Note that this does not limit the number of files you can have in a single directory, since normal files do not contain hardlinks to the parent directory, but there are of course limits to the total number of files and directories you can have on a single filesystem based on how many inodes were created when the filesystem was first created.
(Full message, start of thread)
These are theoretical limits; as discussed above, you will start to run into performance problems well before you hit any limits.
I did some things with freebsd 6.x that involved large numbers of files (50,000+) and don't remember any specific limitations. A quick check on a 7.2 system shows the limit to be well over 100,000. The process is still running as of now, when it fails I'll let you know what the hard limit is for 7.2, which is likely similar to 6.x.
That said, you see a huge performance hit over about 30,000 directory entries when creating new files / directories. At that point people start creating files named HashOfName/name instead of just name so you make lookups easier.
I would expect that number to vary based on the type of filesystem involved as well.