[TriLUG] Random Linux Question

Alan Porter porter at trilug.org
Mon Oct 27 09:15:51 EDT 2008


> Hi, I just have sort of a random little question.  Why is it that some
> directories in the ext2 filesystem are not 4096 bytes in size?  Is there any
> specific reason?  I'm looking at it on CentOS 5, but I'm pretty sure it
> applies to any distro.


A directory is a file that has a table of names and inodes.  An empty
directory can be zero bytes long.  A directory with one or more entries
may fit in a 4096-byte table.  A directory that has a lot of files may
require a larger table.

A directory that once had a lot of files, but now only contains a few,
will still be the larger size.  Directories typically do not shrink the
size of their tables.

You'll notice that the lost+found directory on an ext2/ext3 filesystem
is somewhat larger... sometimes 16k in size.  When the filesystem is
made, a large directory table is created for that directory.  That
way, when fsck is run, it can find orphaned files and add them to the
lost+found directory without having to expand the table.

Alan



.



More information about the TriLUG mailing list