In a recent thread, someone asked how to know how much of a directory is used; that is, information similar to "df" but for a specific directory.
Of course it's a silly question in some respects. Did he mean the percentage of file space used by this directory relative to that available on the file system? Or the number of files that exist as a percentage of the maximum number that could be created? We don't usually concern ourselves with either of those things, so there are no tools that output anything like that.
But there are limits to directories, of course. For one thing, a directory is a file like any other file, and therefore is limited in size by whatever restraints the file system puts upon it. It probably has some minimum space for the name part of its entry, and a fixed space for the inode part, so you couldn't possibly have more entries than could fit in the maximum file size. Also, there are inode limits imposed by the filesystem: if the directory could theoretically hold some impossibly large number of files, it might be impossible for that many files to exist on the file system. Not the directory's fault, of course, but still a limit.
Every file system is going to impose some limit on the maximum number of files in a directory, and may impose a different limit on files with special needs like directories (because of the links that need to be kept track of). Nowadays those limits may be very large, but they do exist.
And then we have other limits. Some file systems use a hash for file names, and are going to run into unavoidable collisions at some point that may be much smaller than any other design criteria. The Reiser FAQ currently says that it allows almost 4GB of files in a directory, but:
in practice this value is limited by hash function. r5 hash allows about 1 200 000 file names without collisions
That's more than enough entries for me, thanks.
Got something to add? Send me email.
More Articles by Anthony Lawrence © 2009-12-15 Anthony Lawrence
There are only two things wrong with C++: The initial concept and the implementation. (Bertrand Meyer)
Tue Nov 22 05:31:29 2005: 1372 anonymous
4GB of files? Do you mean a number or a size in GB?
Tue Nov 22 10:45:03 2005: 1373 TonyLawrence
Number of files.
Thu Sep 6 19:23:35 2007: 3116 anonymous
"That's more than enough entries for me, thanks."
Now. Today. Ten years from now? Nope. Not nearly enough. In fact, I got to this thread looking to see if its OK to copy about a quarter million data files into an ext2 directory, because it will be convenient for later processing. Having to devise and use a subdirectory scheme would be a royal pain.
It will only get "worse," or rather, easier to generate and use huge numbers of digital assets.
Sat Dec 22 14:35:52 2007: 3346 anonymous
Clearly you pick and choose which questions to answer.. here you chose one, labelled it "silly," pointed out the inadequacies of its phrasing, and then made a point of smirking your way through an incomplete answer If your real goal is to insult your audience maybe you should consider stand-up comedy, or better yet: therapy.
Sat Dec 22 17:28:01 2007: 3347 TonyLawrence
Oh, come on: lighten up. I'm not "smirking my way" through anything - I said "in one sense it's a silly question" but then went on to answer it as best I can.
As to "picking and choosing", you are dead wrong. I make no pretense of omniscience and have always cheerfully admitted when I have no freaking idea or the question is way over my head.
By the way, how is it "clear" to you anyway? According to my logs, this is the ONLY post you have read here - at least this month. I suppose I could check back farther..
Tue Dec 15 12:22:57 2009: 7759 siyaram
how many can stored max.data in a folder when space avilable ?
Tue Dec 15 12:41:57 2009: 7760 TonyLawrenc
I'm sorry - I do not understand what you are asking. Can you rephrase your question?
------------------------
Printer Friendly Version
Maximum size of a directory Copyright © November 2005 Tony Lawrence
Have you tried Searching this site?
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more.
Contact us
Printer Friendly Version