01 / JUST GIVE ME THE ANSWER

The quick answer

df reports allocated filesystem blocks; du totals reachable directory entries. Deleted files still held open by a process can explain a discrepancy.

df -h; du -sh /var
02 / EXPLAIN IT PROPERLY

What's going on?

df reports allocated filesystem blocks; du totals reachable directory entries. Deleted files still held open by a process can explain a discrepancy.

Understanding the underlying mechanism makes troubleshooting much easier than memorising a command in isolation.

03 / UNDER THE BONNET

Dig a little deeper

Use sudo lsof +L1 to find deleted but open files. Check filesystem reserved blocks with tune2fs -l (ext filesystems), and make sure du isn't traversing another mounted filesystem.

04 / TRY IT YOURSELF

Hands-on commands

Try these in a suitable test environment. Read each command before running it, especially if you have elevated privileges.

df -h /var
sudo du -xsh /var
sudo lsof +L1
05 / THE RABBIT HOLE

One more thing...

Disk usage is a lesson in the difference between names and objects.

Explore another mystery ↗
← Back to the knowledge base