[CentOS] Disk usage for small files in ext3 in CentOS 5

Thu Mar 12 05:32:54 UTC 2009
Robert Nichols <rnicholsNOSPAM at comcast.net>

Filipe Brandenburger wrote:
> Found it! It's not related to CentOS 4 or 5 (I found a C4 machine in
> which small files took 8kb of diskspace and a C5 machine in which
> small files took 4kb). It's related to SELinux being enabled or not.
> Casually most of my C4 machines had SELinux disabled and most of my C5
> have it enabled. Now I dug out some machines with the opposite config
> and I checked it out.
> I believe if SELinux is enabled, it will use extended attributes to
> store the file's SELinux context (you can see it with "ls -Z", for
> some reason you cannot see it with "getfattr -d", I was expecting that
> to be possible). I guess when the file has extended attributes it will
> use an additional block to store them. That basically doubles the
> storage requirements if you have millions of tiny files...

It shouldn't be doing that.  Was this an old filesystem, originally
created without security attributes?  What does tune2fs show for the
inode size?  On my Fedora 10 laptop, where the filesystem was originally
set up with SELinux attributes, the inode size is 256 bytes and the
security attributes are stored in the inode itself.  On my systems
without SELinux, the inode size is 128 bytes, so the penalty is the
additional 128 bytes per inode, not 4K per file.

If you run debugfs on the partition and use its 'stat' command you
can see where the security attributes are stored.

AFAIK if you are running SELinux there is no way to keep it out of
any filesystem capable of supporting extended attributes.

Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.