Solid state drive/NVMe

From ArchWiki
Jump to navigation Jump to search

NVM Express (NVMe) is a specification for accessing SSDs attached through the PCI Express bus. As a logical device interface, NVM Express has been designed from the ground up, capitalizing on the low latency and parallelism of PCI Express SSDs, and mirroring the parallelism of contemporary CPUs, platforms and applications.


The Linux NVMe driver is natively included in the kernel since version 3.3. NVMe devices should show up under /dev/nvme*.

Extra userspace NVMe tools can be found in nvme-cli or nvme-cli-gitAUR.

See Solid State Drives for supported filesystems, maximizing performance, minimizing disk reads/writes, etc.


Note: This section was adapted from [1].

List all the NVMe SSDs attached with name, serial number, size, LBA format and serial:

# nvme list

List information about a drive and features it supports in a human-friendly way:

# nvme id-ctrl -H /dev/nvme0
Tip: In order to make sense of the abbreviations used, see reference section ("Identify Controller data structure") in the relevant NVMe spec, e.g. bottom of p. 172 for the latest 1.4a spec.

List information about a namespace and features it supports:

Note: Namespaces are the construct in NVMe technology that hold user data. An NVMe controller can have multiple namespaces attached to it. Most NVMe SSDs today just use a single namespace, but multi-tenant applications, virtualization and security have use cases for multiple namespaces.
# nvme id-ns /dev/nvme0n1
Tip: In order to make sense of the abbreviations used, see reference section ("Identify Namespace data structure") in the relevant NVMe spec (e.g. p. 163 for the latest 1.4a spec).

Output the NVMe error log page:

# nvme error-log /dev/nvme0
Tip: Look for output where error count does not equal 1 to find out if there are any errors in the error log.

Delete a namespace:

Warning: This command will delete all data on the specified namespace. Use with caution!
# nvme delete-ns /dev/nvme0n1

Create a new namespace, e.g creating a smaller size namespace to overprovision an SSD for improved endurance, performance, and latency:

# nvme create-ns /dev/nvme0

See nvme help and nvme(1) for a list of all commands along with a terse description.


Output the NVMe SMART log page for health status, temp, endurance, and more:

# nvme smart-log /dev/nvme0
Tip: Use the -H option to output even more information, e.g. nvme smart-log -H /dev/nvme0.

NVMe support was added to smartmontools in version 6.5 (available since May 2016 in the official repositories).

Note: smartmontools official wiki reports this support as experimental.

Currently implemented features (as taken from the wiki):

  • Basic information about controller name, firmware, capacity (smartctl -i)
  • Controller and namespace capabilities (smartctl -c)
  • SMART overall-health self-assessment test result and warnings (smartctl -H)
  • NVMe SMART attributes (smartctl -A)
  • NVMe error log (smartctl -l error[,NUM])
  • Ability to fetch any nvme log (smartctl -l nvmelog,N,SIZE)
  • The smartd daemon tracks health (-H), error count (-l error) and temperature (-W DIFF,INFO,CRIT)

See S.M.A.R.T. and the official wiki entry for more information, and see this article for contextual information about the output.

Secure erase

See Solid state drive/Memory cell clearing#NVMe drive.


Sector size

See Advanced Format#How to determine if HDD employ a 4k sector.


Note: Although continuous TRIM is an option (albeit not recommended) for SSDs, NVMe devices should not be issued discards.

Discards are disabled by default on typical setups that use ext4 and LVM, but other filesystems might need discards to be disabled explicitly.

Intel, as one device manufacturer, recommends not to enable discards at the filesystem level, but suggests the periodic TRIM method, or apply fstrim manually.[2]


NVMe SSDs are known to be affected by high operating temperatures and will throttle performance over certain thresholds.[3]


Raw device performance tests can be run with hdparm:

# hdparm -Tt --direct /dev/nvme0n1

Power Saving APST

NVME Power Saving Patch

Andy Lutomirski has created a patchset which fixes powersaving for NVME devices in linux. The patch has been merged into mainline kernel v4.11.

To test if NVME Power Management is working, install nvme-cli or nvme-cli-gitAUR, and run nvme get-feature /dev/nvme[0-9] -f 0x0c -H:

# nvme get-feature /dev/nvme0 -f 0x0c -H
get-feature:0xc (Autonomous Power State Transition), Current value:0x000001
        Autonomous Power State Transition Enable (APSTE): Enabled
        Auto PST Entries        .................


When APST is enabled the output should contain "Autonomous Power State Transition Enable (APSTE): Enabled" and there should be non-zero entries in the table below indicating the idle time before transitioning into each of the available states.

If APST is enabled but no non-zero states appear in the table, the latencies might be too high for any states to be enabled by default. The output of nvme id-ctrl /dev/nvme[0-9] (as the root user) should show the available non-operational power states of the NVME controller. If the total latency of any state (enlat + xlat) is greater than 25000 (25ms) you must pass a value at least that high as parameter default_ps_max_latency_us for the nvme_core kernel module. This should enable APST and make the table in nvme get-feature (as the root user) show the entries.

Samsung drive errors on Linux 4.10

On Linux 4.10, drive errors can occur and causing system instability. This seems to be the result of a power saving state that the drive cannot use. Adding the kernel parameter nvme_core.default_ps_max_latency_us=5500[4][5] disables the lowest power saving state, preventing write errors.