du and df discrepancy

Bill Vermillion bv at wjv.com
Tue Oct 16 09:30:08 PDT 2007


On Tue, Oct 16, 2007 at 11:49  Paul Kupfer saw "Error reading FAT table?
Try SKINNY table?" And promptly said:


> I am seeing a very odd problem on a FreeBSD 6.1-PRERELEASE #0
> mail server we have. We originally had a separate scsi device
> mounted as /var/mail (note this was underneath the mountpoint
> for /var). We reached a point where space on /var was running
> out, and running a df on that volume would show that there was
> only 160M out of 5.8G available (and 5.2G used).

> So I ran "du -hc /var" to see where I could remove some old
> files. du output shows the total of /var to be 311M, which is
> vastly different than what du tells me. I thought that this was
> perhaps a result of the way we had things mounted, and so I
> unmount the /var/mail device and remounted it as /mail, then put
> a symlink from /mail to /var/mail, still no dice, same results.

> I have not rebooted the machine yet (was hoping I wouldn't have
> to since it is a mail server). Is it possible that the inode
> tables are "out of whack" since changing these mountpoints,
> perhaps an fsck? Anyone ever seen anything like this before?

> Any help would be greatly appreciated.

I've seen it many times in my XX years of Unix work.

du - shows the amount of blocks used by the system
df - shows the amunt of space it thinks is being used.

The latter will compute the length of sparse files so df
will show less free space than du.  Sparse file will have 
blocks of no data in them.  These are typically created
by database programs.

And if you removed files that were open by some application, 
you won't be able to see those files but the application will
have them open and still be adding to the lenght of the file.

When removing files like these - shutdown the ap - remove the file
and restart the ap.  Depending upon the application - if it's
something being run out of syslog, you may have to 'touch' the
file, as syslog will not create a missing file unless you give
it the -C option - only available in releases after the 4.x series.

Bill

-- 
Bill Vermillion - bv @ wjv . com


More information about the freebsd-fs mailing list