What's the maxium number of files a Unix folder can hold?
I think it will be the same as the number of files.
|
What's the maxium number of files a Unix folder can hold? I think it will be the same as the number of files. | |||||||||||||
feedback
|
This question came from our site for professional and enthusiast programmers.
|
Varies per file system, http://en.wikipedia.org/wiki/Comparison_of_file_systems | |||||||||
feedback
|
|
On all current Unix filesystems a directory can hold a practically unlimited number of files. Whereas "unlimited" is limited by diskspace and inodes - whatever runs out first. With older file system designs (ext2, UFS, HFS+) things tend to get slow if you have many files in a directory. Usually things start getting painful around 10,000 files. With newer filesystems (ReiserFS, XFS, ZFS, UFS2) you can have millions of files in a directory without seeing general performance bottlenecks. But having so many files in a directory is not well tested and there are lots of tools which fail that. For example, periodic system maintenance scripts may barf on it. I happily used a directory with several million files on UFS2 and had seen no problems until I wanted to delete the directory - that took several DAYS. | ||||
|
feedback
|
|
I assume you are thinking of storing a lot of files in one place, no? Most modern Unix files systems can put a lot of files in one directory, but operations like following paths, listing files, etc. involve a linear search through the list of files and get slow if the list grows too large. I seem to recall hearing that a couple of thousand is too many for most practical uses. The typically solution is to break the grouping up. That is,
and store your files in the appropriate sub-directory according to a hash of their Cristian Ciupitu writes in the comments that XFS, and possibly other very new file-systems, use | |||||||||
feedback
|
|
It depends how many inodes the filesystem was created with. Executing
will give you the number of free inodes. This is the practical limit of how many files a filesystem and hence a directory can hold. | |||||
feedback
|
|
| |||
|
feedback
|
|
From the comment you left, I think you don't really care about how many files/folders your FS can host. You should probably consider using ModRewrite and rewriting site.com/username to site.com/?user= or something of the kind and store all your data in a database. Creating one folder per user is generally not necessary (and not a good idea). That said, each filesystem has limits, and | |||
|
feedback
|