NVM Express® (NVMe®) technology has enabled a robust set of industry-standard software, drivers, and management tools that have been developed for storage. The tool to manage NVMe SSDs in Linux is called NVMe Command Line Interface (NVMe-CLI).
Overview of features
Data centers require many management functions to monitor the health of the SSD, monitor endurance, update firmware, securely erase storage and read various logs. NVMe-CLI is an open-source, powerful feature set that follows the NVMe specification and is supported by all major distributions. It supports NVMe SSDs as well as NVMe over Fabrics (NVMe-oF™) architecture and offers optional vendor plugins for supplemental information above and beyond the specification.
You can search the Linux man page for help, but it won’t be enough to understand the capabilities of NVMe-CLI. The good news is all the commands in NVMe-CLI directly match the spec! All you need to do is download a copy of the latest NVMe spec to be able to interpret the abbreviations for the various commands.
All the abbreviations in the output of the NVMe commands can be found in the specification. For instance, for the Identify Controller data structure, you can send the command nvme-id-ctrl in NVMe-CLI. The output will have abbreviations for the various fields
Example: Model Number (MN) is displayed in NVMe-CLI as mn
NVMe-CLI can is obtained as a package for all the Linux distributions. The Github page has instructions for all the distributions, example for Ubuntu / Debian is below.
sudo apt install nvme-cli
You can also head over to the releases page and get the most stable build, while you will have to follow the instructions on the GitHub to compile and install for your distribution. On Ubuntu 22.04, the compiling would look like this.
wget https://github.com/linux-nvme/nvme-cli/archive/refs/tags/v2.3.tar.gz
tar -xvf v2.3.tar.gz
cd nvme-cli-2.3
sudo apt update
sudo apt install meson
sudo apt install ninja-build
sudo meson .build
sudo ninja -C .build
sudo meson install -C .build
Here is the cheat sheet of the most commonly used commands. Remember NVMe-CLI is powerful and can do almost anything that the NVMe specification calls out if used correctly. We will go into all these commands in detail.
Cheat Sheet
nvme version |
Display the current version |
nvme list |
Lists all the NVMe SSDs attached: name, serial number, size, LBA format, and serial |
nvme id-ctrl |
Discover information about NVMe controller and features it supports |
nvme id-ns |
Discover optimal namespace size, protection information, LBA size |
nvme format |
Secure erase the data on an SSD, format an LBA size or protection information for end-to-end data protection |
nvme sanitize |
Securely eliminate all data on device, cannot be stopped. Supports block, crypto, and overwrite |
nvme smart-log |
Health of the SSD (critical warning info), temperature, endurance, power on hours and error summary |
nvme error-log |
A log that contains information about errors encountered |
nvme reset |
Resets the NVMe controller |
nvme create-ns |
Create a namespace, can be used for overproviosning an SSD |
nvme delete-ns |
Remove a namespace |
nvme device-self-test |
Simple test for health of a drive, pass/fail |
nvme fw-download, fw-commit |
Download firmware to the drive, update the firmware on the drive |
nvme help |
Lists all the available commands |
Basics – Version, List, and Learning About the Capabilities of Attached NVMe Controllers / SSDs
NVMe Version
nvme version
nvme version 2.3 (git 2.3)
libnvme version 1.3 (git 1.3)
NVMe List
sudo nvme list
Identify Controller
The identify controller command is used to learn about the capabilities of the NVMe controllers (in most cases, this is the capabilities of an NVMe SSD). Instead of guessing which features a vendor supports, they are all neatly laid out in the capabilities field. Other useful information includes drive model, vendor, firmware version,
标签:commands,sudo,CLI,NVMe,nvmecli,介绍,version,使用,nvme From: https://blog.csdn.net/lwexin/article/details/142779205