UFS2 limits

H.fazaeli fazaeli at sepehrs.com
Sun Nov 9 00:49:08 PST 2008


   The number of files and sub-directories is limited by the number
   of available inodes which is fixed at the time you create the
   file system (by -i argument to newfs(8)). Anyway, stick with
   Jeremy's advise if you do not like trouble.
   Jeremy Chadwick wrote:

On Sun, Nov 09, 2008 at 01:40:51AM +0000, [1]no-spam at people.net.au wrote:


Hi,
I have a FreeBSD server that has about 10,500 subdirectories within a single
directory.
This number will keep rising and I assume UFS2 has a limit to the number of
sub-directories in a single directory - can anyone tell me what it is?


As far as I know, there is no such limit on the number of files/dirs
inside of a directory.

I don't want to change the topic of discussion, but I *highly* recommend
you ***stop*** whatever it is you're doing that is creating such a
directory structure.  Software which has to iterate through that
directory using opendir() and readdir() will get slower and slower as
time goes on.

If this is something you've written or have control over or can work
with engineers in regards to, I recommend you change your directory
naming scheme to have separate subdirectories with the first 2 or 3
letters of the directory you wish to create.  E.g.:

/some/place/00/00ilikezeros/*
/some/place/01/01binaryheaven/*
/some/place/aa/aardvarks/*
/some/place/ab/abuse/*
/some/place/ac/actuary/*
...
/some/place/xy/xylophones/*

You get the point.

Traversing this structure is much more efficient, and requires very
little code change on your part.  Those who run nameservers that host
many zones, for example, use this structure to ensure the daemon doesn't
take 32498231 years to start up.



What about ZFS?

At some point I'll have to re-arrange things so that I have a deeper directory
structure, just wondering when I'll hit the limit so I can plan in advance :-)


What baffles me is why you're looking at this problem from a " "how can
the filesystem solve this engineering mistake I made for me" standpoint,
rather than "how can I solve this engineering mistake I made so that it
doesn't impact the filesystem".  Very strange.  Sometimes looking at
things in a different light makes all the difference.

Hope this helps.

P.S. -- I hope this mail makes it to you, because your From line is
[2]no-spam at people.net.au (I'll be surprised if your account name really is
that!).



--


Best regards.

Hooman Fazaeli [3]<hf at sepehrs.com>
Sepehr S. T. Co. Ltd.

Web: [4]http://www.sepehrs.com
Tel: (9821)88975701-2
Fax: (9821)88983352

References

   1. mailto:no-spam at people.net.au
   2. mailto:no-spam at people.net.au
   3. mailto:hf at sepehrs.com
   4. http://www.sepehrs.com/


More information about the freebsd-questions mailing list