Estimate the number of files a directory tree will contain based on depth and fan-out.
A directory tree with uniform fan-out forms a geometric structure: each level has fan_out^level directories. Files reside in the leaf directories, so total file count is leaf_directories × files_per_leaf. This estimate helps with inode capacity planning — if the estimated inode count exceeds the filesystem's inode limit, you will run out of inodes before running out of disk space.
Total files
total_files = fan_out^(depth-1) × files_per_dir
Total directories
total_dirs = sum(fan_out^i) for i=0 to depth-1
Many filesystems (especially ext4) have a fixed inode count set at format time. If you exhaust inodes, no new files can be created even with free disk space — a common issue on mail servers or systems with millions of tiny files.
Use 'df -i' to see inode usage per filesystem. The IUsed and IFree columns show consumed and remaining inodes respectively.