How to Manage your Hard Drive Space
This document provides steps to help you to manage your server's hard drive space.
Important:
We strongly recommend that you keep at least 10% of your server's available disk space free.
Examine disk space usage
To examine your system's disk space usage, run the following command:
df -h |
The output will resemble the following example:
|
1
2
3
4
5
|
Filesystem Size Used Avail Use% Mounted on/dev/mapper/LogVol00 288G 189G 85G 70% //dev/sda1 99M 47M 48M 50% /boottmpfs 252M 0 252M 0% /dev/shm/usr/tmpDSK 485M 11M 449M 3% /tmp |
This output indicates that the system's main storage device (/dev/mapper/LogVol00) in the root (/) directory uses 70% of its available disk space and contains 85 GB of free space.
Examine disk space usage by file and directory
If your system currently uses too much disk space, perform the following steps to identify files to delete:
-
To determine which files and directories consume most of your hard drive space, run the
ducommand.The output will resemble the following example:
123456789101112131415161718372K ~107M etc113 G home253M lib20K LICENSE2.6M locale16K lost+found64K mbox_backup8.0K media8.0K mnt418M opt0 proc12M pub4.0K pub-htaccess.txt648K templates14K tmp64K tools5.4G/varNotes:
- We recommend that you only run this command in off-peak hours to prevent additional load on your server.
- The numbers in the left column represent the sizes of the files and directories that the working directory contains, in human-readable format.
In this example, the
/homedirectory, which generally contains the system's cPanel account data, uses the most disk space (113 GB). Because in most cases you cannot delete your users' data, examine the second largest directory (the/vardirectory) for disk usage data. -
To examine the desired directory, run the following command:
du-sh/var/*The output will resemble the following example:
12345678910111213141516171819202122232425262728293031323312K/var/account4.0K/var/aptitude28K/var/aquota.user938M/var/cache559M/var/cpanel4.0K/var/cvs24K/var/db32K/var/empty8.0K/var/games173M/var/lib8.0K/var/local36K/var/lock3.7G/var/log0/var/mail10M/var/named8.0K/var/nis8.0K/var/opt44K/var/portsentry8.0K/var/preserve144K/var/profiles16K/var/proftpd16K/var/proftpd.delay4.0K/var/proftpd.pid4.0K/var/proftpd.scoreboard8.0K/var/quota.user8.0K/var/racoon1.2M/var/run16M/var/spool4.0K/var/state14K/var/tmp4.0K/var/vzquota44K/var/www20K/var/ypThis output indicates that the
/var/logs/directory uses the most disk space.Note:
Log files use disk space quickly. To retain recent log file entries, perform the additional steps in the Retain log entries section below.
- Repeat this process until you locate files that you wish to remove.
-
To delete the desired files, run the following command, where
filenamerepresents the file to remove:rm-f filenameWarning:
Exercise caution when you run the
rmutility. You cannot recover files or directories that you delete.
Retain log entries
Log files often use a large amount of disk space. To retain the system's most recent log file entries when you remove excess log files, perform the following steps:
-
If you have not already located the specific files to remove from this directory, run the
ducommand. - Examine the command's output to determine the files to delete.
-
For each file, run the following commands, where
filenamerepresents the file's name.123tail-5000 filename > filename.newmvfilename.new filenamesync - To release the file lock, restart the service that created the file.
SMART errors
Warning:
Self-Monitoring, Analysis and Reporting Technology (SMART) errors may indicate hard disk failures or other problems. Only disable SMART errors if you understand these risks.
To disable SMART errors, run the following commands:
|
1
2
|
touch /var/cpanel/disablesmartcheck/scripts/upcp |