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
4096
# tune2fs -l /dev/sda2 | grep -i ‘block size’
Block size: 4096
All three methods return the same so use whatever you like better.
No comments:
Post a Comment