How to: Manage your hard drive space
For WHM version 11.34
We strongly recommend keeping at least 10% of your disk space free.
Examining disk space usage by file system using the df command
If you suspect you're running out of hard drive space, you can easily confirm your suspicion using the df
In this example, the df
command will return all of the file systems mounted on your server and basic information about each mounted file system. The -h
argument causes the df
command to print the results in a human-readable format. The results should resemble the following:
root@host [/var/log]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/LogVol00 288G 189G 85G 70% /
/dev/sda1 99M 47M 48M 50% /boot
tmpfs 252M 0 252M 0% /dev/shm
/usr/tmpDSK 485M 11M 449M 3% /tmp
From this output, we can determine the system's main storage device (/dev/mapper/LogVol00
) mounted at root (/
) is at 70% capacity. In this case, there are only 85 gigabytes of free space on the system's main storage device.
Examining disk space usage by file and directory using the du command
To find out which files and directories are consuming most of your hard drive space, you can use the du
command. This command will print the estimated disk space usage of each file and directory specified.
du -sh /
In the example above, the
argument will print a summary of all contents of your present working directory, versus printing each file and directory's disk usage information individually. The h
argument (as when using df
) causes the command to print the information to the CLI
in human-readable format. The slash (/
) in this command specifies that you want to examine the contents of the root directory.
When passed in this way, the
utility will print the estimated disk space of each file and directory contained within your root directory (
The output of this command should resemble the following:
root@host [~]# du -sh /
113 G home
command will produce more output than the example above. Ideally, you should only run this command during off-peak hours to prevent putting additional load on your hard drives. You should also keep in mind that the du
command is slow by its very nature. This is because it calculates the amount of disk space each file and directory uses on the fly.
Once we have the output information, we can examine the numbers in the far left column. These numbers represent the sizes of the files and directories contained within the working directory (in this case,
), in human-readable format.
After examining the output above, we can determine that the
directory is using the most disk space: 113 gigabytes. However, it is very likely that your cPanel accounts are contained in that directory. As it is unlikely you will be able to remove your users' data, let's examine the
directory instead, by running another du
root@publicdocs [~]# du -sh /var/*
In the example above, we've specified the
directory to the du
command and added an asterisk (*
) to the end of the command. The asterisk is a wildcard that tells the du
command to list the summarized, human-readable disk usage information for every file and directory in
. After examining the output, we can determine that
is using the most disk space.
You can continue running du
commands until you locate the larger files you wish to remove. For the purposes of this tutorial, we can skip ahead a few steps.
Removing unnecessary files using the rm command
To clear some disk space, we will need to remove some files. We can use the rm
utility to do so. This utility removes files from the file system.
rm -f $file
In the example above, the -f
argument forces the removal of the file. This means that you will not
be prompted to confirm that you wish to remove the file. Passing rm
using the -f
argument will save time. However, you will need to be absolutely certain you are ready to delete the file . The $file
parameter is the path to the file or directory you wish to remove. For our purposes, we will only remove single files, rather than entire directories.
Let's continue by removing an old audit log file. To do so, we could use the following chain of commands:
root@host [/]# cd /var/log/audit
root@host [/var/log/audit]# du -sh *
root@host [/var/log/audit]# rm -f audit.log.3
root@host [/var/log/audit]# du -h *
As you can see in the example above, we have successfully located and removed a file that was consuming resources on the system. You can repeat this process until you clear enough free space.