unix question: files per directory

Chris Torek chris at mimsy.UUCP
Tue Apr 11 14:49:27 AEST 1989


In article <24110 at beta.lanl.gov> dxxb at beta.lanl.gov (David W. Barts) writes:
>How many files can there be in a single UNIX directory ....
>I realize that as directories get bigger, they slow down, but
>how much?  Just what IS the maximum directory size?

The maximum size is the same as for files, namely 2^31 - 1 (2147483647)
bytes.  (This is due to the use of a signed 32 bit integer for off_t.
The limit is larger in some Unixes [Cray], but is usually smaller due
to disk space limits.)  Directory performance falls off somewhat at
single indirect blocks, moreso at double indirects, and still more at
triple indirects.  It takes about 96 kbytes to go to single indirects
in a 4BSD 8K/1K file system.

Each directory entry requires a minimum of 12 bytes (4BSD) or exactly
16 bytes (SysV); 16 is a nice `typical' size, so divide 96*1024 by 16 to
get 6144 entries before indirecting on a BSD 8K/1K file system.

The actual slowdown due to indirect blocks is not clear; you will have
to measure that yourself.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.questions mailing list