Determine the block size on a file system

Disks are divided into blocks. A block is the smallest readable or writable unit which can be addressed. The size of these blocks varies.

Block sizes of 512 Bytes used to be standard. Now all major file systems use a block size of 4096 Bytes or more. The block size used in a file system directly impacts the maximum size of the file system e.g. with a 4K block size an ext2, ext3 or NTFS file system can reach 16TB. With 8K blocks, 32TB.

Since the block size of a file system is the smallest writable unit, the first obvious solution would be to write a very small file and check it’s size on disk:

# echo “hello” > blocksize.txt
# du -h blocksize.txt
4.0K blocksize.txt

Of course this won’t help us if the file system is not writable (i.e. read-only). In this case, we’ll need to use one of these:

# dumpe2fs /dev/sda2 | grep -i ‘Block size’
Block size: 4096

# blockdev –getbsz /dev/sda2

# tune2fs -l /dev/sda2 | grep -i ‘block size’
Block size: 4096

All three methods return the same so use whatever you like better.

One thought on “Determine the block size on a file system

  1. Even while using Linux, we may be administering file systems for other OS’s. Thank you for including a command that supports non-Linux-specific file systems. So many posts only list Linux-specific anything, as if that’s all you will ever do on Linux.

    It should be noted that your web publishing software is converting the double-hyphen into emdash. You should probably use ‑‑ which is “& # 8 2 0 9 ;” without spaces.

Leave a Reply

Your email address will not be published. Required fields are marked *