john@CAM.UNISYS.COM (John Dempsey) (10/27/87)
I think I'm missing 5 MB of memory and would like to know why. When I type: "du /" I get "17366 /" as the result. According to the du manual page, the value returned by the du command is the number of blocks used. Then when I type: "df" I get "4046 blocks" (i.e., the number of blocks free). Well, 17366 + 4046 = 21,412 blocks 21,412 blocks * 512 bytes/block = 10,962,944 bytes If I have a 20 MB drive (which I do), what happened to my other 9 MB? I'm assuming that 1 block == 512 bytes (see below). Does anyone know how much memory a 20 MB drive holds formatted and unformatted? In AT&T's UA/Administration under System Information menu, it says: "Disk Space Free: 13% or 2023k" 2023k is half of 4046 blocks (cf., "df" output and the calculation that (4046 blocks * 512 bytes/block = 2072k)). But is the 13%, as is being reported, really correct? 13% would be correct if there was 15 MB of memory available. That is: 13% = 2023k/x x = 2023k/.13 = 15,561,530 bytes (AT&T's number) 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 checking to see if 1 block == 512 bytes, one of my directories contains: 94,247 bytes (from running the "ls -la" command) 191 . (from the "du" command) thus, 191 blocks * 512 bytes/block = 97,792 bytes which confirms that 1 block does equal 512 bytes. ------ Can someone with a 20 MB drive on a Unix PC type "du /" and "df", and tell me what the reported numbers are on their system. Thanks a 5 MB! John Dempsey
lm@eta.UUCP (10/29/87)
In article <381@sdcjove.CAM.UNISYS.COM> john@CAM.UNISYS.COM (John Dempsey) writes: >I think I'm missing 5 MB of memory and would like to know why. When I type: I didn't read this closely but I'll bet you're forgetting about /dev/swap which lives on a different partition of your disk. Sorry 5 meg. -- Larry McVoy uucp: ...!{uiucuxc, rosevax, meccts, ihnp4!laidbak}!eta!lmcvoy arpa: eta!lmcvoy@uxc.cso.uiuc.edu or lm@arizona.edu
wtr@clyde.UUCP (10/29/87)
John, (Initial Disclaimer: I aint no guru, I just work here ;-) a couple questions: 1) do you have multiple file systems mounted on your machine? (assuming #1 true): 2) is it possile that your 'df' only measured the free space on that specific file system? (assuming UA/Admin did the same) your 'du /' would have given you the usage for the entire directory structure (all filesystems). there could be an inconsistancy here. this difference could create the image of a missing 5 MB. I run uport V/at w/ a 40 meg HD at home. Installation created 2 filesystems on the disk: the root ('/') which is ~10MB, and the second file system is mounted as '/usr' off of the root directory. this ratio ( 10MB/30MB ) sounds familiar ( 5MB/15MB on your machine ) so you may wish to check this. ===================================================================== Bill Rankin Bell Labs, Whippany NJ (201) 386-4154 (cornet 232) email address: ...![ ihnp4 ulysses cbosgd allegra ]!moss!wtr ...![ ihnp4 cbosgd akgua watmath ]!clyde!wtr =====================================================================
dca@toylnd.UUCP (David C. Albrecht) (11/01/87)
> 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'. For virtual memory and/or multi-tasking systems that allow swapping you have to put the process and/or page somewhere when it is not in memory. Your disk is partitioned into two sections the first of which is the swap area, the second of which is the storage area. You can use 'iv' if you want more information about your hard disk configuration. It's documented in Vol I of the Users guide. David Albrecht
scott@zorch.UU.NET (Scott Hazen Mueller) (11/01/87)
In article <8700198@eta.ETA.COM> lm@eta.UUCP (Larry McVoy) writes: #In article <381@sdcjove.CAM.UNISYS.COM> john@CAM.UNISYS.COM (John Dempsey) writes: #>I think I'm missing 5 MB of memory and would like to know why. When I type: #I didn't read this closely but I'll bet you're forgetting about /dev/swap which #lives on a different partition of your disk. #Sorry 5 meg. Close. Actually, I'd say that the swap space is 4M (remember, 4M max memory size?) and the 5th is his alternate sectors (for bad sector replacement.) Thus, on the 67M drive, you get 60M total space since you need 3M for bad sectors. #Larry McVoy uucp: ...!{uiucuxc, rosevax, meccts, ihnp4!laidbak}!eta!lmcvoy # arpa: eta!lmcvoy@uxc.cso.uiuc.edu or lm@arizona.edu -- Scott Hazen Mueller ( near_me ? lll-crg!csustan!helium : uunet )!zorch!scott (209) 527-1203 scott@zorch.UU.NET
dca@toylnd.UUCP (David C. Albrecht) (11/03/87)
In article <381@sdcjove.CAM.UNISYS.COM>, john@CAM.UNISYS.COM (John Dempsey) writes:
In re-scanning your question I noticed I didn't really answer it very well.
First off I'm not really sure why the accuracy of the free space computation
seems to be off I don't know from whence they are getting their answer.
Some part of your 20 megabytes is missing because it is stored in an
invisible partition which is used as swap area. This amount, however,
is never seen as part of the file system so would never show in a df or du.
Also you totally ignored in your computations the existence of inodes
(which are reported by df). Files in the system are not actually serial
on disk but rather blocks indirectly referenced by 'inodes'. I would have
to refer back to Unix literature to give you a precisely correct answer
but an inode contains some relatively small number of slots to directly
access the first 'x' blocks of a file. Above that number it indirectly
gets the next block of the file through another inode block. I believe one
slot is reserved for triple indirection. Every file in the system
therefore requires at least one inode and maybe more. Certainly these
structures take not inconsiderable space just a rough guess (from inode(4))
places them at about 64 bytes per.
As I'm using a 67M 3b1 I hopped over to my girlfriend's 20M machine to get
some numbers for you. Her machine has a df of 6184 and a du at '/' of 21280.
The system lists 21% or 3092K free.
David Albrthere
nic@marque.mu.edu (Nic Bernstein) (11/04/87)
In article <316@zorch.UU.NET> scott@zorch.UU.NET (Scott Hazen Mueller) writes: >In article <8700198@eta.ETA.COM> lm@eta.UUCP (Larry McVoy) writes: >#In article <381@sdcjove.CAM.UNISYS.COM> john@CAM.UNISYS.COM (John Dempsey) writes: >#>I think I'm missing 5 MB of memory and would like to know why. When I type: >#I didn't read this closely but I'll bet you're forgetting about /dev/swap which >#lives on a different partition of your disk. >#Sorry 5 meg. > >Close. Actually, I'd say that the swap space is 4M (remember, 4M max memory >size?) and the 5th is his alternate sectors (for bad sector replacement.) >Thus, on the 67M drive, you get 60M total space since you need 3M for bad >sectors. > >#Larry McVoy uucp: ...!{uiucuxc, rosevax, meccts, ihnp4!laidbak}!eta!lmcvoy ># arpa: eta!lmcvoy@uxc.cso.uiuc.edu or lm@arizona.edu > > >-- >Scott Hazen Mueller ( near_me ? lll-crg!csustan!helium : uunet )!zorch!scott >(209) 527-1203 scott@zorch.UU.NET Actually you are close, but not right. The pc7300/3B1 machines have a active memory limit of 4 megs. That is what you are refering to as the 4 meg max memory size. The swap space is in the first partition of the hard disk and can be almost any logical size. This is used as if it were active memory when the actual memory would overflow and the machine can page into the swap space as if it were real memory. It still only uses as many pages as it needs and if you are swapping tasks you can use all of 4 megs of memory and 4 megs of swap up. Try running several GNU-Emacs for this and then have everyone use "info" for the emacs info file. You'll use most of the active and swap up. The bad blocks are something else. The disk is formatted to have 17-512 byte sectors per track. The system uses physical blocks of 512 bytes but has logical blocks of 1024 bytes. This means the the disk is formatted for 17 blocks per sector but the system uses only 16 of the blocks. The 17th block then becomes the alternate for the bad block mapping. These are hidden to you and an "iv -vt" will only report the actual physical mapping. If you do an "iv -vt" on the disk, then the partitioning will become visible. You will probably find the 1st partition to contain 5000 blocks (the actual 1st partiton is the boot sectors, usually about 23 or 24 blocks). This is the swap area. This is caused when you first initalize the system from the "diagnostic" disk, which asks if the system will be used multi-user. If you answer yes to this question, then the default swap area will be 5 megs, if you answer no then the default swap area is 4 megs. Be careful though! If the swap area is too small then the system will kill processes (sometimes silently). We had tried to cut the swap down to 3 megs on one pc-7300 and then ran GNU-Emacs and it could never load the emacs info file, even though it loaded all the other info files properly. It turned out that the system killed the load, silently. Other things can also be a problem, 14 bit compress will run real slow on a 1meg active memory system, spending most of its time swapping things on and off the disk. Much depends on how much disk space you have to play with, but setting the swap size at 5 megs seems the best bet (hope he's not got one of those early 10 meg monsters). - Nic
dave@galaxia.UUCP (David H. Brierley) (11/11/87)
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
dhesi@bsu-cs.UUCP (Rahul Dhesi) (11/14/87)
In article <397@galaxia.UUCP> dave@galaxia.RAY.COM (David H. Brierley) writes: [about System V confusing between kilobytes and blocks] >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. However, 4.3BSD uses kilobytes as indeed every operating system should. A block is used internally by the operating system and the user should not have to know about it unless he so wishes. -- Rahul Dhesi UUCP: <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi