Examine disk space usage
To determine how much available space exists on your server's file systems, run the following command:
The output will resemble the following example:
1 2 3 4 5 6 | 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
|
This output displays that the system's main storage device (/dev/mapper/LogVol00
) which is mounted in the root
(/) directory uses 70% of its available disk space, and contains 85 gigabytes (GB) of free space.
Examine disk space usage by file and directory
To determine which files and directories consume most of your hard drive space, run the following command:
The output will resemble the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | root@host [~]# du -sh /
372K ~
107M etc
113 G home
253M lib
20K LICENSE
2.6M locale
16K lost+found
64K mbox_backup
8.0K media
8.0K mnt
418M opt
0 proc
12M pub
4.0K pub-htaccess.txt
648K templates
14K tmp
64K tools
5.4G /var
|
The numbers in the left column represent the sizes of the files and directories that the working directory contains, in human-readable format.
In the example above, the /home
directory uses the most disk space, with 113 gigabytes (GB). However, that directory likely contains your cPanel accounts. Since you will most likely not remove your users' data, examine the /var
directory for disk usage data. To do this, run the following command:
The output will resemble the following example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | 12K /var/account
4.0K /var/aptitude
28K /var/aquota.user
938M /var/cache
559M /var/cpanel
4.0K /var/cvs
24K /var/db
32K /var/empty
8.0K /var/games
173M /var/lib
8.0K /var/local
36K /var/lock
3.7G /var/log
0 /var/mail
10M /var/named
8.0K /var/nis
8.0K /var/opt
44K /var/portsentry
8.0K /var/preserve
144K /var/profiles
16K /var/proftpd
16K /var/proftpd.delay
4.0K /var/proftpd.pid
4.0K /var/proftpd.scoreboard
8.0K /var/quota.user
8.0K /var/racoon
1.2M /var/run
16M /var/spool
4.0K /var/state
14K /var/tmp
4.0K /var/vzquota
44K /var/www
20K /var/yp
|
The output displays that the /var/logs/
directory uses the most disk space.
Repeat this process to locate more files to remove.
Remove unnecessary files
To clear some disk space, run the rm
utility to remove some files from the file system, for example:
In the example above, filename
represents the path to the file or directory to remove. The -f
argument forces the file's removal, and the system does notprompt you to confirm that you wish to remove the file. This argument saves time if you use an asterisk (*
) as a wildcard to remove multiple files.
For example, to remove an old audit log file, change to the /var/log/audit
directory and perform the following steps:
Locate the audit.log
file that occupies the most disk space. To do this, run the following command:
The output will resemble the following example:
1 2 3 4 | 1.8M audit.log
2.1M audit.log.1
3.1M audit.log.2
5.1M audit.log.3
|
Run the following command to remove the audit.log
file that occupies the most disk space:
This command will not return output.
Confirm that the audit.log.3
file no longer exists. To do this, run the following command:
The output will resemble the following example:
1 2 3 | 1.8M audit.log
5.1M audit.log.1
5.1M audit.log.2
|
0 Comments