Fork me on GitHub

Cleaning Up Disk Space

Let us assume you already figured out where your disk space went.

Cleaning up disk space is easy: You just delete stuf, right?

Well.. Mostly. There are a couple of things to watch out for:

  • Deleting important stuff is ... bad. You still want a working system, right?
  • Deleting files that are in use will not free up the disk space until processes close the files.

Cleaning Out Log Files

Often, the culprit will be a log file that has grown beyond expectations: so you have two options:

  • Stop the process writing to the log file, remove the log file, and start the process again. Obviously this implies that some (important?) service will be down for a short time. You will have to decide whether the downtime is acceptable.

  • Simply truncate the log file with the smiley of death:

    :> /path/to/offending-file

    This makes use of the colon shell command - which is a no-op. Some people prefer to use the much-long-to-type command:

    echo > /path/to/offending-file

    which not only is much longer to type, but also puts a newline in the file. Why bother!?