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?


*

*

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

You are watching: How many bytes in a sector

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 bytes255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 4096 bytesI/O size (minimum/optimal): 4096 bytes / 4096 bytes
Share
Improve this answer
Follow
edited Mar 13 "14 at 17:12

*

Abhijeet Kasurde
47733 silver badges1717 bronze badges
answered Oct 3 "10 at 16:19
*

Patkos CsabaPatkos Csaba
2,39211 gold badge1818 silver badges1515 bronze badges
1
Add a comment |
28
According to the documentation for the queue sysfs files:

# cat /sys/block/sda/queue/hw_sector_size512
Share
Improve this answer
Follow
edited Nov 29 "12 at 8:43

*

Cristian Ciupitu
2,30511 gold badge2020 silver badges2525 bronze badges
answered Jul 3 "12 at 15:23
Anthony AnanichAnthony Ananich
6,54455 gold badges2828 silver badges4444 bronze badges
2
Add a comment |
5
One can just use file(1) command and do the math himself. This works even if you only have an image of the FAT system.

For example:

$ sudo file -s /dev/sda5 | tr , " "/dev/sda5: DOS/MBR boot sector code offset 0x58+2 OEM-ID "mkfs.fat" sectors/cluster 64 reserved sectors 64 Media descriptor 0xf8 sectors/track 63 heads 255 hidden sectors 147632128 sectors 536870912 (volumes > 32 MB) FAT (32 bit) sectors/FAT 65536 serial number 0x9f981691 unlabeledThis partition has 64 sectors per cluster. The number of bytes in each sector is 512, as it is the default, therefore, the cluster size is 32KB.

See more: How Many Electrons Are In A Single Covalent Bond S, How Many Electrons Are In Single Bonds

Notice that the sector size can be greater than 512 (FAT specification limits it to 4096 but you can go higher). When that happens, you will see an additional "Bytes/sector" field in the output.