15

I've searched the internet to find a tool/utility which can tell me the total writes performed to an SSD (or a normal disk). The output should look something like this:

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

But I haven't found one. Is anyone aware of such a tool?

I know the SSDLife tool on Windows does this, but I am specifically looking to do this on Linux.


I looked up the smartctl command from smartmontools suggested by Selivanov. His post has been very helpful. I am going to add more info here which I came across after digging the internet.

I found the gsmartcontrol (gui version of smartctrl) especially helpful. For more information about these class of tools check Smartmontools -- Community Ubuntu Documentation. This link has examples for smartctl.

To understand what each SMART attribute means check this Intel S.M.A.R.T Attributes. These attributes are specific to Intel SSDs, but nevertheless gives an idea, what kind of information SMART attributes convey. Some specific parameters may differ between different SSDs. Is LBA size one of them?, I don't know.

Another excellent information source is How to determine number of write cycles or expected life for SSD under Linux? - Server Fault. Here, the best answer shows the SMART Attribute Id 225 stands for the total write I/O in size of 32MiBs performed to the SSD until now. However, this applies to Intel X25-M. Other SSDs, may use other SMART attributes to convey total data written to disk.

Especially, for Samsung 840 Pro (and may be even for other Samsung SSDs?) SMART Attribute Id 241 -- Total LBAs Written conveys this information. My guess for the LBA size is 512bytes, but I am not sure? Some experiments I ran by writing set amount of data to the SSD and measuring this attribute's value indicates it is 512bytes.

And Or
  • 151
  • 1
  • 1
  • 4
  • [ATA-6 48-bit LBA](https://en.wikipedia.org/wiki/Logical_block_addressing#LBA48) (introduced in 2003) allows addressing up to 128 PiB of disk locations through a 48-bit LBA address. Calculating `128*2^50 / 2^48` yields 512, indicating that disk-level addressing is done in 512-byte chunks. (2^50 / 2^48 = 2^(50-48) = 2^2, 128 * 2^2 = 512.) – user Dec 30 '13 at 12:21
  • 2
    Possible duplicate of [Measuring 'total bytes written' under Linux](http://serverfault.com/questions/238033/measuring-total-bytes-written-under-linux) – AjayKumarBasuthkar Dec 30 '15 at 14:37

4 Answers4

12

This values are hold in S.M.A.R.T attributes. You cat use smartctl command from smartmontools to get them.

UPD smartctl -A /dev/sda | grep -i 'media_wearout_indicator' | tr -s ' ' | cut -d' ' -f4-5 will output VALUE,WORST and THRESHOLD for Media_Wearout_Indicator. Note: for your device the attribute may have different name and threshold value, or may be unavailable at all. Depends on device vendor.

Selivanov Pavel
  • 2,126
  • 3
  • 23
  • 47
7

To be a bit more specific than the others, you can get this information from smartctl with the -l devstat args.

Sample output:

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
Brian Cain
  • 299
  • 3
  • 7
  • This is telling me 855GB have been written to a 256GB SSD that has never been more than 15% full... while I suppose it's possible this seems... *excessive*? – Michael Dec 11 '18 at 17:41
  • 1
    @Michael Easy: browser cache; or may be vendor was running tests on freshly manufactured device. – Selivanov Pavel Dec 11 '18 at 18:11
  • @Michael: depends on how long the drive is in operation. the same sets of files being (over)written again and again over the years (tempfiles, browser cache, OS bookkeeping) may quite well account for that even if the drive itself remained at 15% usage. Also, remember 855GB is roughly only **3** times your SSD capacity, and modern SSDs are rated for **1000** times writes. Still 997 to go! – MestreLion May 14 '22 at 08:39
  • 1
    @MestreLion Well... I think I was reading that cheaper multi-level cell SSDs are actually only rated to around 300 times. I went back and looked and I'm up to 2.6TB written, so about 10x out of 300x. Still it's rather strange because I've got both the browser cache/userdir and /tmp set up in tmpfs partitions. – Michael May 14 '22 at 19:09
3

You might try

# 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://web.archive.org/web/20131029220335/http://namhuy.net/1024/how-to-check-ssd-life-left.html

0

Run sudo smartctl -A /dev/<your disk> and look the following indicators:

  • Data Units Read (how much data was read over the lifetime of the disk)
  • Data Units Written (how much data was read over the lifetime of the disk)
  • Host Read Commands (how many read commands were issued to the disk over its lifetime)
  • Host Write Commands (how many write commands were issued to the disk over its lifetime)

Note: -A prints vendor specific SMART attributes, so these may vary depending on the brand of SSD.

It is not at all surprising (in fact expected) to see values for Data Units Read/Written that is many times the size of the disk when it's used as your system disk.

kynan
  • 1,725
  • 1
  • 11
  • 6