6

Possible Duplicates:
linux free disk space confusion
Why is there a discrepancy in disk usage reported by df and du?

df -h says that I have 494G used on /var:

Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             564G  494G   41G  93% /var

But du -sh /var says it's 350G

What makes them different?

Cheng
  • 6,641

2 Answers2

6

du looks at files, while df looks at the filesystem. If you have a small or empty file, du knows the real file size by really looking into it, while df will see that the file has some size, depending on the "block size" that was set when the partition was created. The block size determines the minimum size of files on the filesystem. While there maybe other causes, I think this is the most obvious difference between df and du.

See also How do I determine the block size of an ext3 partition on Linux?

phunehehe
  • 20,240
3

Most of the filesystems ufs, reiser, ext2, ext3, and ext4 (there may be others) have a reserve of a given percentage of disk to be use exclusively by the root userid. This is basically a safety valve allowing the root users or root processes to continue to use disk when things get close on disk while denying the supposedly less important non-root users.

On ext2, and ext3, I believe that the default reservation is 5%, much too high with the sizes of partitions these days. What I usually do is this to my ext filesystems:

 tune2fs -m 1 /dev/sda3

This is generally safe to change while the disk is mounted. However, you might have to remount the disk to make it effective immediately.

mdpc
  • 6,834