Apr 16, 2012
tom

Disk space usage doesn’t add up with df & du

Question

I’m trying to free up some disk space – if I do a df -h, I have a filesystem called /dev/mapper/vg00-var which says its 4G, 3.8G used, 205M left.

That corresponds to my /var directory.

If I descend into /var and do du -kscxh *, the total is 2.1G

2.1G + 200M free = 2.3G… So my question is, where is the remaining 1.7G ?

Asked by Codecraft

Answer

You probably have some deleted big log file, database file or something similar lying around, waiting for the process holding the file releasing it.

In Linux, a file deletion simply unlinks the file. It actually gets deleted when there’s no file handles connected to that file anymore. So, if you have a 2 GB log file which you delete manually with rm, the disk space will not be freed until you restart syslog daemon (or send HUP signal to it).

Try

lsof -n | grep -i deleted

and see if you have any deleted zombie files still floating around.

Answered by Janne Pikkarainen

Related posts:

  1. How to add disk space to /var/www for my websites?
  2. Logwatch Disk Space Usage is Wrong/Stale
  3. Out of disk space on 4GB partiton yet it’s only using 2GB
  4. VPS – Disk space usage shown in explorer higher than reported by WinDirStat, ideas?
  5. Centos server disk usage not matched?

Leave a comment