Ubuntu - Find Out Your Block Size

The block size you have on your drives can significantly affect performance, but can also cause a lot of wasted space if you set it too large. In simple terms, the block size represents the minimum amount of physical disk space that is taken up by a file. Hence, if you have lots of tiny text files, then it's a good idea to have a small block size in order to reduce wasted space. However, if you are using HDDs (traditional hard drives) to just store large media files such as movies and music, then you may find that you want to set a larger block size of perhaps 1 MiB for better read/write performance.

Why would Increasing The Block Size Increase Performance?

Each block needs to have some assosciated metadata. Thus if you have a smaller block size, then there is more metadata that has to be written when you write the entire file (e.g. file transfers). I assume this is particularly relevant to filesystem level encryption (e.g. truecrypt) where a tiny change to a file within the volume results in all the bits of the volume (thus all the blocks) changing and having to be updated. This is why serverbear benchmarks drives with block sizes at 1M and 64k as shown below:

What's the Command to Find Out My Block Size?

sudo dumpe2fs /dev/sda1 | fgrep -e 'Block size'
Make sure to swap "/dev/sda1" with whatever partition you want to check. It may be useful to run sudo blkid to get potential list. E.g. I had to use "/dev/mapper/vg_main-lv_main" to get the blocksize of my logical volume that combines my 3TB drives.

References

No comments:

Post a Comment