nvme-cli
nvme-cli
is a command-line utility for managing and interacting with NVMe (Non-Volatile Memory Express) devices on Linux-based systems. NVMe is a high-speed storage protocol designed for solid-state drives (SSDs) that are connected through the PCIe interface. The nvme-cli
tool allows you to perform various operations on NVMe devices, such as querying information, formatting, managing namespaces, performing diagnostics, and tuning performance.
Key Features of nvme-cli
:
nvme-cli
:Querying Device Information:
Get detailed information about the NVMe device, including model, serial number, firmware version, capacity, and health.
Example command:
nvme list
This lists all NVMe devices connected to the system along with their status.
SMART Health Information:
Retrieve SMART (Self-Monitoring, Analysis, and Reporting Technology) data for the NVMe device, which includes health status, temperature, error counts, and wear leveling.
Example command:
nvme smart-log /dev/nvme0
Namespace Management:
NVMe devices can have multiple namespaces, which are essentially partitions on the device. You can create, delete, and list namespaces.
Example command to list namespaces:
nvme list-ns /dev/nvme0
Firmware Management:
You can check the current firmware version of an NVMe device and update it if needed.
Example command to check firmware:
nvme id-ctrl /dev/nvme0
Example command to update firmware (requires the firmware file):
nvme fw-download /dev/nvme0 --fw=<firmware_file> nvme fw-activate /dev/nvme0
Device Formatting:
Format NVMe devices or namespaces with various options.
Example command to format a device:
nvme format /dev/nvme0 --force
Diagnostic and Performance Testing:
nvme-cli
can be used to run diagnostic tests on the device and check its performance.Example command for a diagnostic self-test:
nvme self-test /dev/nvme0
Thermal Management:
Get temperature readings and control thermal limits (if supported by the hardware).
Example command to check the temperature:
nvme temperature /dev/nvme0
Power Management:
The tool allows you to manage power states for NVMe devices, including active and low-power states.
Example command to check power states:
nvme power-state /dev/nvme0
Log and Event Monitoring:
nvme-cli
allows you to monitor the device's event log for issues like errors, firmware updates, or other significant events.Example command to retrieve event log:
nvme get-log /dev/nvme0 --log-id=1
Security Features:
Enable or disable features like the secure erase of NVMe drives or manage the cryptographic protection of the device.
Example command to enable security erase:
nvme sanitize /dev/nvme0 --sanitize-erase
Installation:
On most Linux distributions, nvme-cli
can be installed from the package manager:
Debian/Ubuntu:
sudo apt install nvme-cli
Red Hat/CentOS:
sudo yum install nvme-cli
Fedora:
sudo dnf install nvme-cli
Basic Commands:
Listing NVMe Devices:
nvme list
Checking SMART Logs:
nvme smart-log /dev/nvme0
Check Device Identity Information:
nvme id-ctrl /dev/nvme0
Getting Temperature:
nvme temperature /dev/nvme0
Running Self Test:
nvme self-test /dev/nvme0
Formatting Device:
nvme format /dev/nvme0 --force
Use Cases:
Health Monitoring: You can use
nvme-cli
to regularly monitor the health of your NVMe devices, ensuring that they are operating properly and to detect early signs of failure (e.g., wear leveling, temperature issues).Device Configuration and Tuning: Configure and tune your NVMe devices for optimal performance, such as adjusting power management settings or managing namespaces.
Firmware Updates:
nvme-cli
is a useful tool for keeping your NVMe devices up-to-date with the latest firmware to fix bugs or improve performance.Security Management: Securely erase data from NVMe devices when needed, useful for sensitive data environments.
Conclusion:
nvme-cli
is a powerful tool for managing NVMe storage devices on Linux systems. Whether you need to check device health, update firmware, manage namespaces, or run diagnostics, nvme-cli
provides all the necessary commands to interact with NVMe devices at a low level. It is an essential tool for system administrators and professionals managing high-performance storage systems.
Last updated