https://blog.csdn.net/smart9527_zc/article/details/86163533
一、下載nvme
https://codeload.github.com/linux-nvme/nvme-cli/zip/master
二、解壓安裝
$:yun -y install gcc-c++
$:mkdir -p /hoem/share
$:mv nvme-cli-master.zip /home/share/
$:cd /home/share/
$:unzip nvme-cli-master.zip
$:cd nvme-cli-master/
$:make
$:make install
驗證:
[root@ceph-admin nvme-cli-master]# nvme -version
nvme version 1.6
三、Nvme的使用方法
1、查看PCIe設備
[root@ceph02 share]# nvme --list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 CVMD7372007C400OGN INTEL SSDPEDME400G4 1 400.09 GB / 400.09 GB 512 B + 0 B 8DV10171
2、 格式化硬盤
$:nvme format /dev/nvme0n1
3、重置硬盤
NVMe硬盤固件版本進行upgrade/downgrading后要進行reset后才能effective,如果不重置主控需reboot 系統。
$:nvme reset /dev/nvme0n1
4、 讀取硬盤的smart信息
[root@ceph02 share]# nvme smart-log /dev/nvme0n1
Smart Log for NVME device:nvme0n1 namespace-id:ffffffff
critical_warning : 0
temperature : 25 C
available_spare : 100%
available_spare_threshold : 10%
percentage_used : 0%
data_units_read : 49,706,581
data_units_written : 17,137,853
host_read_commands : 1,218,822,719
host_write_commands : 540,713,221
controller_busy_time : 89
power_cycles : 35
power_on_hours : 2,399
unsafe_shutdowns : 21
media_errors : 0
num_err_log_entries : 0
Warning Temperature Time : 0
Critical Composite Temperature Time : 0
Thermal Management T1 Trans Count : 0
Thermal Management T2 Trans Count : 0
Thermal Management T1 Total Time : 0
Thermal Management T2 Total Time : 0
5、nvme升/降固件版本
$:nvme fw-download -f '/root/XXXXXXX.bin'
$:nvme fw-activate /dev/nvme0n1 -s 1 -a 1
$:nvme reset /dev/nvme0n1
6、設置硬盤存儲4k對齊
$:nvme format /dev/nvme1n1 -n 1 -l 1
7、nvme op
$:nvme admin-passthru /dev/nvme0 -o 0x9 --cdw10=0xc1 --cdw11=0x2000000 --cdw12=0x1
8、PCIe硬盤壽命計算
可以通過nvme-cli讀取PCIe硬盤smart信息,進行進行計算硬盤的Endurance、DWPD(Drive Writes Per Day)。
a.測試前讀取硬盤smart-log信息
b.fio進行讀寫一定的數據
c.fio結束后再次執行nvme intel smart-log-add /dev/nvme0n1讀取smart-log信息
d.計算
參考:
《nvme-cli常用指令》https://blog.csdn.net/weixin_40343504/article/details/82386024?utm_source=blogxgwz2
————————————————
版權聲明:本文為CSDN博主「smart9527_zc」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/smart9527_zc/article/details/86163533