ArchWiki / Advanced Format
ArchWiki / Advanced Format
es:Advanced Format hu:Advanced Format ja:アドバンスドフォーマット ru:Advanced Format tr:Advanced Format zh-hans:先进格式化 The minimum physical storage unit of a hard disk drive (HDD) is a sector. The solid state drive (SSD) equivalent is a page.https://www.oo-software.com/en/docs/whitepaper/whitepaper_ssd.pdf 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.
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:
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$ lsblk -tdLOG-SECis the logical sector size (addressable unit used by the operating system).PHY-SECis the physical sector size as reported by the device.
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_sizeSector 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 awupfHowever, 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.
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
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.https://superuser.com/q/982680 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:'For USB-attached drives, the USB bridge needs to support SAT aka SCSI/ATA Translation (ANSI INCITS 431-2007).
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 https://forum.level1techs.com/t/psa-dont-change-sector-size-of-external-usb-wd-drives/191317, 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 bytesHard 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 bytesFor 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 bytes4Kn 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/sdXAfterwards, hdparm should report the logical sector size as 4096 bytes:
Logical Sector size: 4096 bytes [ Supported: 512 4096 ]
Physical Sector size: 4096 bytes# hdparm -I /dev/sdX grep 'Sector size:'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:
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# nvme id-ns -H /dev/nvme0n1 grep "Relative Performance"Metadata Sizeis 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 Performanceindicates 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.:
...
Supported LBA Sizes (NSID 0x1)
Id Fmt Data Metadt Rel_Perf
0 + 512 0 2
1 - 4096 0 1# smartctl -c /dev/nvme0n1Some NVMe SSDs report they support 4 KiB sectors but encounter sporadic instability upon enabling them, especially under heavy random read loads.https://bbs.archlinux.org/viewtopic.php?pidhttps://halestrom.net/darksleep/blog/054_nvme/ 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:
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# nvme format --lbaf=1 /dev/nvme0n1This should take just a few seconds to proceed.
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-tool) with the -set PhysicalSectorSize=4096 option. Notice that only reported physical sector size will be changed, logical sector size will remain the same.
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-cli to perform the same functions Intel MAS used to offer; see Solid state drive/NVMe#Intel/Solidigm.
Seagate
Seagate provides openseachest. 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 -iShould 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 --showSupportedFormatsIf 4096 is listed, you can change the logical sector size to it as follows:
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-inoperableThis 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.
Misaligned partitions will prevent being able to use 4096 byte sectors with dm-crypt/LUKS. See https://lore.kernel.org/dm-crypt/fe8cd3b4-6d50-66d3-375c-254e278a6443@gmail.com/.
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-endoption 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
As of Cryptsetup 2.4.0, luksFormat automatically detects the optimal encryption sector size for LUKS2 format https://mirrors.edge.kernel.org/pub/linux/utils/cryptsetup/v2.4/v2.4.0-ReleaseNotes.
However, for this to work, the device needs to report the correct default sector size, see #Changing sector size.
Cryptsetup strongly recommends changing the drive's logical sector size to 4096 bytes for encryption performance.https://cdn.kernel.org/pub/linux/utils/cryptsetup/v2.8/v2.8.0-ReleaseNotes
After using cryptsetup luksFormat, you can check the sector size used by the LUKS2 volume with
# cryptsetup luksDump device | grep sectorIf 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 deviceThe 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.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:
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 deviceFile systems
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.
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/deviceext4:
# mkfs.ext4 -b 4096 /dev/deviceFAT:
# mkfs.fat -S 4096 /dev/device# mkfs.ntfs -Q -s 4096 /dev/deviceUDF:
# mkfs.udf -b 4096 /dev/deviceXFS:
# mkfs.xfs -s size=4096 /dev/deviceZFS:
# zpool create -o ashift12 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
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 oacsLook 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 : 0x1dConvert 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_defaults2idleSuspend/resume the system before formatting
Affected models
Known on Hynix PC601, Lenovo and Dell laptops, Samsung and WD SN750 drives.
References
See also
Western Digital’s Advanced Format: The 4K Sector Transition Begins
Failure to align one's HDD results in poor read/write performance. See https://linuxconfig.org/linux-wd-ears-advanced-format for specific examples.