Fundamentals 5 min read

How Much Disk Space Does a 1-Byte File Actually Occupy?

A file containing just one byte still consumes 4KB of disk space due to filesystem block allocation, plus inode and directory overhead.

Refining Core Development Skills
Refining Core Development Skills
Refining Core Development Skills
How Much Disk Space Does a 1-Byte File Actually Occupy?

This article explores how much disk space a file with only one byte of content actually occupies. It begins by demonstrating that creating an empty file consumes no data blocks, only an inode. After writing a single character to the file, the directory's disk usage jumps to 4KB, revealing that even minimal data triggers allocation of a full block.

The explanation delves into the Linux ext2 filesystem structure, showing that the inode contains a block array (i_block) with 15 entries: 12 direct pointers, one single indirect, one double indirect, and one triple indirect. The block size on the author's system is 4KB, as confirmed by the dumpe2fs command. This means the smallest allocatable unit is 4KB, so a one-byte file still consumes an entire block.

The article further explains how large files are managed through indirect indexing, allowing exponential growth in addressable space. It concludes by noting that this block-based allocation principle applies to all filesystems, including distributed systems like HDFS, which uses 128MB blocks to reduce management overhead for large-scale data processing.

The key takeaway is that maintaining many small files is inefficient, as each consumes at least one full block plus inode overhead, regardless of actual content size.

Inodefilesystemblock sizedisk allocationext2Storage Efficiency
Refining Core Development Skills
Written by

Refining Core Development Skills

Fei has over 10 years of development experience at Tencent and Sogou. Through this account, he shares his deep insights on performance.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.