[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: du confusion

On Thursday 23 February 2006 07:40am, Joe Orton wrote:
> On Tue, Feb 21, 2006 at 10:06:30AM +1100, Russell Coker wrote:
> > du currently displays the total count of blocks used for the file
> > including block(s) for XATTRs.  This means that every file is reported as
> > having a block used for the security.selinux XATTR (even though those
> > blocks are shared extensively on typical SE Linux systems).
> >
> > A more useful display on SE Linux systems is to have the --apparent-size
> > option of du enabled.  I suggest that we have a default install of Fedora
> > alias "du" to "du --apparent-size".
> That would be really evil,

No, it wouldn't.  Even your own argument here says that.

> du is *supposed* to report disk usage not 
> file sizes.

I think you have that backwards.  du shows the total of file sizes.

Also, how does --apparent-size create an *inaccurate* picture here?  I think 
you've got that backwards, too.

> It's always been true that disk usage and file size can 
> diverge, that's why du and ls are separate tools.

Actually, that's why du and df (disk free) are separate tools.

Just yesterday, I was trying to install an updated kernel on one machine that 
I have at home that does not have SELinux enabled, due to testing I was doing 
recently with other filesystems that didn't have xattr support (next testing 
turns it back on :) ).  It has a 512MB root LV and /usr, /var, /tmp & /home 
are all on their own LVs.  There wasn't enough space on /, according to rpm.

Running "du -sx /" on that home system showed that only about 220,000 KB was 
in use, but "df /" showed that approximately 502,000 KB was in use.  I was 
thinking, "What the heck is going on here?"  Then, it struck me, ext3.  The 
items remaining on the root partition are almost all small files, and 
thousands of them (plus some directories that are taking up data blocks).

It is very important to understand that difference.  It would be a good idea 
to add --apparent-size to du, out-of-the-box.

However, would that switch affect results on non SELinux systems?  Those with 
other types of xattrs?  If so, then we might want to look at having something 
flip that switch in and out based on getenforce state.  If "Disabled", no 
switch; otherwise, include the --apparent-size switch.  How about an alias 

alias du="du$(if [ `getenforce` != "Disabled" ]; then echo " --apparent-size"; 

That's just off the top of my head and not tested, so please, refine it if 
Lamont R. Peterson <lamont gurulabs com>
Senior Instructor
Guru Labs, L.C. [ http://www.GuruLabs.com/ ]
GPG Key fingerprint: F98C E31A 5C4C 834A BCAB  8CB3 F980 6C97 DC0D D409

Attachment: pgpZPgPVJX4tD.pgp
Description: PGP signature

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]