Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 1995 12:13:51 -0400
From:      "Garrett A. Wollman" <>
To:        Terry Lambert <>
Cc: (Lars Koeller),
Subject:   Re: Discrepance between df/du/tar!
Message-ID:  <>
In-Reply-To: <>
References:  <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
<<On Fri, 15 Sep 1995 08:44:47 -0700 (MST), Terry Lambert <> said:

> Most likely you have several sparse file on your box, including your
> password databases and mail aliases.

db(3) does not create sparse files, and in any case this does not
account for the discrepancy he is seeing.  Here is the CORRECT answer:

`du' figures out disk usage by walking the directory tree and
examining every file listed.  However, it is possible for a file to
exist, but not be listed in any directory (because it was unlinked
after it was opened and is still open).  This explains the difference
between what `du' was able to determine by examining the directory
structure and what `df' found out by asking the kernel how much space
is free.

`tar' pads the end of each file in the archive with null characters to
make it a multiple of the block size you specified, or 10k if you
didn't specify one.  So, if we assume that the residual (i.e., size
mod blocksize) is uniformly distributed, then you can expect a `tar'
archive of N files to contain N * blocksize / 2 bytes of padding.  (In
reality, the distribution is not uniform, so this estimate is not
accurate, but it gives you an idea.)  And, of course, `tar' has to
output directory information about the files it writes.  This explains
the discrepancy between `du' and what `tar' wrote.


Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ...  | Shashish is the bonding of hearts in spite of distance.
Opinions not those of| It is a bond more powerful than absence.  We like people
MIT, LCS, ANA, or NSA| who like Shashish.  - Claude McKenzie + Florent Vollant

Want to link to this message? Use this URL: <>