Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Sep 1995 12:13:51 -0400
From:      "Garrett A. Wollman" <wollman@lcs.mit.edu>
To:        Terry Lambert <terry@lambert.org>
Cc:        lars.koeller@odie.physik2.uni-rostock.de (Lars Koeller), freebsd-questions@freefall.freebsd.org
Subject:   Re: Discrepance between df/du/tar!
Message-ID:  <9509151613.AA06621@halloran-eldar.lcs.mit.edu>
In-Reply-To: <199509151544.IAA01184@phaeton.artisoft.com>
References:  <199509150855.KAA01129@odie.physik2.uni-rostock.de> <199509151544.IAA01184@phaeton.artisoft.com>

next in thread | previous in thread | raw e-mail | index | archive | help
<<On Fri, 15 Sep 1995 08:44:47 -0700 (MST), Terry Lambert <terry@lambert.org> 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.

-GAWollman

--
Garrett A. Wollman   | Shashish is simple, it's discreet, it's brief. ... 
wollman@lcs.mit.edu  | 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: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9509151613.AA06621>