Delete via File Descriptor to free up disk space

Sometimes, you might see your “df -h /” showing 100% usage and even after deleting gigs of files/folders, you might not see the disk freed up.

So, this is what you have to do.

~]# lsof | grep deleted
java 8859 hudson 1w REG 253,0 3662503356 7578206 /crucible/data/current/var/log/fisheye.out (deleted)

Then execute:

cd /proc/PID/fd
ex: cd /proc/8332/fd

fd]# ls -l |grep deleted

total 0
l-wx—— 1 hudson devel 64 Feb 7 11:48 1 -> /crucible/data/current/var/log/fisheye.out (deleted)

The “1” will be the file descriptor. Now type “> FD” to reclaim that space

fd]# > 1

OR if you can find the entry in /proc/fd/ that cooresponds to the filehandle, you can cat /dev/null to it.

ex: lr-x—— 1 tomcat rms 64 Jun 23 18:02 /proc/8332/fd/341 -> /usr/local/tomcat

fd]# cat /dev/null > /proc/8332/fd/341

After running this, you will see that the inode is still open, but now it’s size is 0.

Advertisements