Find out how many inodes you are using on a hard disk or in a directory?

Inodes are like pseudo files that manage the metadata about the actual files and folders on the filing system, they don’t have any data in them.

How Many Inodes On Disk

Most hosting plans have a limitation on inodes – so you need to know how many inodes there are and where they are being used if you need to do some file deletion. If you remove files and folders you will lower your inode usage.

To find the inode limit for your whole disk or VPS, on the command line type:

df -i

Output will be similar to this: 

Filesystem            Inodes   IUsed   IFree IUse% Mounted on

/dev/vzfs            1000000  805718  194282   81% /

So this tells us all we need to know:

  • FIlesystem – Our actual file system
  • Inodes – How many inodes are available
  • Iused – How many inodes are used
  • IFsed – How many inodes are free
  • IUse% – Percentage of inodes used

To find and display a well formatted summary of how many inodes are in a certain directory and list all the subdirectories – move into the directory and run: 

echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"

Output will be similar to below


To see which folder on the filing system contains the most inodes, from the disk root directory on the command line run:

{ find / -xdev -printf '%h\n' | sort | uniq -c | sort -k 1 -n; } 2>/dev/null

Depending on how large your disk is, this mat take a coupe of minutes, the returned output on the command line will show you the smallest to largest directory of files, so this can assist where you can do some file removal.