unix

How do I determine the block size for my filesystem?

The block size for your filesystem specifies size that the filesystem will use to read and write data. Larger block sizes help improve disk I/O performance when dealing with large files because the disk can read or write data for a longer period of time before having to search for the next block.

If you set your block size to 4096 (4K) and you create a file that is 256 bytes in size, it will still consume 4K of space on your hard drive. For one file that’s not a problem, but for thousands of files it can add up to a lot of wasted space.

Block size can also affect the maximum supported file size on some filesystems because many filesystem are limited by the number of blocks.

Below are some examples of ways you can check the block size:

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

# dumpe2fs -h /dev/sda1 |grep “Block size:”
Block size: 4096

# blockdev –getbsz /dev/sda1
4096

# echo “abc” > testfile
# du -h testfile
4.0K test

Click to comment

Leave a Reply

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

To Top