Table of Contents
Remove excessive inodes
Updated Jun 8th, 2021 at 15:24 BST
Disk space issues can be caused by large files or too many inodes. Inodes store information about files and directories (folders), such as file ownership, access mode (read, write, execute permissions), and file type. The maximum number of inodes, like disk space, is set when the server is created.
If you have not yet found areas of high inode use, see find inode usage.
Warning: This article is intended for advanced SSH users. If you don't know the purpose of a file or folder, don't remove it. Removing system files or directories is irreversible and may break the server (taking all of the sites down).
Do not attempt to remove files from the /home/virtfs directory. This directory is a virtual file system used by WHM/cPanel and doesn't actually use disk space.
Switch to the root user.
Use "cd" to move into the directory with the inode issue before running any commands to remove files.
There are several ways to remove multiple files. The following are a few common methods.
If you run a command and receive an error like /bin/rm: Argument list too long, you will need to be more specific with your command (ie. files older than 14 days instead of all files).
To remove all of the files within a directory:
find /path/to/directory -type f -exec rm -f {} \;
Use -mtime to search for and remove specific files older than 14 days:
find /tmp -type f -mtime +14 -exec rm -f {} \;
Use -name to remove files that use the naming convention 'sess_{randomstring}':
find /var/cpanel/php/sessions/ea-php73 -type f -name 'sess*' -exec rm -f {} \;
Use -mmin to remove all files older than 30 minutes:
find /var/cpanel/php/sessions/ea-php73 -type f -mmin +30 -name 'sess*' -exec rm -f {} \;
To completely remove a directory and all of it's contents (use with extreme caution):
rm -rf /path/to/directory