{"id":227668,"date":"2021-10-08T10:59:57","date_gmt":"2021-10-08T02:59:57","guid":{"rendered":"https:\/\/lrxjmw.cn\/?p=227668"},"modified":"2021-09-28T11:00:24","modified_gmt":"2021-09-28T03:00:24","slug":"linux-nvme","status":"publish","type":"post","link":"https:\/\/lrxjmw.cn\/linux-nvme.html","title":{"rendered":"\u4f7f\u7528 Linux \u547d\u4ee4\u884c\u5de5\u5177\u6765\u4e86\u89e3\u4f60\u7684 NVMe \u9a71\u52a8\u5668"},"content":{"rendered":"\n\n\n
\u5bfc\u8bfb<\/td>\nnvme-cli \u547d\u4ee4\u62e5\u6709\u8bf8\u591a\u5b9e\u7528\u7684\u9009\u9879\uff0c\u4e14\u5b83\u662f\u63a7\u5236\u548c\u7ba1\u7406\u6570\u636e\u4e00\u79cd\u5f88\u597d\u7684\u65b9\u5f0f\u3002<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

NVMe \u662f\u6307\u975e\u6613\u5931\u6027\u5185\u5b58\u89c4\u8303\uff0c\u5b83\u89c4\u8303\u4e86\u8f6f\u4ef6\u548c\u5b58\u50a8\u901a\u8fc7 PCIe \u548c\u5176\u4ed6\u534f\u8bae\uff08\u5305\u62ec TCP\uff09\u8fdb\u884c\u901a\u4fe1\u7684\u65b9\u5f0f\u3002\u5b83\u662f\u7531\u975e\u8425\u5229\u7ec4\u7ec7\u9886\u5bfc\u7684 \u5f00\u653e\u89c4\u8303\uff0c\u5e76\u5b9a\u4e49\u4e86\u51e0\u79cd\u5f62\u5f0f\u7684\u56fa\u6001\u5b58\u50a8\u3002<\/p>\n

\u6211\u7684\u7b14\u8bb0\u672c\u7535\u8111\u6709\u4e00\u4e2a NVMe \u9a71\u52a8\u5668\uff0c\u6211\u7684\u53f0\u5f0f\u673a\u4e5f\u6709\u3002\u800c\u4e14\u5b83\u4eec\u7684\u901f\u5ea6\u5f88\u5feb\u3002\u6211\u559c\u6b22\u6211\u7684\u7535\u8111\u542f\u52a8\u7684\u901f\u5ea6\uff0c\u4ee5\u53ca\u5b83\u4eec\u8bfb\u5199\u6570\u636e\u7684\u901f\u5ea6\u3002\u51e0\u4e4e\u6ca1\u6709\u5ef6\u8fdf\u3002<\/p>\n

\u6ca1\u8fc7\u591a\u4e45\uff0c\u6211\u5c31\u5bf9\u9a71\u52a8\u8fd9\u79cd\u8d85\u9ad8\u901f\u5b58\u50a8\u7684\u6280\u672f\u4ea7\u751f\u4e86\u597d\u5947\uff0c\u6240\u4ee5\u6211\u505a\u4e86\u4e00\u4e9b\u8c03\u67e5\u3002\u6211\u4e86\u89e3\u5230\uff0cNVMe \u9a71\u52a8\u5668\u6d88\u8017\u7684\u7535\u529b\u66f4\u5c11\uff0c\u800c\u63d0\u4f9b\u7684\u6570\u636e\u8bbf\u95ee\u901f\u5ea6\u751a\u81f3\u6bd4 SATA \u7684 SSD \u9a71\u52a8\u5668\u5feb\u5f97\u591a\u3002\u8fd9\u5f88\u6709\u8da3\uff0c\u4f46\u6211\u60f3\u77e5\u9053\u66f4\u591a\u5173\u4e8e\u6211\u7684\u7279\u5b9a NVMe \u9a71\u52a8\u5668\u7684\u4fe1\u606f\uff0c\u6211\u60f3\u77e5\u9053\u5b83\u4eec\u4e0e\u5176\u4ed6\u9a71\u52a8\u5668\u6709\u4f55\u533a\u522b\u3002\u6211\u53ef\u4ee5\u5b89\u5168\u5730\u64e6\u9664\u9a71\u52a8\u5668\u5417\uff1f\u6211\u600e\u6837\u624d\u80fd\u68c0\u67e5\u5b83\u7684\u5b8c\u6574\u6027\uff1f<\/p>\n

\u5e26\u7740\u8fd9\u4e9b\u95ee\u9898\u6211\u5728\u4e92\u8054\u7f51\u4e0a\u641c\u7d22\uff0c\u53d1\u73b0\u4e86\u4e00\u4e2a\u5f00\u6e90\u9879\u76ee\uff0c\u5176\u4e2d\u6709\u4e00\u7cfb\u5217\u7ba1\u7406 NVMe \u9a71\u52a8\u5668\u7684\u5de5\u5177\u3002\u5b83\u88ab\u79f0\u4e3a nvme-cli<\/span>\u3002<\/p>\n

\u5b89\u88c5 nvme-cli<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u4ece\u4f60\u7684\u53d1\u884c\u7248\u7684\u5305\u7ba1\u7406\u5668\u4e2d\u5b89\u88c5 <\/p>\n

nvme-cli<\/strong><\/div>\n

\u3002\u4f8b\u5982\uff0c\u5728 Fedora\u3001CentOS \u6216\u7c7b\u4f3c\u7cfb\u7edf\u4e0a\uff1a<\/p>\n

$ sudo dnf install nvme-cli\r\n<\/pre>\n

\u5728 Debian\u3001Mint\u3001Elementary \u548c\u7c7b\u4f3c\u7cfb\u7edf\u4e0a:<\/p>\n

$ sudo apt install nvme-cli\r\n<\/pre>\n
\u63a2\u7d22 NVMe \u9a71\u52a8\u5668<\/strong><\/div>\n

\u5728\u5b89\u88c5 nvme-cli<\/span> \u540e\uff0c\u6211\u60f3\u63a2\u7d22\u6211\u7684\u9a71\u52a8\u5668\u3002nvme-cli <\/span>\u6ca1\u6709\u624b\u518c\u9875\uff0c\u4f46\u4f60\u53ef\u4ee5\u901a\u8fc7\u8f93\u5165 nvme help<\/span> \u83b7\u5f97\u5f88\u591a\u5e2e\u52a9\uff1a<\/p>\n

$ nvme help\r\nnvme-1.14\r\nusage: nvme  [] []\r\nThe '' may be either an NVMe character device (ex: \/dev\/nvme0) or an\r\nnvme block device (ex: \/dev\/nvme0n1).\r\nThe following are all implemented sub-commands:\r\n list List all NVMe devices and namespaces on machine\r\n list-subsys List nvme subsystems\r\n id-ctrl Send NVMe Identify Controller\r\n id-ns Send NVMe Identify Namespace, display structure\r\n id-ns-granularity Send NVMe Identify Namespace Granularity List, display structure\r\n list-ns Send NVMe Identify List, display structure\r\n list-ctrl Send NVMe Identify Controller List, display structure\r\n nvm-id-ctrl Send NVMe Identify Controller NVM Command Set, display structure\r\n primary-ctrl-caps Send NVMe Identify Primary Controller Capabilities\r\n[...]\r\n<\/pre>\n
\u5217\u51fa\u6240\u6709\u7684 NVMe \u9a71\u52a8\u5668<\/strong><\/div>\n

sudo nvme list <\/span>\u547d\u4ee4\u5217\u51fa\u4f60\u673a\u5668\u4e0a\u6240\u6709\u7684 NVMe \u8bbe\u5907\u548c\u547d\u540d\u7a7a\u95f4\u3002\u6211\u7528\u5b83\u5728 \/dev\/nvme0n1 <\/span>\u627e\u5230\u4e86\u4e00\u4e2a NVMe \u9a71\u52a8\u5668\u3002\u4e0b\u9762\u662f\u547d\u4ee4\u8f93\u51fa\u7ed3\u679c\uff1a<\/p>\n

$ sudo nvme list\r\nNode SN Model Namespace Usage Format FW Rev\r\n--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------\r\n\/dev\/nvme0n1    S42GMY9M141281 SAMSUNG MZVLB256HAHQ-000L7 1\r\n214.68 GB \/ 256.06 GB 512  B + 0 B 0L2QEXD7\r\n<\/pre>\n

\u6211\u6709\u4e00\u4e2a\u540d\u4e3a nvme0n1<\/span> \u7684\u9a71\u52a8\u5668\u3002\u5b83\u5217\u51fa\u4e86\u5e8f\u5217\u53f7\u3001\u54c1\u724c\u3001\u5bb9\u91cf\u3001\u56fa\u4ef6\u7248\u672c\u7b49\u7b49\u3002<\/p>\n

\u901a\u8fc7\u4f7f\u7528 id-ctrl <\/span>\u5b50\u547d\u4ee4\uff0c\u4f60\u53ef\u4ee5\u5f97\u5230\u66f4\u591a\u5173\u4e8e\u8be5\u786c\u76d8\u548c\u5b83\u6240\u652f\u6301\u7684\u7279\u6027\u7684\u4fe1\u606f\uff1a<\/p>\n

$ sudo nvme id-ctrl \/dev\/nvme0n1\r\nNVME Identify Controller:\r\nvid : 0x144d\r\nssvid : 0x144d\r\nsn : S42GMY9M141281\r\nmn : SAMSUNG MZVLB256HAHQ-000L7\r\nfr : 0L2QEXD7\r\nrab : 2\r\nieee : 002538\r\ncmic : 0\r\nmdts : 9\r\ncntlid : 0x4\r\nver : 0x10200\r\nrtd3r : 0x186a0\r\nrtd3e : 0x7a1200\r\n[...]\r\n<\/pre>\n
\u9a71\u52a8\u5668\u5065\u5eb7<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u901a\u8fc7 smart-log<\/span> \u5b50\u547d\u4ee4\u6765\u4e86\u89e3\u786c\u76d8\u7684\u6574\u4f53\u5065\u5eb7\u72b6\u51b5\uff1a<\/p>\n

$ sudo nvme smart-log \/dev\/nvme0n1\r\nSmart Log for NVME device:nvme0n1 namespace-id:ffffffff\r\ncritical_warning : 0\r\ntemperature : 21 C\r\navailable_spare : 100%\r\navailable_spare_threshold : 10%\r\npercentage_used : 2%\r\nendurance group critical warning summary: 0\r\ndata_units_read : 5,749,452\r\ndata_units_written : 10,602,948\r\nhost_read_commands : 77,809,121\r\nhost_write_commands : 153,405,213\r\ncontroller_busy_time : 756\r\npower_cycles : 1,719\r\npower_on_hours : 1,311\r\nunsafe_shutdowns : 129\r\nmedia_errors : 0\r\nnum_err_log_entries : 1,243\r\nWarning Temperature Time : 0\r\nCritical Composite Temperature Time : 0\r\nTemperature Sensor 1 : 21 C\r\nTemperature Sensor 2 : 22 C\r\nThermal Management T1 Trans Count : 0\r\nThermal Management T2 Trans Count : 0\r\nThermal Management T1 Total Time : 0\r\nThermal Management T2 Total Time : 0\r\n<\/pre>\n

\u8fd9\u4e3a\u4f60\u63d0\u4f9b\u4e86\u786c\u76d8\u7684\u5f53\u524d\u6e29\u5ea6\u3001\u5230\u76ee\u524d\u4e3a\u6b62\u7684\u4f7f\u7528\u65f6\u95f4\u3001\u4e0d\u5b89\u5168\u7684\u5173\u673a\u6b21\u6570\u7b49\u7b49\u3002<\/p>\n

\u683c\u5f0f\u5316\u4e00\u4e2a NVMe \u9a71\u52a8\u5668<\/strong><\/div>\n

\u4f60\u53ef\u4ee5\u7528 nvme-cli<\/span> \u683c\u5f0f\u5316\u4e00\u4e2a NVMe \u9a71\u52a8\u5668\uff0c\u4f46\u8981\u6ce8\u610f\u3002\u8fd9\u5c06\u5220\u9664\u9a71\u52a8\u5668\u4e0a\u7684\u6240\u6709\u6570\u636e\uff01\u5982\u679c\u4f60\u7684\u786c\u76d8\u4e0a\u6709\u91cd\u8981\u7684\u6570\u636e\uff0c\u4f60\u5fc5\u987b\u5728\u8fd9\u6837\u505a\u4e4b\u524d\u5c06\u5176\u5907\u4efd\uff0c\u5426\u5219\u4f60\u5c06\u4f1a\u4e22\u5931\u6570\u636e\u3002\u5b50\u547d\u4ee4\u662f format<\/span>\uff1a<\/p>\n

$ sudo nvme format \/dev\/nvme0nX\r\n<\/pre>\n

\uff08\u4e3a\u4e86\u5b89\u5168\u8d77\u89c1\uff0c\u6211\u7528 X \u66ff\u6362\u4e86\u9a71\u52a8\u5668\u7684\u5b9e\u9645\u4f4d\u7f6e\uff0c\u4ee5\u9632\u6b62\u590d\u5236\u7c98\u8d34\u7684\u9519\u8bef\u3002\u5c06 X<\/span> \u6539\u4e3a 1<\/span> \u6216 nvme list<\/span> \u7ed3\u679c\u4e2d\u5217\u51fa\u7684\u5b9e\u9645\u4f4d\u7f6e\u3002\uff09<\/p>\n

\u5b89\u5168\u5730\u64e6\u9664 NVMe \u9a71\u52a8\u5668<\/strong><\/div>\n

\u5f53\u4f60\u51c6\u5907\u51fa\u552e\u6216\u5904\u7406\u4f60\u7684 NVMe \u7535\u8111\u65f6\uff0c\u4f60\u53ef\u80fd\u60f3\u5b89\u5168\u5730\u64e6\u9664\u9a71\u52a8\u5668\u3002\u8fd9\u91cc\u7684\u8b66\u544a\u4e0e\u683c\u5f0f\u5316\u8fc7\u7a0b\u4e2d\u7684\u8b66\u544a\u76f8\u540c\u3002\u9996\u5148\u8981\u5907\u4efd\u91cd\u8981\u7684\u6570\u636e\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u547d\u4ee4\u4f1a\u5220\u9664\u8fd9\u4e9b\u6570\u636e\uff01<\/p>\n

$ sudo nvme sanitize \/dev\/nvme0nX\r\n<\/pre>\n
\u5c1d\u8bd5 nvme-cli<\/strong><\/div>\n

nvme-cli <\/span>\u547d\u4ee4\u662f\u5728 GPLv2 <\/span>\u8bb8\u53ef\u4e0b\u53d1\u5e03\u7684\u3002\u5b83\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u547d\u4ee4\uff0c\u6709\u5f88\u591a\u6709\u7528\u7684\u9009\u9879\uff0c\u7528\u6765\u6709\u6548\u5730\u63a7\u5236\u548c\u7ba1\u7406\u6570\u636e\u3002<\/p>\n


\n

via:\u00a0https:\/\/opensource.com\/article\/21\/9\/nvme-cli<\/a><\/p>\n

\u4f5c\u8005\uff1aDon Watkins<\/a>\u00a0\u9009\u9898\uff1alujun9972<\/a>\u00a0\u8bd1\u8005\uff1ageekpi<\/a>\u00a0\u6821\u5bf9\uff1aturbokernel<\/a><\/p>\n

\u672c\u6587\u7531\u00a0LCTT<\/a>\u00a0\u539f\u521b\u7f16\u8bd1\uff0cLinux\u4e2d\u56fd<\/a>\u00a0\u8363\u8a89\u63a8\u51fa<\/p>\n","protected":false},"excerpt":{"rendered":"

NVMe \u662f\u6307\u975e\u6613\u5931\u6027\u5185\u5b58\u89c4\u8303\uff0c\u5b83\u89c4\u8303\u4e86\u8f6f\u4ef6\u548c\u5b58\u50a8\u901a\u8fc7 PCIe \u548c\u5176\u4ed6\u534f\u8bae\uff08\u5305\u62ec TCP\uff09\u8fdb\u884c\u901a\u4fe1\u7684\u65b9\u5f0f\u3002\u5b83 […]<\/p>\n","protected":false},"author":1890,"featured_media":227669,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-227668","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227668","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1890"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=227668"}],"version-history":[{"count":1,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227668\/revisions"}],"predecessor-version":[{"id":227670,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/227668\/revisions\/227670"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/227669"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=227668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=227668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=227668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}