Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Nov 1997 17:30:10 -0800 (PST)
From:      Doug White <dwhite@gdi.uoregon.edu>
To:        Charles Owens <owensc@enc.edu>
Cc:        Craig Johnston <caj@praline.no.neosoft.com>, questions list FreeBSD <freebsd-questions@FreeBSD.ORG>
Subject:   Re: full file system: df and du disagree - why?
Message-ID:  <Pine.BSF.3.96.971114172326.4473F-100000@gdi.uoregon.edu>
In-Reply-To: <Pine.BSF.3.95q.971114170529.14249M-100000@itsdsv2.enc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 14 Nov 1997, Charles Owens wrote:

> > > A 'du -ks /var' showed that only 11 out of 60 megs were in use, so I
> > > _knew_ that there was plenty of free space.  But, df didn't think so, and
> > > the kernel apparantly didn't think so either, as writes to /var still
> > > produced a filesystem full error. 
> > 
> > Some process has a file that has been rm'ed open, likely.  The file is not
> > actually deleted until the last process that has it open closes it.  Du will
> > report the space as unused, df will report correctly.
> 
> Thanks!  Could you define "rm'd open" ?

Under UNIX, files have a `link count' associated with them.  WHen you
create a file on a filesystem, it gets one link to the FS. When a program
opens a file, the link count is incremented.  When a program closes a file
or you use the rm(1) command, the link count is reduced by one.  When the
link count reaches 0, the index node (inode) is cleared, the disk's block
free list is updated and the file is forgotten. 

The problem you may be seeing is that although you deleted a file, some
program still has the file open.  Even though the filesystem's link is
gone, the link count is still >0, so the inode continues to exist, and so
df(1) will count it (since it exists in the used block list) even though
du(1) can't see it since it can't see it's directory entry.

Check out the fs(5) and friends man page for a little more detail. 
Hopefully I haven't obfusciated this too badly. 

Doug White                              | University of Oregon  
Internet:  dwhite@resnet.uoregon.edu    | Residence Networking Assistant
http://gladstone.uoregon.edu/~dwhite    | Computer Science Major





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.96.971114172326.4473F-100000>