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
$ stat -c %s,%o,%b foo.txt
$ stat -c %s,%o,%b bar.txt

Why the number of blocks is always a multiple of 8? I thought the number of blocks of a file is the smallest integer that satisfies filesize <= blocksize * blockcount.

share|improve this question
What's the output of dumpe2fs /dev/sda1 | grep Block (/dev/hda1 for an IDE disk)? – John T Jun 14 '10 at 4:18
Block count: 2441880 / Block size: 4096 / Blocks per group: 32768 / Group 0: ... / – C. Lee Jun 14 '10 at 4:22
Since you're using a block size of 4K, the min will always be 8. 4096/512=8. Edit: See Ignacio's answer. – John T Jun 14 '10 at 4:42
up vote 4 down vote accepted

%b returns the number of blocks on the filesystem that are allocated for the file, where each block is 512 bytes. Since the smallest block on the filesystem is 4kB, the number of blocks returned by stat will always be a multiple of 8 (4096 ÷ 512 = 8).

share|improve this answer
Thank you for your answer! But I still don't understand. 512 bytes? Where does it come from? – C. Lee Jun 14 '10 at 4:54
I don't know the entire history, but the sector size of disks used to be 512 bytes. – Ignacio Vazquez-Abrams Jun 14 '10 at 5:35
512-bytes blocks dates from the early days of Unix, and stayed in Linux for historical reasons. Thay have no relation to today's hard disks. – harrymc Jun 14 '10 at 10:03
@harry, Ignacio: they are not relating to Unix, but are to harddisks. And while hard disks don't really store information in 512-byte blocks, all of them are using LBA for addressing, which is 512-byte-discrete. – whitequark Jun 14 '10 at 13:49
Everything is a multiple of 8 because computer systems generally describe data in bits (base2 or 0 or 1 per digit) and bytes (base8 or 0-8 per digit) and hex (base 16 or 0-16 per digit) whereas 'normal' math is almost always base 10 (0-10 per digit). BTW, +1 for nice explanation. – Evan Plaice Jun 15 '10 at 8: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.