Solution For Running Out of Inodes

The inode is a data structure in Unix-like file system and which stores information about the file except its name and the path of the file. An inode is always said to be a metadata of data. A file in Unix-like system is stored in two places on the disk – data block and inodes. The contents of file stored in data block, and the inode contains the information about the data. The inode contains the following information:

1) Mode/permission (protection)

2) Owner ID

3) Group ID

4) Size of file

5) Number of hard links to the file

6) Time last accessed

7) Time last modified

8) Time inode last modified

 

To list the inode of files on a directory, we can use the following command.

# cd /

# ls -lai

 

total 132

2 drwxr-xr-x  24 root root   4096 Feb 26 13:31 .

2 drwxr-xr-x  24 root root   4096 Feb 26 13:31 ..

2637825 drwxr-xr-x   2 root root   4096 Jan 14 19:02 bin

196609 drwxr-xr-x   3 root root   4096 Feb 24 10:41 boot

3 drwxr-xr-x  16 root root   4460 Mar  5 09:35 dev

983041 drwxr-xr-x 206 root root  12288 Mar  5 07:45 etc

2 drwxr-xr-x  14 root root   4096 Dec 29 09:24 home

One of the major issues on the server side is the disk space issues and high load average issues. Most likely you got this message “No space left on device” or “disk is full” despite having enough space free on your server. If you ever face this trouble, most likely it’s because of your server exceeds the available inodes. Let’s discuss about the solution for this problem;

 

Solution

1) The first step is for it to check whether your server have enough free disk space. Use the below given command for checking the available disk space on the server.

# df -h

Filesystem         1K-blocks    Used     Available   Use%     Mounted on

/dev/xvda         33030016   10407780  22622236   32%     /

tmpfs             368748     0        368748     0%      /lib/init/rw

varrun            368748     56       368692      1%     /var/run

varlock            368748     0        368748     0%      /var/lock

udev              368748     108      368640     1%      /dev

tmpfs             368748      0       368748     0%      /dev/shm

 

2) The second step is to check the available inodes on your server. For that use below command to check the available inodes on the server.

# df -i

Filesystem         Inodes     IUsed      IFree     IUse%   Mounted on

/dev/xvda         2080768    2080768     0      100%    /

tmpfs             92187      3          92184   1%     /lib/init/rw

varrun            92187      38          92149   1%    /var/run

varlock            92187      4          92183   1%    /var/lock

udev              92187     4404        87783   5%    /dev

tmpfs             92187       1         92186   1%    /dev/shm

If the result has 100% or near of IUse% value, then the large number of files is the reason for this issue.

 

3) The next step is to find those files. For that we can use a small script which will list the directories and the number of files on them.

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

From the output, you can see the directory which uses a large number of files, then repeat this script for that directory like below. Repeat it until you see the suspected directory.

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

 

4) When you find the suspected directory with large number of unwanted files. Just delete the unwanted files on that directory and free up some inode space by following command.

#  rm -rf /home/bad_user/directory_with_lots_of_empty_files

You have successfully solved the problem. Check the inode usage now with the df -i command again, you can see the difference like this.

# df -i

Filesystem            Inodes    IUsed    IFree  IUse%  Mounted on

/dev/xvda            2080768  284431  1796337    14%   /

tmpfs                92187       3    92184     1%    /lib/init/rw

varrun                92187      38    92149     1%   /var/run

varlock                92187       4    92183     1%   /var/lock

udev                  92187    4404    87783     5%   /dev

tmpfs                 92187       1    92186     1%   /dev/shm

 

If you need any further assistance please contact our support department.

Was this answer helpful? 0 Users Found This Useful (0 Votes)