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

  • OK, 2560 files , each is 1kb, that's 2560*0.001 mb = 2.56 mb. Each 1kb file should occupy roughly 1/4 of the block, because 1000*4=4000, right? And block size is 4096, so you need 4 files to fill up the block. 1mb file , then, will cost you 1000000/4096 = 244 blocks. – Sergiy Kolodyazhnyy Jun 28 '15 at 19:12

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

| improve this answer | |
  1. File systems can have block size from 512 to (usually) 65536 bytes. The block size can be specified as mkfs.xxx option. The default blocksize in most Linux filesystems - 4096 bytes.

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.