Ubuntu: How file system block size works?


All Linux file systems have 4kb block size. Let's say I have 10mb of hard disk storage. That means I have 2560 blocks available and let's say I copied 2560 files each having 1kb of size. Each 1 kb block will occupy 1 block though it is not filling entire block.

So my entire disk is now filled but still I have 2560x3kb of free space. If I want to store another file of say 1mb will the file system allow me to store? Will it write in the free space left in the individual blocks? Is there any concept addressing this problem?

I would appreciate some clarification. Thanks in advance


The default block size was 512 bytes since the first Linux ever. Except until recently 4k block sizes where introduced to cater for the ever increasing size of disks. This is actually even nearly dictated by the disk hardware (see more:https://unix.stackexchange.com/questions/178899/optimizing-logical-sector-size-for-physical-sector-size-4096-hdd).

Yet for your specific question: you are right that all files waste the unused bytes of the last block on many types of file systems, which is particularly wasteful for small files. But btfrs and reiserfs seem to be able to cope, acvording to https://en.m.wikipedia.org/wiki/Block_suballocation


  1. File systems can have block size from 512 to (usually) 65536. The block size could be specified as mkfs.xxx option. The default blocksize of most of linux FSs - 4096.

  2. Some filesystems support tail-packing and/or subblock allocation. ext2/3/4, xfs AFAIK - not. If you plan to fill a partition by several small files, you could reduce a wasted "tail" space by shrinking blocksize to 512 or 1024.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »