Operating System - HP-UX
1833494 Members
2729 Online
110052 Solutions
New Discussion

Numver of files in one directory?

 
SOLVED
Go to solution
Mike_305
Super Advisor

Numver of files in one directory?

Hi,

This question was raised by oracle dba.

I have search for this information on the web and no luck.

Does HP have any limitation on how many files can be under one directory?

Is there any way this can affect the performance of the file system?

Thanks in advance.

Mike
If there is problem then don't think as problem, think as opportunity.
6 REPLIES 6
Michael Tully
Honored Contributor

Re: Numver of files in one directory?

Hi,

As far as I know the only limit that you could
come across is the inode limit on the filesystem itself. To find the number of inodes used in any directory is ll -i | wc -l or you could run the 'bdf -i' command for the filesystem in question.

-Michael
Anyone for a Mutiny ?
A. Clay Stephenson
Acclaimed Contributor

Re: Numver of files in one directory?

Hi:

There is essentially no limit but there is a practical limit. First, be aware that directory searches are linear searches and thus become inefficient when the directories are large. Secondly, file name expansion in the shell, e.g. ls X* can exceed ARG_MAX and you have to start breaking that into ls X[0-4]*. Third, the directories become difficult for humans to deal with. Fourth, I have seen quite a few applications crash because the dumb programmer made the silly assumption that nobody would be stupid enough to put more than N (you fill in the blank) files in one directory. I suggest, that you use the directory structure as it was designed - a tree.

Regards, Clay
If it ain't broke, I can fix that.
Roger Baptiste
Honored Contributor

Re: Numver of files in one directory?


In Unix, even a directory
is a File i.e it''s inode
structure is the same as
that of a file. It''s size
can grow to as much as blocks
it can address (direct and indirect and indirect to indirect), which will generally be beyond a normal Filesystem size. The directory holds the two-dimensional addressing of
files mapping the filenames
to their inode numbers.
So, realistically speaking
there is no limit to number of
files in a directory.

It surely has a effect on
the performance in accessing
the files. A more important
factor is the security part.
Since all files are in one
directory. If the directory
gets corrupted, the files
are as good as gone.
Moral: avoid it, unless there
is no choice.

For more details, look
at man inode.

-Raj
Take it easy.
Roger Baptiste
Honored Contributor

Re: Numver of files in one directory?

<there is no limit to number of files in a directory>>

I meant, "theoretically"
there is NO limit. But
practically, it will hit
the FS limit and that's the
end of the road .

-raj
Take it easy.
G. Vrijhoeven
Honored Contributor
Solution

Re: Numver of files in one directory?

Hi,

It depents on several things
1 Number of inodes in filesystem, inode cache for performance
2 max lenght in bytes of input line (_POSIX_LINE_MAX in /usr/include/limits.h)
this one may couse commands to fail

remind the longer the path, the slower.

hope this will help
Paula J Frazer-Campbell
Honored Contributor

Re: Numver of files in one directory?

Hi

I and other sys admins tend to use 1024 as a limit on files in dirs.


HTH

Paula
If you can spell SysAdmin then you is one - anon