How to Find Filesystem Inode Utilization in Linux

Most Linux filesystems utilize an index node (inode) data structure to reference filesystem objects such as files and directories. Each filesystem object is allocated an inode within the inode table that is used to store its various attributes and metadata. As additional files are created within a filesystem, inode usage increases and may possibly become exhausted. This document describes how to identify specific inode usage.

The du command provides the –inode option that allows users to identify which files/directories utilise the greatest number of inodes i.e.

# man du(1)

NAME
du - estimate file space usage
....
--inodes
list inode usage information instead of block usage
....

Examples of Finding inode usage

1. The following example displays specific inode usage within a filesystem using du(1):

# du --inodes /var/log/ | sort -rn
150 /var/log/
26 /var/log/journal
25 /var/log/journal/42bcb1d7d2694862b1aeb9c95a5ecc9a
16 /var/log/gdm
15 /var/log/sa
10 /var/log/anaconda
8 /var/log/cups
3 /var/log/swtpm
3 /var/log/audit
2 /var/log/tuned
2 /var/log/swtpm/libvirt
2 /var/log/samba
2 /var/log/pluto
2 /var/log/libvirt
1 /var/log/swtpm/libvirt/qemu
1 /var/log/speech-dispatcher
1 /var/log/samba/old
1 /var/log/qemu-ga
1 /var/log/ppp
1 /var/log/pluto/peer
1 /var/log/libvirt/qemu
1 /var/log/glusterfs
1 /var/log/chrony

2. The following example displays overall filesystem inode usage:

# df -iH
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 4.2M 407 4.2M 1% /dev
tmpfs 4.1M 1 4.1M 1% /dev/shm
tmpfs 4.1M 704 4.1M 1% /run
tmpfs 4.1M 15 4.1M 1% /sys/fs/cgroup
/dev/mapper/vg00-root 961k 961k 0 100% /
/dev/mapper/vg00-usr 641k 118k 524k 19% /usr

3. The following example displays the specific inode number associated with a file using ls(1):

# ls -li
total 96
57345 drwxr-xr-x. 2 root root 4096 Apr 23 2018 adm
8193 drwxr-xr-x. 6 root root 4096 Apr 23 15:21 cache
32770 drwxr-xr-x. 2 root root 4096 Aug 8 2019 crash
65537 drwxr-xr-x. 4 root root 4096 Dec 5 06:03 db
16385 drwxr-xr-x. 2 root root 4096 Apr 23 2018 games
24577 drwxr-xr-x. 2 root root 4096 Apr 23 2018 gopher
24578 drwxr-xr-x. 3 root root 4096 Jun 2 2020 kerberos
90113 drwxr-xr-x. 36 root root 4096 Dec 5 06:02 lib
32769 drwxr-xr-x. 2 root root 4096 Apr 11 2018 local
13 lrwxrwxrwx. 1 root root 11 May 32 2016 lock -> ../run/lock
2 drwxr-xr-x. 21 root root 4096 Mar 17 17:07 log
11 drwx------. 2 root root 16384 May 11 2016 lost+found
67 lrwxrwxrwx. 1 root root 10 Jan 6 2020 mail -> spool/mail
65538 drwxr-xr-x. 2 root root 4096 Apr 23 2018 opt
12 lrwxrwxrwx. 1 root root 6 May 11 2016 run -> ../run
16386 drwxr-xr-x. 12 root root 4096 Apr 11 2018 spool
57346 drwxrwxrwt. 6 root root 4096 Mar 20 07:14 tmp
73730 drwxr-xr-x. 2 root root 4096 Apr 11 2020 yp
Related Post