How do I clear a full partition ?
There are a few possible solutions.
Usually, /var is what fills up first. This is because /var holds all the system logs.
To see what directory or log is taking up all the room, start at the base. Issue the following commands from a terminal session:
- cd /var
- du -sh *
This will show how much space is used and available in each directory, as well as the file sizes of each file in the current directory. Examine the command's output. Once you see what directory is taking up all the space, cd to it and type the same command again. Follow this searching pattern until you find the files taking up the space.
Once found, you can either delete the files or, if you'd like to save some of the most recent entries to it, you can type this:
- tail -5000 filename > filename.new
- mv filename.new filename
This will copy the last 5000 lines from the file to a temporary file. Now you probably want to restart whatever service it is that created the file, to release its file lock.
The /usr directory also fills up sometimes, because of Apache. The first thing you should look at is usually the Apache logs.
- cd /usr/local/apache
- du -sh *
You will likely find that the logs/error_log or logs/access_log files are very large. At this point, you are free to delete them or use the tail trick above.