A file with actual size 1 byte uses 8 blocks of 4096 bytes on the filesystem

79 Views Asked by At

In my home directory, I created a file named file_size_test.txt. I added a single character a to its content (no newline). Actual file size of file_size_test.txt = 1 byte.

However, stat file_size_test.txt shows that the file occupies 8 blocks. Block size = 4096 bytes.

NB: I'm running WSL with Ubuntu.

Details here: enter image description here

I was expecting that the file file_size_test.txt would only use 1 block.

A similar question was already asked here but the only answer provided didn't help me (at least as it was expressed): Linux block size issue

1

There are 1 best solutions below

0
Philippe On BEST ANSWER

There are two notions of block size :

$ sudo blockdev --getbsz /dev/sdc
4096
$ sudo blockdev --getpbsz /dev/sdc
512

The Blocks: 8 in stat is in terms of physical block size 8*512=4096.