Freeing Space

Problem:

Is there a way to tell the kernel to give back the free disk space now? Like a write to something in /proc/ ?

This is probably an old and very repeated theme. After hitting 0 space only noticed when my editor couldn't save source code files I have open, which to my horror now have 0 byte size in the folder listing, I went on a deleting spree.

An hour later still no free space and cannot save my precious files opened in the editor, but notice the disparity below:

# sync; df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda4 13915072 13304004 0 100% /

Any suggestions? I shut off some services/processes but not sure how to check who might be actively eating disk space.


Solution:

sudo lsof | grep "(deleted)$" | sed -re 's/^\S+\s+(\S+)\s+\S+\s+([0-9]+).*/\1\/fd\/\2/' | while read file; do sudo bash -c ": > /proc/$file"; done

Explanation:
Grep lsof output to extract only deleted files. Sed extract the process id and filedescriptor id from each line, and create a string in format {pid}/fd/{fid}. While loop and output nothing to each file, setting them to empty.
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

What are .htaccess files and how to create and edit them

.htaccess files are used to configure and provide the server with instuctions regarding the...

How to install a custom BIN on CloudLinux (with CageFS)

CageFS creates a filesystem template in /usr/share/cagefs-skeleton directory. CageFS template...

[WHM/cPanel] Update WHM/cPanel using CLI

Occasionally, WHM or cPanel might experience errors that can only be resolved by updating the...

[WHM/cPanel] CloudLinux PHP selector not saving on cPanel 54 and CL 6.x & 7.x

Problem:When trying to change php extensions in paper_lantern, nothing saves. I can click Save or...

How to silence a CRON and prevent it to send emails

Problem:Every time that a CRON is running, an email is sent.  Those emails aren't always...