Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

When I execute the command df -h /tmp it says disk utilization is 100%, but when it try du -sh /tmp it says disk utilization is 2%.

I want to know why these commands shows different output, how these two commands work and what is the solution to this problem.

Context: /tmp is installed on it own file system. I am using Ubuntu 12.04 server edition on my VPS account. Due to this problem utilization of /tmp 100% according to df some programs complain about free space in /tmp.

share|improve this question

1 Answer 1

up vote 6 down vote accepted

du reports free space by scanning reachable inodes and calculating their size.

If a file is created, opened, and later deleted while it is still open, the program that opened it will continue to have access to the file, and writes and reads can be performed to that memory location on disk. du does not account for such open files whereas df does.

A simple restart should flush /tmp and solve your problem.

An alternative would be to scan open files and restart or kill the process that did not release the deleted files.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.