I have a 1 TB hard drive when I run:

# fdisk -l 

among other details I get:

Model: ATA HGST HTS721010A9 (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

I view the logical sector size to be the operating system's sector size for I/O. However, it shows that the physical sector is 4096B. I'm not sure what's the difference between the two. Why the kernel would use a 512B sector for I/O versus 4096B sector, maybe for compatibility reasons? Wouldn't this slow I/O operations?


Yes, compability is the reason. Hard disks moved to a sector size of 4096 to utilize the disk area more efficiently. All software could not be converted to use the larger sector size overnight, so 4k disks still present themselves as a having 512 byte logical sectors. It does slow down I/O if the disk accesses are not aligned to the 4096 physical sector size. If you take care of alignment, it really doesn't matter, because read and write requests are done multiple sectors at a time anyway. Note that the logical sector size is mandated by the disk, and the kernel has to adapt to it, not the other way round.

| improve this answer | |
  • "Note that the logical sector size is mandated by the disk, and the kernel has to adapt to it, not the other way round.". That's to say the kernel takes logical size from the disk? – direprobs Jul 30 '17 at 17:23
  • And what happens to the rest of the space available in the sector? – direprobs Jul 30 '17 at 17:45
  • 2
    The 4k physical sector is divided into eight 512 byte logical sectors. If a single write to the disk isn't a multiple of eight sectors, or the sectors aren't aligned to the 4k physical sectors, the drive must do a read-modify-write cycle, in which it reads the whole 4 k sector into RAM on the drive, modifies the changed sectors with the written data and finally writes the whole 4 k sector to the drive. – Johan Myréen Jul 30 '17 at 18:03
  • 2
    When the kernel requests a single 512 byte logical sector, the drive reads a whole 4096 byte physical sector into RAM on the drive, and sends the requested 512 byte chunk over the interface to the host. For example, if the kernel requests logical sector (block) 2 from the drive (counting from 0), the drive reads physical sector 0, and transmits bytes 1024 to 1535 to the host. The drive must read the whole physical sector since it is the smallest amount of data it can read at once. There are also drives where both the physical and logical sectors are 4k in size. – Johan Myréen Jul 30 '17 at 19:13
  • 1
    See the Wikipedia article on Advanced Format disks for more information. – Johan Myréen Jul 30 '17 at 19:20

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