Why Numbers from "du -s" and "df" Disagree


Contents

About this document
About du -s and df
The problem
Why the numbers do not add up
The ls command

About this document

This document describes why numbers returned by du -s and df are inconsistent. The document applies to AIX Versions 3.2 and 4.x.


About du -s and df

Notice that du and df report on only the blocks allocated for data actually written. The ls command reports slightly different results depending on the type of file. See the section in this document called, "The ls command".

At AIX versions prior to 4.1, df reports its statistics in 1024-byte units and du reports in 512-byte units. At AIX 4.1 and later, both df and du default to 512-byte units. The following discussion addresses df and du in AIX 4.x; thus all units are in 512-byte blocks.


The problem

Sometimes du and df are used to get a free block value: df is used to report the total block count, and then the value returned by du -s /filesystem_path is subtracted from that total to calculate the free block value. However, this method of calculation yields a value that is greater than the free block value reported by df.

For example, sample output from executing du -s /tmp is as follows:

   12920   /tmp
Sample output from executing df /tmp on the same system is as follows:
Filesystem    512-blocks      Free  %Used    Iused  %Iused  Mounted on
/dev/hd3           57344     42208    26%      391      4%  /tmp

Here, the <total from df> - <used from du> = <false free block count>: 57344 - 12920 = 44424.

the following:

    8 notsparse
    8 sparse.1

Each command correctly reports the data that is specific to its intended purpose. ls shows the range of offsets where data can be read from or written to a file. Reading from an offset where no data is written makes it appear to be zero-filled. du and df report only blocks allocated for data actually written.


Why Numbers from "du -s" and "df" Disagree: ITEM: FAX
Dated: 2001/01/30~00:00 Category: cmd
This HTML file was generated 2001/03/08~16:06:55
Comments or suggestions? Contact us