Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 06-14-2013, 02:46 PM   #1
LQ Newbie
Registered: May 2013
Posts: 4

Rep: Reputation: Disabled
total number of files in mount point from all directories

Hi folks

we have to migrate a data from 1 server to another for that we need completed file list and data size and inode number which exist on a mount point. Please tell me command or set of commands to do following.
1 total number of file in a mount point[from all directories]. file names not required.
2 total number of inodes which exist in a mount point
3 total size of all directories which exist under mount point

Last edited by rookie11; 06-14-2013 at 02:53 PM.
Old 06-14-2013, 03:28 PM   #2
Registered: Jan 2012
Location: South Africa
Posts: 500

Rep: Reputation: 189Reputation: 189
Hi there,

For the number of files, try running "find /mountpoint -xdev -type f -print | wc -l" (as root).

For the number of inodes, I'm not sure of a filesystem-agnostic command. For Ext2/3/4 filesystems, try "tune2fs -l /dev/sda2" (using correct device name of course). There are similar commands for other filesystem types.

For the total size of all directories under the mount point, you can get the info from the "df -h" and "du -hx" commands.


Old 06-14-2013, 05:51 PM   #3
Registered: Mar 2013
Distribution: Redhat, Ubuntu
Posts: 525

Rep: Reputation: 141Reputation: 141
This is a rough script. you can improve on it in many ways. (Taken from script template originally created by druuna from here)

PHP Code:
while read MOUNTED
"Looking in: $MOUNTED"
total_files=$(find $MOUNTED -type f 2>/dev/null wc -l)
total_inodes=$(df --inodes $MOUNTED awk '$1~/(mapper|sd)/{print $2}')
total_size=$(du -sh $MOUNTED 2>/dev/null awk '{print $1}')
"Total Files: $total_files"
echo "Total iNodes: $total_inodes"
echo "Total Size: $total_size"
done < <(df -awk '$1~/(mapper|sd)/ { print $(NF)}'
$ ./allfiles
Looking in: /
Total Files: 333560
Total iNodes: 983040
Total Size: 381G

Looking in: /boot
Total Files: 30
Total iNodes: 51200
Total Size: 58M

Looking in: /dc
Total Files: 10337
Total iNodes: 32768000
Total Size: 56G

Looking in: /home
Total Files: 4638
Total iNodes: 6553600
Total Size: 18G

Looking in: /var
Total Files: 19956
Total iNodes: 1310720
Total Size: 5.7G

Looking in: /mnt/Win8
Total Files: 99129
Total iNodes: 6172720
Total Size: 31G

Looking in: /mnt/Backup
Total Files: 11323
Total iNodes: 23553832
Total Size: 212G

Looking in: /media/Madhu_USB
Total Files: 5
Total iNodes: 14893916
Total Size: 697M

Last edited by mddnix; 06-14-2013 at 05:52 PM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find the total number of files in a folder cnm Linux - Newbie 18 08-25-2015 02:01 AM
subtract total numbers of files from 2 directories Michael235 Linux - Newbie 2 03-28-2009 06:49 PM
Listing the mount point for directories sopiaz57 Linux - General 2 03-27-2007 12:29 PM
List total number of directories paraiso Linux - Newbie 5 04-18-2005 05:04 AM
Command to list total number of files. WillieB_72 Linux - General 3 01-29-2003 10:25 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:33 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration