6

I have a new 4 TB Western Digital SN850X NVMe SSD drive that I am trying to partition as a boot drive for Ubuntu 20.04. No matter what I do, fdisk reports that the partitions are misaligned, even though they appear to be aligned to both the logical (512 byte) and physical (8388608 byte) sector sizes:

$ sudo fdisk -l /dev/sda
Disk /dev/sda: 3.65 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model:                 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 8388608 bytes
I/O size (minimum/optimal): 8388608 bytes / 8388608 bytes
Alignment offset: 6832128 bytes
Disklabel type: gpt

Device      Start        End    Sectors  Size Type
/dev/sda1   16384     671743     655360  320M EFI System
/dev/sda2  671744 7814035455 7813363712  3.7T Linux filesystem

Partition 1 does not start on physical sector boundary.
Partition 2 does not start on physical sector boundary.

Note that partition 1 starts at sector 16384, exactly 8 MiB (16384 * 512) into the disk, which matches the physical sector size, but fdisk claims that it's misaligned by the strange value of 6832128 bytes.

parted align-check reports the same:

(parted) align-check
alignment type(min/opt)  [optimal]/minimal? minimal                       
Partition number? 1                                                       
1 not aligned: 16384s % 16384s != 13344s
(parted) align-check                                                      
alignment type(min/opt)  [optimal]/minimal? minimal                       
Partition number? 2                                                       
2 not aligned: 671744s % 16384s != 13344s

Here parted appears to be saying that the partitions are misaligned by 13344 sectors, which is 6832128 bytes, the same value reported by fdisk. But clearly "16384s % 16384s" is aligned.

Where is this bizarre misalignment value of 6832128 bytes / 13344 sectors coming from? Any suggestions / thoughts much appreciated!

3
  • 2
    head /sys/block/sda/*align* /sys/block/sda/queue/*size* (written from memory, list may be incomplete) It's not uncommon for these values to be reported wrong. Personally I ignore this altogether and just stick to plain old MiB alignment. Is there an USB enclosure involved? All the more reason to ignore it as they tend to report wrong values, too. Oct 17, 2022 at 0:23
  • 1
    Thanks -- there is indeed a USB enclosure. I'll try connecting directly to the laptop's NVMe port and see if that makes a difference in the reported "alignment offset" value. It's hard to believe that the reported offset of 6832128 bytes could actually be real.
    – David
    Oct 18, 2022 at 19:29
  • 1
    Use regular MiB alignment unless you can show that it actually makes a difference, so if in doubt - run a suitable benchmark. Oct 18, 2022 at 19:33

1 Answer 1

6

Note the text:

Alignment offset: 6832128 bytes

in the fdisk -l output.

This SuSE support article about partition alignment has this nugget of information on alignment offset:

There's one special case: When internal 4k block sizes were introduced, some HDD manufacturers actually addressed the classical DOS partition table misalignment by shifting the logical sector counting by one, so a start at sector 63 would translate to sector 64 (i.e. internal block 8). Some HDDs even were configurable with a switch to do this shifting by one. The SATA spec did even provide a mechanism for the drives to report such an offset, so the OS can take the appropriate steps to optimize performance. To our knowledge not many such drives exist; and only a subset of them reports the offset correctly.

If the drive reports any alignment offset, the Linux kernel in SLE11-SP1 (or later) will report this via the attribute /sys/block/$DEV/alignment_offset (in sectors).

So your disk seems to be a very special case: not only it seems to use 8 MiB physical blocks, the first block also has a non-uniform size of 6832128 bytes for some reason... assuming the reported information is correct.

Since Western Digital SN850X is a NVMe drive (as you correctly stated), the fact that you are accessing it as /dev/sda implies there is a converter device of some kind in between the PCIe bus and the drive: a directly-connected non-enterprise NVMe device would be presented as /dev/nvmeNn1 and its partitions as /dev/nvmeNn1pP instead of /dev/sd* (where N = the NVMe device number and P = partition number).

(In NVMe device names, the n1 is a namespace number: most non-enterprise NVMe devices support only a single namespace, but the device naming scheme is designed to support more than one. Think of namespaces as meta-partitions with potential for some enterprise storage features like snapshotting.)

1
  • 1
    Thanks for this information! So it seems to come down to whether I should trust this strange value reported by the hardware for the "alignment offset" or just ignore it as likely fictitious. You are correct that there is an intermediate device involved -- a USB NVMe enclosure. I will try connecting the drive directly to the NVMe port in the laptop and see if it still reports the same odd value for the alignment offset. If it doesn't, then I think I can safely conclude it wasn't real and that the partitions are in fact aligned correctly.
    – David
    Oct 18, 2022 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .