From owner-freebsd-questions Fri Sep 15 09:15:11 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id JAA18125 for questions-outgoing; Fri, 15 Sep 1995 09:15:11 -0700 Received: from halloran-eldar.lcs.mit.edu (halloran-eldar.lcs.mit.edu [18.26.0.159]) by freefall.freebsd.org (8.6.12/8.6.6) with SMTP id JAA18107 for ; Fri, 15 Sep 1995 09:15:08 -0700 Received: by halloran-eldar.lcs.mit.edu; (5.65/1.1.8.2/19Aug95-0530PM) id AA06621; Fri, 15 Sep 1995 12:13:51 -0400 Date: Fri, 15 Sep 1995 12:13:51 -0400 From: "Garrett A. Wollman" Message-Id: <9509151613.AA06621@halloran-eldar.lcs.mit.edu> To: Terry Lambert Cc: lars.koeller@odie.physik2.uni-rostock.de (Lars Koeller), freebsd-questions@freefall.freebsd.org Subject: Re: Discrepance between df/du/tar! In-Reply-To: <199509151544.IAA01184@phaeton.artisoft.com> References: <199509150855.KAA01129@odie.physik2.uni-rostock.de> <199509151544.IAA01184@phaeton.artisoft.com> Sender: owner-questions@FreeBSD.org Precedence: bulk < 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