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

Re: df and du results on / strange



wsa wrote:
> / is ext2, all others are ext3.
> I get a almost 100% use of /
> But with du i'm geting nowhere near 1.9GB total which is the size
> of my / , in total i get to 568419 used on / if i take du's output as truth.
> The real thruth is there's about 130MB free space on / , cause trying to 
> copy more that that to / results in 'no space left on device'.
> What am i missing here?

The 'minfree' value.

When the filesystem is created 5%-10% of the total disk space will be
reserved by the filesystem as 'minfree'.  This is available only to
root processes and not to non-root processes.  The amount of minfree
is dependent upon the defaults of the particular mkfs.  You probably
have 5% unless you changed it.  Also some disk space will be used by
Inodes in some filesystems.  On others it is dynamic.

Secondly the 'df' command is just returning data from the statfs(2)
call.

              struct statfs {
                 long    f_type;     /* type of filesystem (see below) */
                 long    f_bsize;    /* optimal transfer block size */
                 long    f_blocks;   /* total data blocks in file system */
                 long    f_bfree;    /* free blocks in fs */
                 long    f_bavail;   /* free blocks avail to non-superuser */
                 long    f_files;    /* total file nodes in file system */
                 long    f_ffree;    /* free file nodes in fs */
                 fsid_t  f_fsid;     /* file system id */
                 long    f_namelen;  /* maximum length of filenames */
                 long    f_spare[6]; /* spare for later */
              };

So disk is usually total - minfree - inodes - free but the command
does not compute it.  The df command is just reporting what the
filesystem has precomputed for those values.

Also remember that when approaching a completely full disk the
performance of the filesystem can degrade exponentially.  It is then
difficult for the filesystem to find free disk blocks and won't be
able to automatically produce defragmented physical layout.  A small
percentage of minfree is required to ensure reasonable performance.  I
believe this plus ensuring root having a little extra when users
filled the disk were the original reasons for minfree.  It used to be
10% but has been reduced to 5% in recent years because of the much
larger disk capacity.

> du -s /* | sort -nr | less :

Also remember that du reports disk blocks used.  A disk block will be
different sizes on different filesystems.  This is not the same as the
disk space used.  A three byte file takes up three bytes of used space
but fits in one (likely 512 byte frag) disk block.  Again, this is
usually tuned by different filesystems and is one of the reasons
different filesystems have different performance.

Yes, it can be confusing.

Bob

Attachment: pgpip4ULC1sf5.pgp
Description: PGP signature


Reply to: