If you run ls -l on a file that contains one letter, it will list as 2B in size. If your file system is in 4k blocks, I thought it rounded files up to the block size? Is it because ls -l actually reads the byte count from the inode? In what circumstances do you get rounded up to block answers vs actual byte count answers in Linux 2.6 Kernel GNU utils?
I guess you got that one letter into the file with
In contrast to
The first column is the allocated size, again in units of 1kiB. Last can be changed by specifying
As we can see the size of the file is listed as 2B. However, if you need to check the block size, you need to run the below command.
The 4 above displays the block size used. We can also verify the same using the
Now the question arises on why
I think that the deep answer is the following:
As the other answers show, in principle a file created with two bytes has length two bytes (show by
(the first command add 8191 zero bytes to
Some filesystem can also compact short files so that they occupy less space by sharing blocks (see for example tail packing) and others like btrfs do copy on write, so the relationship between a file, its logical length, and how much space it occupies on a disk is a complex one.
(1) It is not really a hole, it is at the end... but still, it works to the end of the example.