Re: Different reported sizes with df and du

[email protected] (Bob Proulx)
Newsgroups gmane.comp.gnu.fileutils.bugs
Message-ID <[email protected]>
Thomas Preissler <[email protected]>:
> Thank you very much, for your help.
> 
> But I already fixed the problem. A MySQL-logifile has been deleted,
> but MySQL was not restartet. After restarting it, all was ok.

Glad to hear your problem is resolved.

Yes this will cause df and du to report different sizes.  If you
search around you will find several other discussions of the reference
counting of filesystems.  I had not thought of that from your posting.
But now that you say this above it I am sure that was your problem.

The filesystem is reference counted.  Only when the last pointer to
the file is gone will the file actually be deleted and the file space
reclaimed for the system.  Until that time the filesystem may have
much space consumed by files that are not listed in any directory but
are still open by a program.  The deleting of logfiles which are still
open by a running daemon is a common source of this.

Something for the future is to truncate the file instead of deleting
it if you suspect that a program still has it open.  Truncating the
file will reclaim the disk space immediately.  I usually truncate by
using normal shell redirection of a do nothing command like 'true'.
(That is ':' to the long time unix user.)

  true > logfile

Bob
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.