UFS2 limits

Erik Trulsson ertr1013 at student.uu.se
Sun Nov 9 01:35:25 PST 2008

On Sat, Nov 08, 2008 at 06:40:46PM -0800, Jeremy Chadwick wrote:
> On Sun, Nov 09, 2008 at 01:40:51AM +0000, 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.

Actually there is.  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.

<Insert your favourite quote here.>
Erik Trulsson
ertr1013 at student.uu.se

More information about the freebsd-questions mailing list