How to Manage and Clear a Full Partition Efficiently

March 17, 2025 / Command Line

This guide provides steps to manage and clear a full partition. The /var directory typically fills up first since it stores system logs. The /usr directory may also fill up quickly due to Apache usage.

Let us follow these steps:

Checking Disk Space

To check disk space from the command line, follow these steps:

  1. Log in to your server as the root user via SSH.
  2. Identify the directory or log consuming the most space by navigating to the /var directory and running the following command:
    du -sh
    • The du command estimates disk space usage.
    • The -sh flag displays results in a human-readable format.
  3. The output will resemble the following example:
    4.0K    ./cpanel/acllists
    0   ./cpanel/analytics/data
    0   ./cpanel/analytics/logs
    0   ./cpanel/analytics/run
    4.0K    ./cpanel/analytics
    24K ./cpanel/plugins/wordpress-instance-manager-plugin
    24K ./cpanel/plugins
    0   ./cpanel/passreset
    8.0K    ./cpanel/mailman/diskusage_cache
    8.0K    ./cpanel/mailman
    563M    ./cpanel
    4.0K    ./named/data
    0   ./named/dynamic
    0   ./named/slaves
    124K    ./named/cache
    236K    ./named
    44K ./www/html
    0   ./www/cgi-bin
    44K ./www
    0   ./cvs
    0   ./proftpd
    2.8G    .

The left column displays file and directory sizes in a human-readable format.

Deleting Unnecessary Files and Directories
To free up space, delete unnecessary files and directories by following these steps:

  1. Navigate to the directory consuming the most space.
  2. Check file sizes using:
    du -h *
    • This command lists file sizes in a human-readable format.
  3. Review the output to identify large files. For example, in the /var/www/html directory:
    4.0K    400.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
  4. Save recent entries before deleting files (optional):
    tail -5000 filename > filename.new
    mv filename.new filename
    sync
    • Replace the filename with the actual file name.
    • This command retains the last 5000 lines of the file.
  5. Delete files permanently using:
    cat /dev/null > filename
    • This command clears the file’s content.

Restarting Services

After clearing the files, restart the associated service.

By following these steps, you can efficiently manage disk space and prevent partition overflows.  If you require additional assistance, feel free to contact our support staff.

Want to prevent full partitions? Check out our guide How to set default disk usage quota for new packages through WHM

Spread the love