BuycPanel Blog

BuycPanel Blog

Latest news and updates

How do you Clear a Full Partition

Posted by Allura on 28 05 2019.

A Brief Overview
The following document shall outline the steps that need to be followed in order to clear a full partition.It is usually the /var/directory that is the first to fill up. This is because it contains the system logs.Note:In certain cases, the /usr directory may however fill up first, due to Apache. 
Checking for Occupied and Available Space
The first thing to do before clearing a full partition is to check the directory space available.This can be done by a given user from the command line directly. One simply has to follow the outlined steps:Make sure one is logged in to the server as the root user via/from SSH.
Locate the log or directory that uses the most disk space on the system by changing to the /var directory and running the du -sh command.Note:The ‘Du’ utility identifies the estimated size and Disk space occupancy of each directory/log file on…

A Brief Overview

The following document shall outline the steps that need to be followed in order to clear a full partition.

It is usually the /var/directory that is the first to fill up. This is because it contains the system logs.

Note:

In certain cases, the /usr directory may however fill up first, due to Apache.

 

Checking for Occupied and Available Space

The first thing to do before clearing a full partition is to check the directory space available.

This can be done by a given user from the command line directly. One simply has to follow the outlined steps:

  • Make sure one is logged in to the server as the root user via/from SSH.
  • Locate the log or directory that uses the most disk space on the system by changing to the /var directory and running the du -sh command.

Note:

The ‘Du’ utility identifies the estimated size and Disk space occupancy of each directory/log file on the specified path, while the ‘-sh’ component makes sure it appears in a humanly intelligible format.

 

Clearing a Full Partition

It is only after the results of the aforementioned command have been examined and it has been determined which directories are using the maximum amount of disk space that one can decide to clear the relevant ones. The following steps will allow one to Delete it Clear the necessary directories/files:

  • One can choose to either delete individual files within directories or entire individual directories altogether.
  • Select the relevant directory such as the one using maximum disk space and determine the size of each of the individual files contained within it. This can be done by running the ‘ du -h’ command. The output should be similar to the one displayed below – 4.0K shtml
    4.0K     401.shtml
    4.0K     403.shtml
    4.0K     404.shtml
    4.0K     413.shtml
    4.0K     500.shtml
    12K      cp_errordocument.shtml
    4.0K     index.html

Note:
The above example relates to the output for the /var/www/html directory.

  • Having determined the details one can either Delete all of the files or choose to save recent entries, deleting others.
  • The Delete or Clear the files, one simply has to run the given command –

cat /dev/null > filename

  • To Save recent entries one can run a command similar to the given –

tail -5000 filename > filename.new
mv filename.new filename
sync

Note:
In the above command, the word, filename stands for the file to be deleted, while filename.new stands for the file to which to the most recent entries are to be saved.

Concluding Thoughts

Following the outlined steps should then enable a user to clear a full partition.

Once the process of clearing has been completed one should restart the service in order to ensure the smooth operation of the same.