Skip to content
ENExplore Calculators

Directory Size Calculator

Estimate total directory size from file counts and average file sizes.

About Directory Size Calculator

The `du` command reports space actually allocated on disk, which is always ≥ the sum of file byte sizes because every file consumes whole filesystem blocks (block-rounding / 'slack space'), and every directory entry and inode carries its own metadata. This calculator estimates total = allocated_data + directory_metadata + inode_metadata, so you can sanity-check `du -sh` output against a rough file-count × average-size model before running it on a live filesystem.

Formula

Total estimated size

total ≈ file_count × ceil(avg_size / block_size) × block_size + subdirs × block_size + file_count × 256

n
file count
s
average file size
b
block size
d
subdirectory count

Worked example

With the default values below, Directory Size Calculator returns Estimated Total Size (incl. overhead) of 1.22 GiB. Change any input above and every figure here is recalculated in your browser.

Inputs used

Number of Filesminimum 0
10,000
Average File Size (KB)minimum 0
128
Number of Subdirectoriesminimum 0
50
Filesystem Block Size (bytes)one of 4096 (4K, ext4/xfs default), 1024 (1K), 8192 (8K)
4096 (4K, ext4/xfs default)

Results

Estimated Total Size (incl. overhead)
1.22 GiB
Raw Data Size (file bytes only)
1.22 GiB
Allocated Size (block-rounded)
1.22 GiB
Metadata + Slack Overhead (bytes)
2,764,800
Overhead Percentage
0.21%

Step by step

  1. 1Values used
  2. 2Total estimated size
  3. 3Estimated Total Size (incl. overhead)= 1.22 GiB
  4. 4Raw Data Size (file bytes only)= 1.22 GiB
  5. 5Allocated Size (block-rounded)= 1.22 GiB
  6. 6Metadata + Slack Overhead (bytes)= 2,764,800
  7. 7Overhead Percentage= 0.21

Assumptions and limits

  • The result is derived only from the 4 inputs listed above. Anything not among them is not part of the calculation.
  • In particular, this calculator does not take inflation, tax, fees or charges or compounding frequency into account.
  • Figures are rounded for display to 2 decimal places, so totals built from several rounded parts can differ slightly from the unrounded arithmetic.

How these calculators are built and tested is described on the Methodology page. If a figure looks wrong, please report it.

Frequently Asked Questions

Why does du report a bigger size than ls -l sums to?

ls -l shows exact byte sizes; du reports blocks actually allocated on disk. A 100-byte file on a filesystem with 4096-byte blocks still consumes one full 4096-byte block, so many small files inflate du's total well above the sum of their logical sizes.

How much does having many small files hurt disk usage?

Block rounding (slack space) is worst for files much smaller than the block size — a 1KB file on 4K blocks wastes 3KB. Millions of small files also multiply inode and directory-entry metadata overhead, which is why archiving small files into a tar or using a filesystem with tail-packing (like Btrfs or ReiserFS) reduces total usage.

Does this replace running du -sh directly?

No — this gives a planning estimate before you have access to the filesystem (e.g. sizing a migration or a new volume). For an authoritative number on an existing directory, always run du -sh or du --apparent-size for the raw byte total.

Directory Size Calculator | Calcrivo