Solid state drive/NVMe
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.
Installation
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.
Management
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
List information about a namespace and features it supports:
# nvme id-ns /dev/nvme0n1
Output the NVMe error log page:
# nvme error-log /dev/nvme0
Delete a namespace:
# 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 and for a list of all commands along with a terse description.
SMART
Output the NVMe SMART log page for health status, temp, endurance, and more:
# nvme smart-log /dev/nvme0
NVMe support was added to smartmontools in version 6.5.
Currently implemented features (as taken from the wiki):
- Basic information about controller name, firmware, capacity ()
- Controller and namespace capabilities ()
- SMART overall-health self-assessment test result and warnings (
smartctl -H
) - NVMe SMART attributes ()
- NVMe error log ()
- Ability to fetch any nvme log ()
- The smartd daemon tracks health (), error count () 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
Generic
Firmware can be managed using nvme-cli. To display available slots and check whether Slot 1 is read only:
Download and commit firmware to specified slot. In the example below, firmware is first committed without activation (). Next, an existing image is activated (). Refer to the NVMe specification for details on firmware commit action values.
# nvme fw-log /dev/nvme0
Firmware Log for device:nvme0 afi : 0x21 frs1 : 0x32303132345a3553 (S5Z42102) frs2 : 0x35303132345a3553 (S5Z42105)
Finally reset the controller to load the new firmware
# echo 1 > /sys/class/nvme/nvme0/reset_controller
Intel
"The Intel® Memory and Storage Tool (Intel® MAS) is a drive management tool for Intel® SSDs and Intel® Optane™ Memory devices, supported on Windows*, Linux*, and ESXi*. [...] Use this tool to manage PCIe*-/NVMe*- and SATA-based Client and Datacenter Intel® SSD devices and update to the latest firmware."
Install /intel-mas-cli-toolAUR and check whether your drive has an update available:
If so, execute the command as follows:
Kingston
Kingston does not provide separate firmware downloads on their website, instead referring users to a Windows only utility. Firmware files appear to use a predictable naming scheme based on the firmware revision:
https://media.kingston.com/support/downloads/S5Z42105.zip
Then proceed with the generic flashing instructions.
Performance
Sector size
Discards
Discards are disabled by default on typical setups that use ext4 and LVM, but other file systems might need discards to be disabled explicitly.
Intel, as one device manufacturer, recommends not to enable discards at the file system level, but suggests the periodic TRIM method, or apply manually.
Airflow
NVMe SSDs are known to be affected by high operating temperatures and will throttle performance over certain thresholds.
Testing
Raw device performance tests can be run with :
# hdparm -Tt --direct /dev/nvme0n1
Power Saving (APST)
To check NVMe power states, install nvme-cli or , and run :
# 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 (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 kernel module. This should enable APST and make the table in (as the root user) show the entries.
Troubleshooting
Controller failure due to broken APST support
Some NVMe devices may exhibit issues related to power saving (APST). This is a known issue for Kingston A2000 as of firmware S5Z42105 and has previously been reported on Samsung NVMe drives (Linux v4.10)
A failure renders the device unusable until system reset, with kernel logs similar to:
nvme nvme0: I/O 566 QID 7 timeout, aborting nvme nvme0: I/O 989 QID 1 timeout, aborting nvme nvme0: I/O 990 QID 1 timeout, aborting nvme nvme0: I/O 840 QID 6 timeout, reset controller nvme nvme0: I/O 24 QID 0 timeout, reset controller nvme nvme0: Device not ready; aborting reset, CSTS=0x1 ... nvme nvme0: Device not ready; aborting reset, CSTS=0x1 nvme nvme0: Device not ready; aborting reset, CSTS=0x1 nvme nvme0: failed to set APST feature (-19)
As a workaround, add the kernel parameter to completely disable APST, or set a custom threshold to disable specific states.
Since March 2021 a firmware update 9 from Kingston is available. As Kingston only supports Windows, downloads for Linux can be found via heise.de or github. It is expected that, as long as the kernel workaround is in place, the firmware update will not do much as the deepest powersaving states are not reached anyway.
The value passed is the maximum exit latency (Ex_Lat). For example, to disable PS4 set .
Controller failure due to broken suspend support
Some users (for example, see Laptop/HP) have reported suspend failures with certain NVMe drives. As above, the failure renders the device inoperable until system reset, with kernel messages
nvme nvme0: Device not ready; aborting reset, CSTS=0x3 nvme nvme0: Removing after probe failure status: -19
As a workaround, add the kernel parameter to use a software replacement for the hardware IOMMU. (For further details, see this documentation.) This has the potential to cause some slight processing overhead.