Last updated: 2026-08-20
HARDWARE & ARCHITECTURE

NVMe storage architecture & nvme-cli reference

Category: Physical Storage StandardsSpecification: NVM Express 1.4 / 2.0Driver: drivers/nvme/host/

NVM Express (NVMe) is the open standard interface developed from the ground up for solid-state storage attached via the PCIe bus. Unlike legacy SATA/AHCI which was limited to a single command queue with 32 commands, NVMe supports up to 65,535 parallel I/O queues with up to 64K (65,536) commands per queue, unlocking multi-gigabyte/sec throughput and millions of IOPS on modern Linux systems.

NVMe architectural hierarchy

The Linux NVMe kernel subsystem organizes storage hardware into three distinct entities:

4Kn vs 512e: Native sector format switching

Drives formatted with 512-byte emulation (512e) force the internal Flash Translation Layer (FTL) to perform 4K read-modify-write cycles when writing unaligned blocks. Combining native 4096-byte (4Kn) sectors with 1MiB partition alignment aligns the OS block layer directly with physical flash pages. For maximum bandwidth, pair 4Kn formatting with the none I/O scheduler and configure automated SSD TRIM / discard commands.

# 1. Inspect supported LBA formats on target namespace
sudo nvme id-ns -H /dev/nvme0n1 | grep -A 10 "LBA Format"

# Example output:
# 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

# 2. Reformat namespace to LBA Format 1 (4Kn) [Destroys all data!]
sudo nvme format /dev/nvme0n1 --namespace-id=1 --lbaf=1 --force

# 3. Confirm 4096 physical and logical block sizes
sudo blockdev --getss --getpbsz /dev/nvme0n1

Essential nvme-cli command reference

CommandDescription & Operational Usage
nvme listLists all NVMe controllers, active namespaces, capacities, formats, and firmware versions.
nvme smart-log /dev/nvme0Displays detailed health telemetry: temperature sensors, composite temperature, wear percentage, spare capacity, and unsafe shutdowns.
nvme id-ctrl -H /dev/nvme0Dumps hardware controller capabilities: queue limits, maximum data transfer sizes (MDTS), sanitize features, and power states.
nvme error-log /dev/nvme0Retrieves controller hardware error log entries from internal non-volatile memory.
nvme sanitize /dev/nvme0 -a 2Initiates hardware cryptographic erase across all namespaces and overprovisioned flash (NIST 800-88).
nvme fw-download /dev/nvme0 -f fw.binDownloads new firmware payload binary into controller staging buffer.
nvme fw-commit /dev/nvme0 -s 2 -a 3Commits and activates staged firmware without requiring a physical host reboot.

Host Memory Buffer (HMB) management

On consumer and edge DRAM-less SSDs, Linux automatically allocates host RAM for HMB. Verify HMB allocation via sysfs:

# Check whether HMB is enabled for this controller (1 = enabled, 0 = disabled)
cat /sys/class/nvme/nvme0/hmb

# Disable HMB if diagnosing PCIe DMA instability
echo 0 | sudo tee /sys/class/nvme/nvme0/hmb

To continuously track drive health and wear percentage, see the SMART Monitoring Guide. To measure true hardware throughput and IOPS ceilings, follow the fio Disk Performance Benchmarking Guide.

Frequently asked questions

Why should you format NVMe drives to native 4Kn instead of 512e?

Most consumer and enterprise SSDs ship in 512-byte emulation (512e) mode for legacy OS compatibility. Formatting to native 4096-byte (4Kn) sectors eliminates the SSD controller Flash Translation Layer (FTL) translation overhead, reducing metadata write amplification, eliminating read-modify-write penalties, and increasing random 4K write throughput by 10-25%.

What is an NVMe Namespace?

An NVMe Namespace is a quantity of non-volatile memory that can be formatted into logical blocks. A single physical NVMe controller can expose multiple independent namespaces (e.g. /dev/nvme0n1, /dev/nvme0n2), which the Linux kernel treats as separate, isolated block devices.

What is Host Memory Buffer (HMB)?

HMB is an NVMe 1.2+ specification feature used primarily by DRAM-less SSDs. It allows the SSD controller to allocate a small chunk (typically 16-64 MB) of the host computer's system RAM via PCIe Direct Memory Access (DMA) to cache the FTL mapping table, delivering DRAM-class random I/O performance at lower hardware cost.

What is the difference between NVMe Format and NVMe Sanitize?

nvme format wipes user data and recreates the logical block address table. nvme sanitize (NVMe 1.3+) is a hardware-enforced cryptographic or physical block erase that operates across all user namespaces, overprovisioned reserve blocks, and retired bad sectors, meeting NIST 800-88 compliance.