2

I believe this is the same question as Optimizing logical sector size for physical sector size 4096 HDD but that question never got an accepted answer and the existing answers dance around the core question.

If I have an advanced format HDD/SSD that I know has a physical sector size of 4K, AND I know that all the hardware/software on my system can handle a minimum I/O size of 4K, AND I'm OK with the marginal loss of free space for files smaller than 4K, THEN is there a way for me to set it up so that all components of the system view that device has having both a logical and physical sector size of 4K?

I expect a solid answer including the following information:

  1. What information does the disk reports to the kernel?

  2. Does the kernel unconditionally and truthfully reports that info via /sys or whether it can be made to conditionally adjust the values?

  3. Whether components other than the kernel might directly interact with the hardware and discover this information.

  • 1
    You made a long list of conditions for you to accept an answer. Now please describe what problem are you actually trying to solve, and what are your criteria for deciding whether said problem is solved on not in a given situation. In particular, do you have any numbers to back up your claims? – Satō Katsura May 24 '17 at 4:18
  • The problem is of course alignment, which I know the canonical solution for. But the canonical solution is hard to verify that it was applied correctly. Checking alignment when you have several disks in RAID, over which you have LUKS encryption, over which you have a filesystem can be tedious if not hard. A simple way to avoid that is to ensure there is only one option: 4k. – Huckle May 24 '17 at 20:16
0

It's not the kernel you need to patch for #1, it's the hard drive you will have to tell to both report and use a logical sector size of 4k.

On the other hand, if (as you say) all your software is prepared for a logical sector size of 4k, what difference does the sector size make? If all your reads and writes are multiples of 4k and are neatly aligned, what advantage do you gain from issuing a read command to the drive reading

  • 25 blocks starting from block 155, vs.
  • 200 blocks starting from block 1240?
  • It's about ease of verification. It's tedious to check alignment and block sizes for many layers of stack blocked devices and filesystems to make sure they are all aligned and of optimal size. If you can eliminate all the options at the source you've reduced the chances of something going wrong. – Huckle May 24 '17 at 20:19
0

I believe that some WD hard drives have a jumper you can set to switch the logical sector size to 4k, but there is really no need to do so since all recent software understands that the physical sector size is 4k and with automatically handle the correct alignment. For this reason, they may have phased out the jumper setting.

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.