Hi all,
Spot the bleedin' obvious:
jmkg@s1c1:/home$ sudo du -csh 64G . 64G total jmkg@s1c1:/home$ sudo df -h /home Filesystem Size Used Avail Use% Mounted on /dev/sda7 124G 105G 13G 89% /home
Tiny wincey little bit of a disagreement going on there. Server is a MySQL box, I've had to keep removing binary logs due to disk space issues and lately this has been a pain. A quick look for other areas of disk usage on this partition showed the discrepency.
Any particular ideas on what may be the cause? Only reference on Google was circa 1999 when deleting open files caused this to be demonstrated. df does update when I delete stuff today...
Cheers,
James
James
$ du -csh /home : 64G total $ df -h /home : 124G 105G 13G 89% /home
Any particular ideas on what may be the cause? Only reference on Google was circa 1999 when deleting open files caused this . . .
du only shows named files, but anonymous files still take up space in the filesystem and so show up on df.
An anonymous file is produced when a file is opened by a process and then all the file's names are unlinked. Typical scenario:
An admin finds that nearly all the space on a slice is gone, spots a massive log file and rm's the file. Unfortunately the job writing the log still has it open and the log is still filling the partition up. Worse: since the file doesn't have a name anymore, there is no way to truncate it or do anything with it apart from killing the job that has it open. Moral: truncate the file before deleting it.
Some programs also write temporary files, and to stop them hanging around after program exit do:
Open file for read/write under some tempName unlink tempName write and read the file using its file descriptor close the file, or just exit to clear up.
To Fix: Do you remember doing rm on a big file? If so, knowing what its name was should tell you what is holding it open. If desparate, rebooting the machine will close the process holding the anonymous file open and free up the space. If this is too drastic, try restarting possible culprits - MySql, apache, anything else you might suspect and see if this restart frees up the 40G of anonymous space.
It might help to find the process holding an anonymous file open. To find the process try:
Shut down everything that you don't need that might have open files in /home, then run
fuser -m /dev/sda7
This should give you a list of process IDs which you can look at with ps -p, and with luck you can figure out what is happening. You can also use fuser to kill any processes holding files open under /home.
Hope this helps
Alan