Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any unix file system (or network fs) that can get size of folder without iterating over its content?

I need the fastest and cheapest way to get size of folder (maybe some fs cache metadata on nodes?), iterating over its content is too slow.

share|improve this question

closed as not constructive by EEAA, Khaled, Ward, mdpc, Dave M Jan 27 '13 at 20:04

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

Some more details would improve this question. For instance, how are you currently determining size? Are you reading in the files and counting the bytes or just reading the metadata? Also, how slow is "slow"? Actual numbers here are important. You may have reached the limits of your physical disks and only changing those will help (RAID, 15krpm, SSDs, all of the above, etc.). Your measuring methodology will be important too. It's very easy to get misleading performance data about disks thanks to the filesystem cache. – Ladadadada Jan 27 '13 at 12:34
up vote 1 down vote accepted

[Linux only answer] If there is a specific set of folders you want to measure fast you could try to use:

  • separate filesystems/mountpoints (e.g. on LVM to ease management), then use df to get size. Be aware that df on some filesystems are not 100% accurate.
  • XFS project quotas and then see disk usage by xfs_quota -x -c "report -p". You can assign huge disk space or disable quota enforcements by using uqnoenforce mount option.

Personally I would go to XFS project quotas on kernels that do support it.

share|improve this answer

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