Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I answered this question, assuming that the *.img file had a sector size of 512.

How do I query a device, or the image of a device, to find the correct sector size?

share|improve this question
up vote 16 down vote accepted

fdisk -l (that's lower L in the parameter) will show you, among other information, the sector size too.

$ sudo fdisk -l

Disk /dev/sda: 150.3 GB, 150323855360 bytes
255 heads, 63 sectors/track, 18275 cylinders, total 293601280 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
   /dev/sda1   *          63      208844      104391   83  Linux
   /dev/sda2          208845   209712509   104751832+  83  Linux

This shows that the sector size is 512 bytes.

EDIT: Newer versions of fdisk e.g., fdisk (from package util-linux 2.20.1), will also show you the logical and physical sector sizes. For example, relevant output from a "WDC WD10EFRX 1TB drive":

Disk /dev/sdn: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
share|improve this answer

According to the documentation for the queue sysfs files:

# cat /sys/block/sda/queue/hw_sector_size
share|improve this answer
This will not work for arbitrary image files. How should the kernel know about them? – Christian Pietsch Jul 22 '14 at 11:26

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.