如何衡量Linux中对SSD的总写入次数?


13

我已经在互联网上搜索了一个工具/实用程序,可以告诉我对SSD(或普通磁盘)的总写入次数。输出应如下所示:

SSD Intel 320S :- 
Total data written until now -- 2Tb
Total data read until now -- 4Tb
power on Hours -- 1234 Hrs
etc.

但是我还没有找到。有人知道这样的工具吗?

我知道Windows上的SSDLife工具可以做到这一点,但是我特别希望在Linux上做到这一点。


smartctlsmartmontoolsSelivanov的建议中查找了命令。他的职位非常有帮助。我将在此处添加更多信息,这些信息是我在浏览互联网后遇到的。

我发现gsmartcontrol(的gui版本smartctrl)特别有用。有关此类工具的更多信息,请查看Smartmontools-社区Ubuntu文档。此链接包含的示例smartctl

要了解每个SMART属性的含义,请检查此Intel SMART属性。这些属性特定于Intel SSD,但是仍然提供了一个思路,即SMART属性可以传达什么样的信息。不同的SSD之间某些特定参数可能有所不同。LBA是其中之一吗?我不知道。

另一个出色的信息来源是如何确定Linux下SSD的写周期数或预期寿命?-服务器故障。在这里,最好的答案表明了SMART Attribute Id 225迄今为止对SSD执行的32MiB大小的总写入I / O。但是,这适用于Intel X25-M。其他SSD可以使用其他SMART属性来传递写入磁盘的总数据。

特别是对于Samsung 840 Pro(甚至可能对于其他Samsung SSD?)SMART Attribute Id 241 -- Total LBAs Written传达此信息。我对LBA大小的猜测是512字节,但是我不确定吗?我通过将一定数量的数据写入SSD并测量该属性的值表明它为512字节来进行一些实验。


ATA-6 48位LBA(于2003年推出)允许通过48位LBA地址寻址多达128个PiB磁盘位置。计算128*2^50 / 2^48产量512,表明磁盘级寻址以512字节块完成。(2 ^ 50/2 ^ 48 = 2 ^(50-48)= 2 ^ 2,128 * 2 ^ 2 =512。)
CVn 2013年

Answers:


9

此值保存在SMART属性中。您可以使用smartmontools中的smartctl命令来获取它们。

UPD smartctl -A /dev/sda | grep -i 'media_wearout_indicator' | tr -s ' ' | cut -d' ' -f4-5将为Media_Wearout_Indicator输出VALUE,WORST和THRESHOLD。注意:对于您的设备,属性可能具有不同的名称和阈值,或者可能根本不可用。取决于设备供应商。


2
如果可以通过SMART获得编号,我会发现SMART有点偶然,它取决于设备。Linux上的另一个选项是监视和记录/proc/diskstats,尽管显然在重启后会重置。
2013年

您不能只说使用“ smartctl”而不告诉我们要传递的参数!
迈克尔

@Michael更新了答案
Selivanov Pavel

4

要比其他人更具体一点,您可以从 smartctl通过-l devstatargs。

样本输出:

Device Statistics (GP Log 0x04)
Page Offset Size         Value  Description
  1  =====  =                =  == General Statistics (rev 1) ==
  1  0x008  4              288  Lifetime Power-On Resets
  1  0x018  6     348307315343  Logical Sectors Written
  1  0x020  6         34309409  Number of Write Commands
  1  0x028  6       3434309403  Logical Sectors Read
  1  0x030  6         34954859  Number of Read Commands
  4  =====  =                =  == General Errors Statistics (rev 1) ==
  4  0x008  4                0  Number of Reported Uncorrectable Errors
  4  0x010  4                0  Resets Between Cmd Acceptance and Completion
  5  =====  =                =  == Temperature Statistics (rev 1) ==
  5  0x008  1               13  Current Temperature
  5  0x010  1               16  Average Short Term Temperature
  5  0x018  1               25  Average Long Term Temperature
  5  0x020  1               34  Highest Temperature
  5  0x028  1               12  Lowest Temperature
  5  0x030  1               35  Highest Average Short Term Temperature
  5  0x038  1               16  Lowest Average Short Term Temperature
  5  0x040  1               26  Highest Average Long Term Temperature
  5  0x048  1               21  Lowest Average Long Term Temperature
  5  0x050  4                0  Time in Over-Temperature
  5  0x058  1               55  Specified Maximum Operating Temperature
  5  0x060  4                0  Time in Under-Temperature
  5  0x068  1                0  Specified Minimum Operating Temperature
  6  =====  =                =  == Transport Statistics (rev 1) ==
  6  0x008  4           224211  Number of Hardware Resets
  6  0x010  4              463  Number of ASR Events
  6  0x018  4                0  Number of Interface CRC Errors
  7  =====  =                =  == Solid State Device Statistics (rev 1) ==
  7  0x008  1                3  Percentage Used Endurance Indicator

