nvmecli介绍和使用

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,

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

早日实现财富自由-2025

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值