Discrepancy finding and counting all files on the system

0

I have been researching the different methods of counting up all files on my system. In my case, I want all the files starting at / and going into subfolders. Here is what I have come up with so far:

Method #1

# df --inodes /
Filesystem            Inodes IUsed   IFree IUse% Mounted on
/dev/mapper/sys-root 1602496 71756 1530740    5% /

Here I am concerned with (I think) the IUsed column. 71756.

Method #2

# find . -xdev -print | wc -l
74194

Here is the first discrepancy. My understanding is that each inodes represents a file, and that should be the most accurate figure. However in the second command I am not sure what else its finding.

Method #3

# find . -type f | wc -l
127470

I ran this from /. I expected to get something close to the figures above, but as you can see it was not even close. Can anyone explain these discrepancies and tell me which method out of the three I have provided give me the most accurate and total # of files on my system under /. ?? Or suggest a better approach?

user53029

Posted 2015-11-04T15:01:20.423

Reputation: 179

Answers

1

Well, regarding your last command, that one also searches in /dev, /proc, /cgroup, /sys. Which you don't want to count.

Edit: also in any other mounted fs you may have

cristi

Posted 2015-11-04T15:01:20.423

Reputation: 453