Why does a 1-byte size file occupies 8 blocks in hard drive in ext4 filesystem?

Viewed 1106

I've ran into a scenario where I've created a simple plain text file with just one ASCII letter: a. I checked the file size with stat and here's what I got:

$ stat file
File: 'file'
  Size: 1           Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d  Inode: 433312      Links: 1
...many details...

Blocks: 8 reported by stat is the number of blocks allocated. Why a file with a 1-byte size file occupies 8 blocks with each block having a size of 4096 bytes?

Assuming I read the results of stat properly, this means other distinct files in the filesystem share blocks, because a 1-byte file consuming 4096 * 8 of space is too much, isn't? Essentially, are the 8 blocks occupied by the 1-byte file alone?

Edit:

This question clarified many concepts: How does stat command calculate the blocks of a file?

Then each block is allocated in 512 bytes and the 1 byte file consumes a physical storage of 512 * 8 = 4096. Does this mean that only one block is actually being used to store the 1 byte and because each block is 512 bytes the block won't be fully used and the remaining 7 blocks will be empty, but still reserved for the 1 byte file?

I/O block as reported by stat is 4096, the 4096 is then the preferable chunks of bytes for reading and writing from and to disk? This indicates that I/O operations read 8 blocks of size 512 bytes at a time, right?.

The physical blocks are always 512 bytes at least for hard drives, is this correct?

0 Answers
Related