Printing the current sector size of a device in Linux

In the past year, a number of disk drives started shipping with 4K sector sizes. To see if your disk drive is using 512-byte or 4K sectors, you can use the blktool utility to print the sector size of a device:

$ blktool /dev/sda sector-sz
512

You can also look at the hw_sector_size value for a given device in /sys, but who wants to do that when a sweet little utility like blktool exists. There are various other ways to do this, and you comments and suggestions are welcome. :)

4 thoughts on “Printing the current sector size of a device in Linux”

  1. I think your post should read 512 bytes and 4K :)

    What is the benefit / difference using 4K sectors instead of 512 bytes?

  2. @John — oops, typo on my part. From what I’ve read, the disk manufacturers need to use larger sector sizes to get more capacity out of disks (you can address more 4k sectors than 512-byte sectors with the same amount of memory).

    I haven’t seen any good papers describing the performance benefits to 4k sectors. Most modern disk firmware should be able to coalesce adjoining 512-byte reads / writes into a single larger read / write, so I’m not real sure if 4k sectors make much of a difference for performance. If someone has a link to some performance data, please let me know.

Leave a Reply

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