1

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.

Diego
  • 11

1 Answers1

1

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.