Search code examples
sizeblock

Find out block size of a device


I am trying to find out the block size of a file system. I found these 2 commands:

    [root@node1 test]# stat -fc %s .         
    4096
    [root@node1 test]# blockdev --getbsz /dev/mapper/node1_test
    512

Why is the result different? Which is the correct one?

Many thanks.


Solution

  • I think it's likely that both answers are correct. It's just that blockdev --getbsz returns the result in bytes. Your stat command must be returning bits.. So 512 X 8 = 4096.

    It seems that the result of stat would only show in bytes with that format specifier if it was not a filesystem. See the note about the formats on this page for stat.

    Reference for blockdev.