Opened 8 years ago

Last modified 17 months ago

#11796 new enhancement

Support for "4K-native" hard disks.

Reported by: pulkomandy Owned by: nobody
Priority: normal Milestone: Unscheduled
Component: - General Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All


For some time now hard disks and SSDs have switched to 4K sectors instead of 512 bytes. They have, however, hidden this from the OS as it would break too much things (motherboard chipsets, BIOSes, etc). So the drives report secotrs of 512 bytes to the system and make adjustments on the firmware side.

However, we're starting to see some (high-end) drives which expose 4K sectors to the system. With an UEFI system and well-designed chipset the hardware issues should be solved, but the software needs to be adjusted as well. We need to check our MBR/GPT code, our stage1 loader, and the releated tools (drivesetup, writembr, makebootable, etc). We also need to check the ATA stack, block cache, filesystems, and make sure they don't hardcode the 512 bytes value anywhere and can handle 4K sectors properly. I suspect most of the issues would be in the bootloader and MBR, which is probably ok as these are skipped on EFI systems and it is currently unclear if an MBR is supposed to work on 4K-sector disks at all.

Change History (4)

comment:1 by waddlesplash, 4 years ago

I don't think legacy BIOSes can handle 4K disks natively, can it? That would be up to the BIOS to handle them properly, and my guess is that they don't, for the most part.

NVMe drives usually have much larger block sizes than 512, and our support for these seems fine. Anything more to be done here?

comment:3 by pulkomandy, 17 months ago

In SDHC and SDXC cards, this field was removed from the CSD and the sector size is fixed to 512 bytes.

To test this, you would have to find a 2GB or 4GB non-SDHC card, of which there are not many (SDHC was specified before 2GB cards became common).

The question here is mainly what happens for MBR and GPT, since they store partition offsets in LBA numbers. If the sectors on disk are larger, are we expected to store sizes in multiples of 512 bytes regardless of it, or are we expected to store them in multiples of the sector size used by the disk?

The SATA driver is also not currently able to handle sectors if size other than 512. There are some anouncements for migrating to "4K native" disks ( for example), Windows and Linux support it, but I'm not sure where to buy one such drive.

There are no problem at the driver API level where we just use off_t, so it is up to each driver to do the conversion from off_t to blocks. But we should also make sure to keep reads and writes aligned to sectors (which I think we can do using the block cache and DMA constraints).

comment:4 by waddlesplash, 17 months ago

The SATA driver is also not currently able to handle sectors if size other than 512.

Indeed I see some things that hardcode 512. But it appears the driver does check the device-reported sector size. Maybe an easy fix?

Note: See TracTickets for help on using tickets.