这告诉我855GB已被写入到256GB的SSD中,该SSD的容量从未超过15%...而我想这似乎可能... 过多了吗?
迈克尔

@Michael Easy:浏览器缓存;或者可能是供应商在新制造的设备上运行测试。
Selivanov Pavel

3

你可以试试

# smartctl -a /dev/sda

smartctl -a /dev/sda
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-49-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net

=== START OF INFORMATION SECTION ===
Device Model: INTEL SSDSC2CW180A3
Serial Number: CVCV204408A6180EGN
LU WWN Device Id: 5 001517 bb2824682
Firmware Version: 400i
User Capacity: 180,045,766,656 bytes [180 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ACS-2 revision 3
Local Time is: Thu Jul 11 00:55:16 2013 PDT
SMART support is: Available – device has SMART capability.
SMART support is: Enabled

=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED

General SMART Values:
Offline data collection status: (0×00) Offline data collection activity
was never started.
Auto Offline Data Collection: Disabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 2097) seconds.
Offline data collection
capabilities: (0x7f) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Abort Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0×0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0×01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 48) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0×0021) SCT Status supported.
SCT Data Table supported.

SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0×0032 100 100 000 Old_age Always – 0
9 Power_On_Hours 0×0032 000 000 000 Old_age Always – 46385647693103
12 Power_Cycle_Count 0×0032 100 100 000 Old_age Always – 279
170 Unknown_Attribute 0×0033 100 100 010 Pre-fail Always – 0
171 Unknown_Attribute 0×0032 100 100 000 Old_age Always – 0
172 Unknown_Attribute 0×0032 100 100 000 Old_age Always – 0
174 Unknown_Attribute 0×0032 100 100 000 Old_age Always – 278
184 End-to-End_Error 0×0033 100 100 090 Pre-fail Always – 0
187 Reported_Uncorrect 0×0032 100 100 000 Old_age Always – 0
192 Power-Off_Retract_Count 0×0032 100 100 000 Old_age Always – 278
225 Load_Cycle_Count 0×0032 100 100 000 Old_age Always – 10754
226 Load-in_Time 0×0032 100 100 000 Old_age Always – 65535
227 Torq-amp_Count 0×0032 100 100 000 Old_age Always – 66
228 Power-off_Retract_Count 0×0032 100 100 000 Old_age Always – 65535
232 Available_Reservd_Space 0×0033 100 100 010 Pre-fail Always – 0
233 Media_Wearout_Indicator 0×0032 100 100 000 Old_age Always – 0
241 Total_LBAs_Written 0×0032 100 100 000 Old_age Always – 10754
242 Total_LBAs_Read 0×0032 100 100 000 Old_age Always – 21803
249 Unknown_Attribute 0×0013 100 100 000 Pre-fail Always – 357

SMART Error Log not supported
SMART Self-test Log not supported
Note: selective self-test log revision number (0) not 1 implies that no selective self-test has ever been run
SMART Selective self-test log data structure revision number 0
Note: revision number not 1 implies that no selective self-test has ever been run
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0×0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.

http://namhuy.net/1024/how-to-check-ssd-life-left.html


您的样本中哪一行输出提供了TBW?
迈克尔
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.