Advanced Format - ArchWiki

Jump to content

# Advanced Format

From ArchWiki

This article or section is a candidate for moving to Storage layout and alignment.

Notes: "Advanced Format" is HDD-specific. (Discuss in Talk:Advanced Format#Rewrite Advanced Format to a new Sector Sizes page)

The minimum physical storage unit of a hard disk drive (HDD) is a sector. The solid state drive (SSD) equivalent is a page.[1] Storage device firmware abstract away their physical sectors into logical sectors that software can operate on. The size of this sector refers to the size of the smallest addressable unit on the disk.

Note Software and documentation may sometimes refer to "sectors" and "blocks" interchangeably, regardless of the storage type.

Physical sector size
  This is the smallest unit a physical storage device claims it can write atomically. For HDDs, it is the actual size of sectors in a platter. Traditionally, the physical sector size for HDDs was 512 bytes, meaning that each sector could hold 512 bytes of data. However, with the introduction of Advanced Format HDDs, the physical sector size was increased to 4096 bytes (4 KiB) for increased storage density and improved error correction capabilities. SSDs do not expose their actual NAND flash memory page size, which typically ranges from 4 KiB to 16 KiB, instead their reported physical sector size is the same as their logical sector size. For NVMe SSDs, if it is available, the Atomic Write Unit Power Fail (AWUPF) parameter value is used.
Logical sector size
  The logical sector size, also known as the operating system sector size, represents the size of the sectors exposed to the operating system and applications. It is the sector size used for reading from and writing to the storage device at the software level. The logical sector size can differ from the physical sector size. For example, an Advanced Format HDD with a physical sector size of 4096 bytes may still present a logical sector size of 512 bytes for compatibility with older systems and applications.

The different "layers", namely the device, stacked block devices, and file systems, should utilize the same sector sizes. If they do not, the mapping process from the firmware's translation layer, although usually transparent, will result in overhead that can be avoided.

You can check the reported logical and physical sector sizes of storage devices with lsblk:

    $ lsblk -td

    NAME    ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE  RA WSAME
    sda             0   4096      0    4096    4096    1 mq-deadline      64 128    0B
    nvme1n1         0   4096      0    4096    4096    0 none           1023 128    0B
    nvme0n1         0   4096      0    4096    4096    0 none           1023 128    0B

- `LOG-SEC` is the logical sector size (addressable unit used by the operating system).
- `PHY-SEC` is the physical sector size as reported by the device.

Note On NVMe SSDs, the `PHY-SEC` value typically mirrors the logical sector size and does not reflect the true physical write granularity (e.g., NAND page size or atomic write unit). Most consumer NVMe drives do not expose this information through standard interfaces. The NVMe 1.2a specification defines AWUPF as indexed by logical block units and warns that AWUPF may be zero, and a zero does not represent physical NAND page size.

Alternatively, `sysfs` entries can be queried:

    $ cat /sys/class/block/drive/queue/physical_block_size
    $ cat /sys/class/block/drive/queue/logical_block_size

Sector sizes can also be seen in fdisk, smartctl and hdparm output.

These values again reflect what the device reports but may not be accurate for SSDs or NVMe drives, which often abstract or omit true physical characteristics.

For more detailed information on NVMe drives, such as supported LBA formats and atomic write unit granularity (if available), the following NVMe CLI commands may help:

    # nvme id-ns /dev/nvme0n1 | grep -i lbaf
    # nvme id-ctrl /dev/nvme0n1 | grep -i awupf

However, many drives will show only a single LBA format (e.g., `lbads:9`, meaning 512-byte logical blocks), and an `awupf` value of `0`, indicating no atomic write unit information is provided.

Tip For true NAND write sizes and optimal alignment, refer to the manufacturer’s datasheet if available, as it may not be reported via software tools.

## Changing sector size

Warning Changing a drive's sector size will irrevocably erase all the data on the drive.

Some NVMe drives and "enterprise" SATA hard disk drives support changing their reported sector size using standard NVMe (`Format NVM` from NVM Command Set Specification 1.0 or later) or ATA (`SET SECTOR CONFIGURATION EXT` from ATA Command Set - 4 or later) commands, respectively. For hard disk drives this changes the logical sector size in order to match the physical sector size for optimal performance. While for NVMe solid state drives, both the reported logical and physical sector size values get changed.

SATA solid state drives typically do not support changing their sector size. Exception are certain Intel SATA SSDs that can change the reported physical sector size, but not the logical sector size.[2] Follow #Intel to change their reported physical sector size.

Changing the sector size of a drive is a complex process that requires low-level formatting. As an alternative, you can manually specify the desired sector size when creating file systems on the drive to get optimal performance. See #dm-crypt and #File systems.

### Advanced Format hard disk drives

To determine if the sector size of an Advanced Format hard disk drive can be changed, use the hdparm utility:

    # hdparm -I /dev/sdX | grep 'Sector size:'

Note For USB-attached drives, the USB bridge needs to support SAT aka SCSI/ATA Translation (ANSI INCITS 431-2007).
Warning Even if a USB-attached drive reports support for a different sector size and can pass through commands, it is possible that changing the sector size renders the drive unusable afterwards (to the point where it will not attach and no further commands can be sent), as consumer-grade USB bridges may not support different sector sizes. See for example [3], which is still actual for Western Digital drives as of November 2025.

Advanced Format drives whose Sector Configuration Log lists multiple logical sector sizes will show a list of them:

            Logical  Sector size:                   512 bytes [ Supported: 512 4096 ]
            Physical Sector size:                  4096 bytes

Hard disk drives which do not support multiple changeable logical sector sizes will simply report the current sector sizes. E.g., an Advanced Format 512e drive:

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

For optimal performance on these types of drives, ensure the #dm-crypt sector size or #File systems block size is at least 4096 bytes and aligns to it.

An Advanced Format 4Kn drive:

            Logical  Sector size:                  4096 bytes
            Physical Sector size:                  4096 bytes

4Kn drives already have the optimal configuration out of the box and do not need special considerations when partitioning/formatting. They can be simply used as is.

If your SATA HDD supports multiple logical sector sizes and the optional ATA command `SET SECTOR CONFIGURATION EXT` (usually only available in so-called "enterprise" class HDDs), you can use hdparm to change between the supported logical sector sizes.

To set it to 4096 bytes, i.e. 4Kn, run:

    # hdparm --set-sector-size 4096 --please-destroy-my-drive /dev/sdX

Afterwards, hdparm should report the logical sector size as 4096 bytes:

    # hdparm -I /dev/sdX | grep 'Sector size:'

            Logical  Sector size:                  4096 bytes [ Supported: 512 4096 ]
            Physical Sector size:                  4096 bytes

### NVMe solid state drives

Most solid state drives (SSDs) report their logical block address size as 512 bytes, even though they use larger blocks physically—typically 4 KiB, 8 KiB, or sometimes larger.

To check the formatted logical block address size (FLBAS) of an NVMe drive, use the nvme-cli utility in addition with Identify Namespace command:

    # nvme id-ns -H /dev/nvme0n1 | grep "Relative Performance"

    LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x2 Good (in use)
    LBA Format  1 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0x1 Better

- `Metadata Size` is the number of extra metadata bytes per logical block address (LBA). As this is not well supported under Linux, it is best to select a format with a value of 0 here.
- `Relative Performance` indicates which format will provide degraded, good, better or best performance.

smartctl can also display the supported logical block address sizes, but it does not provide user friendly descriptions. E.g.:

    # smartctl -c /dev/nvme0n1

    ...
    Supported LBA Sizes (NSID 0x1)
    Id Fmt  Data  Metadt  Rel_Perf
     0 +     512       0         2
     1 -    4096       0         1

Warning Some NVMe SSDs report they support 4 KiB sectors but encounter sporadic instability upon enabling them, especially under heavy random read loads.[4][5] Make sure to test the new configuration thoroughly before storing data you cannot afford to lose on it. If encountering this issue, simply revert back to a 512 byte sector configuration.

To change the logical block address size, use `nvme format` and specify the preferred value with the `--lbaf` parameter:

    # nvme format --lbaf=1 /dev/nvme0n1

    You are about to format nvme0n1, namespace 0x1.
    WARNING: Format may irrevocably delete this device's data.
    You have 10 seconds to press Ctrl-C to cancel this operation.

    Use the force [--force] option to suppress this warning.
    Sending format operation ...
    Success formatting namespace:1

This should take just a few seconds to proceed.

Note Make sure to follow #Partition alignment when partitioning, otherwise any performance benefit will be void.

### Using manufacturer specific programs

If the above generic utilities do not allow changing the sector size, it may still be possible to change it using a utility from the drive's manufacturer.

#### Intel

For Intel use the Intel Memory and Storage (MAS) Tool (intel-mas-cli-toolAUR) with the `-set PhysicalSectorSize=4096` option. Notice that only reported physical sector size will be changed, logical sector size will remain the same.

Note Ever since Intel's SSD business was bought by SK Hynix under the Solidigm brand, Intel MAS cannot be used to manage SSDs, only Optane products. Solidigm provides solidigm-sst-storage-tool-cliAUR to perform the same functions Intel MAS used to offer; see Solid state drive/NVMe#Intel/Solidigm.

#### Seagate

Seagate provides openseachestAUR. The utilities can be used on non-Seagate drives too since they use standard ATA and NVMe commands.

Scan all drives to find the correct one, and print info from the one you found:

    # openSeaChest_Basics --scan
    # openSeaChest_Basics -d /dev/sdX -i

Should print out information about the drive. Make sure to check the serial number.

Check the logical block sizes supported by the drive:

    # openSeaChest_Format -d /dev/sdX --showSupportedFormats

If 4096 is listed, you can change the logical sector size to it as follows:

Warning Seagate warns that any interruption to the operation may render the drive inoperable, and thus recommends minimizing all disk activities for the time (other drives as well, as they might compete for disk controller resources). The safest is to do this from a live USB where there are no extra background processes.

    # openSeaChest_Format -d /dev/sdX --setSectorSize=4096 --confirm this-will-erase-data-and-may-render-the-drive-inoperable

This will take a couple of minutes, after which your drive now uses a 4 KiB native sector size.

## Partition alignment

Aligning partitions correctly avoids excessive read-modify-write cycles. A typical practice for personal computers is to have each partition's start and size aligned to 1 MiB (1 048 576 bytes) marks. This covers all common page and block size scenarios, as it is divisible by all commonly used sizes—1 MiB, 512 KiB, 128 KiB, 4 KiB, and 512 B.

Warning Misaligned partitions will prevent being able to use 4096 byte sectors with dm-crypt/LUKS. See [6].

- fdisk, cfdisk and sfdisk handle alignment automatically.
- gdisk and cgdisk handle alignment automatically.
  - sgdisk by default only aligns the start of partitions. Use the `-I`/`--align-end` option to additionally enable partition size/end alignment.
- Parted only aligns the start of the partition, but not the size/end. When creating partitions, make sure to specify the partition end in mebibytes or a larger IEC binary unit.

checkpartitionsalignment.sh is a bash script that checks for alignment using Parted and awk.

## dm-crypt

This article or section needs expansion.

Reason: Add example for plain dm-crypt. (Discuss in Talk:Advanced Format)

As of Cryptsetup 2.4.0, `luksFormat` automatically detects the optimal encryption sector size for LUKS2 format [7].

However, for this to work, the device needs to report the correct default sector size, see #Changing sector size.

Tip Cryptsetup strongly recommends changing the drive's logical sector size to 4096 bytes for encryption performance.[8]

After using `cryptsetup luksFormat`, you can check the sector size used by the LUKS2 volume with

    # cryptsetup luksDump device | grep sector

If the default sector size is incorrect, you can force create a LUKS2 container with a 4 KiB sector size and otherwise default options with:

    # cryptsetup luksFormat --sector-size=4096 device

The command will abort on an error if the requested size does not match your device:

    # cryptsetup luksFormat --sector-size 4096 device
    (...)
    Verify passphrase:
    Device size is not aligned to requested sector size.

Note See cryptsetup issue 585 for why the command may fail while the underlying drive does use 4 KiB physical sectors.

If you encrypted your device with the wrong sector size, the device can be re-encrypted by running:

Warning The contained file system must have a block size of 4096 bytes or a multiple of it, otherwise it will break.

    # cryptsetup reencrypt --sector-size=4096 device

## File systems

This article or section needs expansion.

Reason: Differentiate which mkfs utilities use 4096 explicitly and which use the page size (`getconf PAGESIZE`). (Discuss in Talk:Advanced Format)

On 4Kn disks (4096 byte physical sector size and 4096 byte logical sector size) all mkfs utilities will use a block size of 4096 bytes. On 512e (4096 byte physical sector size, 512 byte logical sector size) and 512n (512 byte physical sector size and 512 byte logical sector size) disks, each mkfs utility behaves differently.

File system block size in bytes on non-4Kn disks
mkfs utility | 512e disk | 512n disk
--- | --- | ---
mkfs.bcachefs | 4096 | 4096
mkfs.btrfs(8) | 4096 | 4096
mkfs.exfat(8) | 512 | 512
mkfs.ext4(8) | 40961 | 40961
mkfs.fat(8) | 512 | 512
mkfs.f2fs(8) | 4096 | 4096
mkfs.jfs(8) | 4096 | 4096
mkfs.nilfs2(8) | 4096 | 4096
mkfs.ntfs(8) | 512 | 512
mkfs.udf(8) | 512 | 512
mkfs.xfs(8) | 4096 | 512
mkswap(8) | 4096 | 4096
zpool-create(8) | 512 | 512

1. mkfs.ext4(8) defaults to 1024 byte sectors for file systems smaller than 512 MiB and 4096 byte sectors for 512 MiB and larger.

If the storage device does not report the correct sector size, you can explicitly format the partitions according to the physical sector size.

In particular shingled magnetic recording (SMR) drives that are firmware-managed are severely and negatively impacted if using a logical sector size of 512 bytes if their physical sector size is of 4096 bytes. Those drives have different performance writing zones and remapping reallocation occurs while being idle, but during heavy active writes (e.g., RAID resilvering, backups, writing many small files, rsync, etc.), a different file system sector size could drop write speed to single digit megabytes/second, as the higher performance write areas get depleted, and the sector translation layer gets overworked on the shingled areas.

Here are some examples to set the 4096-byte sector size explicitly:

- exFAT:

      # mkfs.exfat -s 4096 /dev/device

- ext4:

      # mkfs.ext4 -b 4096 /dev/device

- FAT:

      # mkfs.fat -S 4096 /dev/device

- NTFS-3G:

      # mkfs.ntfs -Q -s 4096 /dev/device

- UDF:

      # mkfs.udf -b 4096 /dev/device

- XFS:

      # mkfs.xfs -s size=4096 /dev/device

- ZFS:

      # zpool create -o ashift=12 poolname raidz device0 … deviceN

## Known issues

### Syslinux and FAT

Syslinux does not support FAT file systems with a sector size other than 512 bytes.

## Troubleshooting

### NVMe drives fail to format

This article or section needs language, wiki syntax or style improvements. See Help:Style for reference.

Reason: There is no need for subsections. (Discuss in Talk:Advanced Format)

Some NVMe drives do not support the `nvme format` command, which is required to change the sector size (LBA format). This is still compliant with the NVMe specification. The issue may also present itself as `INVALID_OPCODE(2001)` or `INVALID_FORMAT: The LBA Format specified is not supported. This may be due to various conditions(0x10a)`. If this is the case, review the links under References below.

To check whether your drive supports the Format NVM command:

    # nvme id-ctrl /dev/nvme0 | grep oacs

Look at the `oacs` field (Optional Admin Command Support), which is a bitmask. Format NVM support corresponds to bit 1 (value `0x02`). If bit 1 is not set, your controller does not support Format NVM and you will not be able to change the LBA format.

Example (Format NVM not supported):

    oacs      : 0x1d

Convert `0x1d` to binary: `0001 1101` → Bit 1 is not set (second bit from the right is 0) → Format NVM is not supported

In some cases, formatting still fails even when Format NVM is supported. This is commonly seen on drives using Pyrite but notably not OPAL security, especially on Intel platforms using S0ix (Modern Standby). In other cases, `oacs` may report Format NVM as unsupported, yet formatting works after a suspend/resume cycle.

#### Workarounds

- Disable S0ix (Modern Standby) in firmware (set sleep mode to S3 / S2idle)
- Add kernel parameter: `mem_sleep_default=s2idle`
- Suspend/resume the system before formatting

#### Affected models

Known on Hynix PC601, Lenovo and Dell laptops, Samsung and WD SN750 drives.

#### References

- github.com/nvme-cli#84
- github.com/nvme-cli#816
- SanDisk Forum: SN750
- Lenovo Forum: 4Kn format issue

## See also

- Western Digital’s Advanced Format: The 4K Sector Transition Begins
- White paper entitled "Advanced Format Technology."
- Failure to align one's HDD results in poor read/write performance. See [9] for specific examples.

Category:

- Storage

Hidden categories:

- Pages or sections flagged with Template:Move
- Pages or sections flagged with Template:Expansion
- Pages or sections flagged with Template:Style

Advanced Format
Add topic