I have this inode usage:

host:~ # df -i
Filesystem                             Inodes  IUsed   IFree IUse% Mounted on
/dev/hda1                              655360 655357       3  100% /

but, if I run this command:

for i in `find . -xdev -type d `; do echo `ls -a $i | wc -l` $i; done | sort -n

I have this output:

host:/ # find . -xdev -type f | cut -d "/" -f 2 | sort | uniq -c | sort -n
      3 srv
     17 root
     25 bin
     83 sbin
    133 lib64
    184 opt
    985 boot
   2109 etc
   4487 lib
  50489 usr

but the sum of all of them does not match at all. I have no clue where the inodes are used.

  • Use du --inodes -d 1 to get an overview of what is going on and then "drill down" further and further – Raman Sailopal Oct 6 '17 at 13:30

Because your script find only files (-type f).

Directories and symlinks has own inodes but your search request do not find it.

Correct your command to get something like this:

find / -xdev \( -type f -o -type d -o -type l \) | cut -d "/" -f 2 | sort | uniq -c | sort -n

And you will get different output.


Some advice: do not use command like this for inodes problem troubleshooting. In most cases you get problem with small log files that consume all inodes and you basic problem is to find this files.

To do this you can use -mtime option of find command:

find / -xdev -mtime -1 -printf '%h\n' -type f | sort | uniq -c | sort -k 1 -n

This command return directories with amount of file.

And you can replace -type f with \( -type f -o -type d -o -type l \) as mentioned above.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.