Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here is what I get when I issue stat command for a file in my linux:

yasar@yasar-laptop ~/myscripts/sysprog $ LC_ALL=C stat error.c
  File: 'error.c'
  Size: 184         Blocks: 8          IO Block: 4096   regular file
Device: 804h/2052d  Inode: 103650221   Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/   yasar)   Gid: (  100/   users)
Access: 2012-04-23 17:10:28.117455882 +0300
Modify: 2012-04-21 22:18:59.967686183 +0300
Change: 2012-04-21 22:19:00.001019336 +0300
 Birth: -

As you can see, block size for filesystem is 4kb and file has 8 blocks allocated, but it's size is only 184 bytes. Why a file cost 8 blocks, when only one block is sufficient?

share|improve this question
$ echo a > a

file "a" now contains two bytes, an "a" and a newline character.

$ stat -c "%b %B %s" a
16 512 2

There are 16 blocks allocated, each block is 512 bytes in size. This is the minimum quantity of space that the filesystem keeps track of.

share|improve this answer

The file system ext4 allocates at least 4k per file. That are 8 blocks on the disk (512 byte). Here is a really good explanation

share|improve this answer

as you see IO block aka filesystem block is 4kB

this means that file allocates eight 512 byte blocks

(and leaves me wondering what happens if we have modern disk with 4kB physical block size)

and you see the reason fdisk and windows partition tools recently offsets partitions by round megabytes from the start of the disk.... just in case it misdetects media blocksize (NAND write size etc) it is at least somewhat optimal, i.e not writing 4kB block across 2x 128kB NAND chips or so.

share|improve this answer
I don't understand. Where does 512 bytes come from? – yasar Apr 23 '12 at 15:10
it has been a magnetic disk block size for last 30 years. before there were some 1k-block disks, but they died out with disk maker conner. On the other hand CD/DVD uses 2k but they are somewhat later developments. As I mention modern drives tend towards 4kB blocks (which in turn is a memory management page size in i386). – ZaB Apr 23 '12 at 15:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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