hdparm -I /dev/sda output:

Logical  Sector size:                   512 bytes
Physical Sector size:                   512 bytes

stat somefile output:

Size: 509           Blocks: 8          IO Block: 4096   regular file

Why IO Block is 4096 ? Isn't it the same as physical sector size which is 512 bytes ?


No. The disc block size says, in how big byte chunks is the data handled on the disk. If you write something to a file, your CPU/motherboard has to say to the drive controller, what bytes should be written in which sector of the disc. This can happen only in 512byte chunks.

The distinction between the logical and physical sector size is this: the physical sector size is in which the data is organized in the disc physically. The logical sector size means the chunks with your CPU/motherboard can talk with your driver controller card (which is often also a part of your motherboard, but your OS still has to know, what block sizes should it produce as it executes a disc read/write operation).

Since some decades, also the physical sector size is a faked one, and the exact details of it is a business secret of the hard disc manufacturer. But the OSes still have to know this faked data, because it is part of the disc standards (SCSI, PATA, SATA, etc). Thus the physical sector size has no practical meaning in most cases.

On some newer discs there is a new development, that they use 4096-logical sectors instead 512. It is needed because the sector numbers on some old ATA protocols have a 32 bit size, thus discs larger as 4billion sectors (=2Terabytes) couldn't be addressed on them.

The stat command says the block size of your filesystem. Also most filesystems organize data in blocks on your system. If you create a single byte file, it will have to allocate 4096 bytes on your disc. There is only rarely a non-block oriented filesystems, for example Reiserfs, although it is still organized in blocks, its smallest allocatable disc size is only 32 bytes. Thus an 1 byte file will allocate only 32 byte on a reiserfs filesystem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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