Skip to main content

4K NVMe Formatting: Boosting Performance

·445 words·3 mins
Stanislav Cherkasov
Author
Stanislav Cherkasov
{DevOps,DevSecOps,Platform} Engineer
Table of Contents
homelab - This article is part of a series.
Part : This Article

NVMe Block Size: 512 vs 4096 Bytes (Advanced Format)
#

Advanced Format is an industry term that refers to storage devices utilizing a physical sector size of 4096 bytes (4KiB), as opposed to the legacy 512-byte sectors. The motivation is to improve areal density, error correction efficiency, and overall storage reliability.

  • 512n (512 native): Both physical and logical sectors are 512 bytes (rarely used in modern devices).
  • 512e (512 emulation): The drive has a physical sector size of 4096 bytes but emulates 512-byte logical sectors for backward compatibility.
  • 4Kn (4096 native): Both physical and logical sectors are 4096 bytes.

NVMe LBA Formats
#

NVMe namespaces support multiple LBA formats (LBAF), as reported by the device. These can be queried using

nvme list
Node         Generic    SN Model  Namespace Usage            Format           FW Rev
--------------------------------- --------- ---------------- ---------------- --------
/dev/nvme0n1 /dev/ng0n1 99 XX     1         4.00 TB/4.00 TB  512   B +  0 B   L88888888
nvme id-ns -H /dev/nvme0n1 | grep '^LBA Format'
LBA Format 0: Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0x1 Better (in use)
LBA Format 1: Metadata Size: 0 bytes - Data Size: 4096 bytes - Relative Performance: 0 Best

Sometimes it’s not available:

nvme id-ns -H /dev/nvme7n1 | grep '^LBA Format'
LBA Format 0 : Metadata Size: 0 bytes - Data Size: 512 bytes - Relative Performance: 0 Best (in use)

ACHTUNG: Changing the LBA format typically requires a namespace reformat operation, which destroys all user data.

Technical Considerations and LVM Limitations
#

  • 4K sector (4096 bytes): Preferred for modern operating systems and applications. It reduces metadata overhead and increases efficiency in ECC and internal flash management (lower write amplification).
  • 512B sector (512 bytes): Maintained solely for backward compatibility with legacy systems and software that require 512-byte sectors.
  • When using LVM, ensure all physical volumes (PVs) are created on block devices with the same sector size. LVM migration (e.g., pvmove, lvconvert –merge, or extending a VG across multiple devices) will fail if the underlying block sizes differ (e.g., mixing 512B and 4K LBAs).

Implementation
#

Configure 4k format:

nvme format /dev/nvme0n1 --lbaf=1

Check:

nvme id-ns -H /dev/nvme0n1 | grep '^LBA Format'
LBA Format  0 : Metadata Size: 0   bytes - Data Size: 512 bytes - Relative Performance: 0x1 Better
LBA Format  1 : Metadata Size: 0   bytes - Data Size: 4096 bytes - Relative Performance: 0 Best (in use)
nvme list
Node         Generic    SN           Model          Namespace     Usage      Format           FW Rev
------------ ---------- ------------ -------------- --------- ---------------------- ----------------
/dev/nvme0n1 /dev/ng0n1 999999999999 CT4000T700SSD3     1     4.00TB/4.00TB  4 KiB +  0 B   P8888888

All done.

SpeedTest ( raw disk )
#

TBD ( fio )

SpeedTest ( ext4 )
#

TBD ( fio )

homelab - This article is part of a series.
Part : This Article