0 bytes on HD

Smoot Carl-Mitchell smoot at tic.com
Sun Apr 8 14:32:48 UTC 2012


On Sun, 2012-04-08 at 09:42 -0400, J wrote:

> FWIW, I have a problem with xsession-errors being filled silently to
> the point of filling up my HDD... I've actually had a 120GB
> xsession-errors file before.  Deleting that one file, because of it's
> size, resulted in exactly the behaviour described in the OP, where df
> would tell me I had 120GB free, but 0 available,until a reboot.  And I
> haven't found a manual way of resetting that.  TIme was, running sync
> may have helped the kernel catch up to the actual state of the
> filesystem, but it didn't help in my case, so a strait up reboot
> worked wonders.

Do this instead of a reboot:

cp /dev/null .xsession-errors

This will truncate the .xsessions-errors file and free the disk space
immediately.  When you deleted the .xessionn-errors file in an attempt
to free the diskspace, all you did was unlink the inode from a
directory.  But since the file is still open in some process, the
diskspace is not freed. The filesystem semantics allow a file to have no
directory entries.  A file's disk space (e.g. inode) is only freed when
its reference count is 0 which includes any process which has the file
open.

One trick which takes advantage of this semantic is to create a
temporary file and open it in a process and then unlink the file
immediately.  The process can continue to use the file.  Then when the
process exits, it is unnecessary to delete the file.  The OS will take
care of cleaning up the used disk space since the files reference count
is zero after the process exits.

-- 
Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
smoot at tic.com





More information about the ubuntu-users mailing list