GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing wiki.archlinux.org — Advanced Format - ArchWiki 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.
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
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, $ 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.,
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 sizeWarning 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 ( 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 drivesTo 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 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
Be aware not all 512e HDD drive firmware allows sector size to be set with hdparm[4], but may exit with an error. The devices may allow it with other tools like openSeaChest. NVMe solid state drivesMost 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
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.[5][6] 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 --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 programsIf 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. IntelFor Intel use the Intel Memory and Storage (MAS) Tool (intel-mas-cli-toolAUR) with the 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.
SeagateSeagate 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 alignmentAligning 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 [7].
checkpartitionsalignment.sh is a bash script that checks for alignment using Parted and awk. dm-cryptAs of Cryptsetup 2.4.0, 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.[9]
After using # 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 systemsOn 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.
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:
Known issuesSyslinux and FATSyslinux does not support FAT file systems with a sector size other than 512 bytes. TroubleshootingNVMe drives fail to formatSome NVMe drives do not support the To check whether your drive supports the Format NVM command: # nvme id ctrl /dev/nvme0 | grep oacs Look at the Example (Format NVM not supported): oacs : 0x1d Convert 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, Workarounds
Affected modelsKnown on Hynix PC601, Lenovo and Dell laptops, Samsung and WD SN750 drives. ReferencesSee also
| ||||||||||||||||||||||||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |