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

Filipe Brandenburger filbranden at gmail.com
Thu Mar 12 00:36:48 UTC 2009


Hi,

On Wed, Mar 11, 2009 at 17:29, Filipe Brandenburger
<filbranden at gmail.com> wrote:
> If I "du" a small file (couple of bytes) in CentOS 5, it tells me the
> file is using 8kb, while I was expecting 4kb which is the block size
> I'm using.

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...

ACLs would probably have the same effect (I did not test it though).

I wonder if there is a way to override this, for instance by mounting
a filesystem and disabling extended attributes, specifying the SELinux
context for all the files in the mount options or something. I know
that is possible for NFS, but not for local filesystems... I'll dig
in, I'll let you know if I find anything.

Thanks!
Filipe


More information about the CentOS mailing list