Subject: Re: 'df' not reporting correct disk usage
To: Chris Foote <>
From: Brian C. Grayson <>
List: netbsd-users
Date: 07/17/1998 23:20:33
On Sat, Jul 18, 1998 at 09:23:03AM +0930, Chris Foote wrote:
> I've recently noticed that 'df' isn't reporting reclaimed disk space
> on my root partition:
> mrtg:~\:# df
> Filesystem  1K-blocks     Used    Avail Capacity  Mounted on
> /dev/wd0a       84327    72955     7155    91%    /
> /dev/wd0e     1782683   952398   741150    56%    /usr
> kernfs              1        1        0   100%    /kern
> mrtg:~\:# du -sx /
> 25650   /
> i.e. df reports an additional 47MB of disk space in use than there
> really is.

  Have you recently deleted a bunch of stuff on this partition?  In
particular, did you delete files (i.e. binaries) that were open
at the time, like a make install?  If so, the kernel doesn't
_actually_ delete them until they are finally
closed/not-being-used.  Thus, one could fill up one's root
partition by doing something like the following, I believe:

  ## Assume / has 10MB free, and
  ## netscape is a 10MB executable.
  cp /usr/local/bin/netscape /
  /netscape &
  rm /netscape

  At this point, du will say you still have 10MB free, but df
will say you are at 100%.  If you now try to use any disk space
on /, it'll fail, until you kill the running netscape,
at which point the disk _really_ no longer needs to hold the
backing store for /netscape, so the blocks are deallocated.

  Make sense?  I'd bet that if you rebooted, df and du would
agree.  If not, then maybe there _really is_ a bug, but I'm
skeptical....  :)

  Hope this helps!

"If you get 100 power engineers in a room, 101 of them will work this problem
 like this."  - R. P. Massey, ELEC 342