Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!bloom-beacon!gatech!rayssd!galaxia!dave From: dave@galaxia.UUCP (David H. Brierley) Newsgroups: comp.sys.att Subject: Re: Missing: 5 MB on a Unix PC. Message-ID: <397@galaxia.UUCP> Date: Tue, 10-Nov-87 23:42:17 EST Article-I.D.: galaxia.397 Posted: Tue Nov 10 23:42:17 1987 Date-Received: Fri, 13-Nov-87 23:54:58 EST References: <381@sdcjove.CAM.UNISYS.COM> <182@toylnd.UUCP> Reply-To: dave@galaxia.RAY.COM (David H. Brierley) Distribution: comp.sys.att Organization: Dave's Very Own Personal System Lines: 44 In article <182@toylnd.UUCP> dca@toylnd.UUCP (David C. Albrecht) writes: >> My question is: "Why is there roughly a 5 MB difference between AT&T's >> number (15.5 MB) and my number (10.9 MB)?" > >In a word 'Swap tracks'. In a word: 'bull crap'. If the problem were 'swap tracks' then the question would be "how come I say there is 20 meg but df only says 15 meg?". I did some research into this while I was writing a replacement for the df command and discovered the real reason for the difference. The df and du commands both report the number of blocks being used and everyone knows that "a block is a block is a block (is 512 bytes)", right? Wrong! The "blocks" that are reported by the du command are "calculated" by taking the size of the file in bytes and dividing by 512. However, the blocks that are reported by df are "calculated" by extracting the "total blocks used" field from the super block and multiplying by 2!! If you read the manual page for "fs" you will find a field called "s_type" which is defined as either "Fs1b" or "Fs2b". On all the machines that I have access to this field is set to Fs2b. This value indicates that the file system uses 1024 byte blocks! What all of this means is that if you allocate a 500 byte file the du command will report that you have used 1 block but in reality you have used 1 "1024 byte block" which df will report as 2 blocks. As a result, any file that du reports as having an odd number of blocks is wrong. If you have 1000 files that fall into this category then the numbers reported by du and df will differ by 1000. If you dont believe me, try the following simple test: 1. run df and note how many blocks are reported as available 2. create a file containing 1 byte by typing "echo '' > junkfile" 3. run df again and compare the numbers. 4. type "du junkfile" and see how many blocks are reported. I had to read the manual four times and run a test program a dozen times before I fully believed that this was really the case. I had gotten used to this type of weirdness on BSD systems but I had never seen it on a SysV machine before. -- Dave Brierley Home: rayssd!galaxia!dave -or- dave%galaxia@rayssd.ray.com Work: dhb@rayssd.ray.com -or- {cbosgd,gatech,ukma,ihnp4}!rayssd!dhb