Thursday, February 4, 2016

linux - Disk space usage doesn't add up with df & du



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 ?


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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...