reduce inode usage in linux

How to Reduce Inode Usage in Linux

Linux uses inodes (index nodes) to keep track of all files in the system whether it is images, videos, emails, spams, website content, backups. But every system has a limit on number of inodes allowed, depending on the system memory. When there are too many inodes to track in the system, Linux will start giving errors and it will also affect system performance. This happens because there are many unused files in the system such as junk files, spam emails, old backups that use up available inodes. If all available inodes are used up, you will not be able to create any more files on your system, even if there is plenty of disk space on it. So it is important to monitor inode usage regularly and remove unnecessary files from your system. In this article, we will learn how to reduce inode usage in Linux.


How to Reduce Inode Usage in Linux

Here is the command to check inode usage.

$ df -i

Here is a sample output of the above command, which displays the total number of inodes available for each partition, and number of inodes that have been used up at this point.

How to Reduce Inode Usage

There are several ways to reduce inode usage in Linux.

1. Remove Unnecessary Files & Folders

The simplest way to reduce inode usage is to remove unwanted files & folders from your system, These can include spam emails, junk files, old backups, etc. You can also remove these files via SSH.

2. Clear Cache

Various CMS systems like Drupal, WordPress, Joomla, etc. save cache about your website on your disk. This is used to improve speed & performance. This also increased inode usage. You can clear their cache to reduce inode usage.

3. Delete Spam Emails

Almost every email account has spam emails. Each email adds to one inode number. So it is advisable to delete old and spam emails to reduce inode usage.

4. Find Directory with Most Inode Usage

If you get inode errors event after following the above steps, you can run the following bash script to determine the directory with maximum inode usage.

for i in /*; do echo $i; find $i |wc -l; done

Thereafter, you can delete its contents to quickly fix the problem.

As we have learnt, inode number is basically the total number of files on your system. If the inode limit is reached, users cannot add any more files to the system.

We have also learnt several ways to reduce inode usage and clear inodes on Linux system.

Also read:

How to Use Port Knocking to Secure SSH
How to Enable & Disable Line Numbers in Vim
How to Read Audit Logs in Linux
How to Check User Login Details in Linux
How to Delete Multiple Directories in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *