[Techtalk] Different usage betweed df and du

Conor Daly c.daly at met.ie
Wed Jul 13 22:11:59 EST 2005


On Wed, Jul 13, 2005 at 11:55:05AM +1000 or thereabouts, Sue Stones wrote:
> I received a message saying that /home is full.  (I deleted some stuff 
> so that I can get some work done.)
> 
> When I run "df" it tells me that I have used 9.4 of my 11GB on /home 
> (before I deleted stuff it said I had used 11G)
> 
> When I run "du" it tells me that /home has used 1.1GB.
> 
> What it the likely cause of this difference?  How do I go about sorting 
> it out?

One thing that can give rise to a situation like this (though I suspect it
wouldn't account for 10Gb) is a file that has been deleted while in use.
For example, say you download a 4.7Gb DVD image (eg rhel_3_dvd.iso).  Now
you loopmount that to have a look inside

mount -o loop rhel_3_dvd.iso /mnt/iso

The iso file is now in use.  You've finished looking inside and decide you
don't need it so you:

rm rhel_3_dvd.iso

and it disappears from your directory listing.  du won't see it and won't
attempt to count it but, because it's still mounted, it doesn't get removed
from the filesystem so df doesn't see it as free space.  If you 

umount /mnt/iso

the space magically reappears!  This sort of thing can happen with stuff
like logrotate where an old copy of a logfile gets deleted but the program
that's writing to that log still has it open.  In this case, the new logfile
gets ignored and the program continues to write to the old, deleted logfile
which nothing else can access.  Which is why apache manages its own log
rotation rather than allowing logrotate to do so.  Of course, logrotate
knows about this and will signal a process with something like 

kill -HUP $PID 

which should prompt the process to reopen various files it's dealing with...

I don't imagine this would cause Sue's space loss though (unless you deleted
various logfiles??).

Conor
-- 
Conor Daly,                   Please avoid sending me 
Met Eireann, Glasnevin Hill,  Word or PowerPoint attachments.
Dublin 9, Ireland             http://www.fsf.org/philosophy/no-word-attachments.html
Ph +3531 8064276 Fax +3531 8064247

**********************************************************************
This e-mail and any files transmitted with it are confidential 
and intended solely for the addressee. If you have received
this email in error please notify the sender.
This e-mail message has also been scanned for the
presence of computer viruses.
**********************************************************************



More information about the Techtalk mailing list