15

Is there a Terminal command which will show me how many GB has been written to my SSD through the whole lifetime of the disk? I'm asking because I want to find out how many cycles have been done. SSD are able to do about 1000–2000 cycles depending on type.

  • Which SSD is in your Mac? – bmike Feb 18 '15 at 22:30
  • If you write 1000 cycle on a 250GB drive, it means that you've wrote 250TB of data. Even if you write 50GB each day it would take 13 years to kill it. – Thomas Ayoub Feb 20 '15 at 8:46
  • 2
    I actually average 32 GB per day on my SSD. I have 42 TB of writes already logged and the "wear level" is only 88% and total writes "99%" (whatever that means) according to DriveDx. My drive has been powered on for a total of 20 months. I have absolutely no errors or bad sectors. – zagadka314 Aug 24 '18 at 20:45
  • 1
    @ThomasAyoub 50GB/day is one hell of an underestimate thanks to swap! My 120GiB SSD's Host_Writes_MiB is 317296939 (That's 2421 cycles) and Wear_Leveling_Count is FAILING_NOW. My macbook is nowhere near 13 years old, more like 4 years. – Navin Sep 18 '18 at 7:12
  • 2
    @Navin well then, I agree I was totally wrong. – Thomas Ayoub Sep 19 '18 at 9:18
8

Read out the following S.M.A.R.T attributes of your SSD with an appropriate tool*:

241 - Total LBAs Written: The total number of 512-byte sectors written during the entire lifetime of the device.

242 - Total LBAs Read: The total number of 512-byte sectors read during the entire lifetime of the device.

A second set of attributes is:

174 - Host_Reads_MiB
175 - Host_Writes_MiB

But i don't know if the values found in the second set really make sense (at least for me with a 120 GB SSD as one part of a Fusion drive) because considerably more data is written to the SSD than the HDD though the SSD has only 1/25th of the size:

0xae Host_Reads_MiB          ----CK   100   100   000    -    12268569 (~12 TiB)  
0xaf Host_Writes_MiB         ----CK   100   100   000    -    16481745 (~16 TiB) 

compared to the 3 TB HDD (the second part of the Fusion drive):

0xf1 Total_LBAs_Written      ------   100   253   000    -    21361815408 (~10 TiB)  
0xf2 Total_LBAs_Read         ------   100   253   000    -    23925221693 (~11 TiB)

After installing smartmontools the following commands give the written data in GB if the attribute "242 Total_LBAs_Written" exists:

smartctl -s on -i -A -f brief -f hex,id -l devstat /dev/DiskIdentifier | grep 0xf1 | awk '{ print $8/1953125 }'

or in TB:

smartctl -s on -i -A -f brief -f hex,id -l devstat /dev/DiskIdentifier | grep 0xf1 | awk '{ print $8/1953125000 }'

Replace "DiskIdentifier" with the identifier of your internal SSD found with diskutil list. Probably it's disk0.

The following command gives the written data in GB if the attribute "175 - Host_Writes_MiB" exists (treat the result with caution):

smartctl -s on -i -A -f brief -f hex,id -l devstat /dev/DiskIdentifier | grep 0xaf | awk '{ print $8/953.67 }'

Like already mentioned earlier replace "DiskIdentifier" with the identifier of your internal SSD found with diskutil list. Probably it's disk0.

The smartctl commands above doesn't work very reliable (at least for me).
If you get an error like "Read SMART Data failed: Undefined error: 0", try smartctl -A /dev/disk0 first.
If you get an error like "SMART Disabled. Use option -s with argument 'on' to enable it.", try smartctl -s on -A /dev/disk0
Then retry the above commands to readout and calculate data written to disk.

*smartmontools

| improve this answer | |
  • OS X doesn't enable S.M.A.R.T. in SSDs by default? Will enabling it provide past history information? – grg Feb 18 '15 at 16:14
  • @grgarside Before posting I checked my Fusion-SSD and SMART was enabled. Couldn't find those attributes though. – klanomath Feb 18 '15 at 16:19
  • My "APPLE SSD SM256E" (rMBP) shows "Available" but "Disabled" with smartctl. – grg Feb 18 '15 at 16:23
  • @grgarside Enable it with smartctl -s on /dev/DiskIdentifier. Then you will be able to get the data. To disable it again: smartctl -s off /dev/DiskIdentifier – klanomath Feb 18 '15 at 17:11
  • 1
    You may want to add that smartctl can be easily installed using homebrew or port and that there even is a GUI for it. – n1000 Nov 10 '16 at 8:52
5

The original post mentions that SSDs have a 1000-2000 cycle limit, which over-simplifies the problem. Individual cells in an SSD may have such a limit, but the SSD implements many different solutions: from over-provisioning and write-levelling to Sandforce's proprietary collection of de-duplication, compression, and data differencing techniques, which it calls "DuraWrite".

Back to the original post: techniques like iostat, while relevant, show aggregate activity but it's very hard to work backwards to knowing how many program/erase cycles were performed for each cell, and from there, how much life remains on the SSD.

A useful recommendation might be to avoid filling SSDs to within 20% or so of their stated capacity, and to avoid deploying used SSDs without adequate backup.

Ars Technica has a couple of really useful articles on how SSDs work. Most directly useful is this: "Consumer-grade SSDs actually last a hell of a long time". For more details, see here, particularly page 5.

| improve this answer | |
4

I installed GSmartControl with Homebrew (brew install gsmartcontrol), and got this:

GSmartControl screenshot OSX

The SMART attribute no. 173 (Erase Count, or Wear Leveling) should mean the used up overall sector writes.

My MacBook 2015 answered this (no 0xf1 ID):

smartctl -s on -i -A -f brief -f hex,id -l devstat /dev/disk0 
smartctl 6.4 2015-06-04 r4109 [x86_64-apple-darwin15.0.0] (local build)
Copyright (C) 2002-15, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Device Model:     APPLE SSD SM0256G
...
LU WWN Device Id: 5 002538 900000000
Firmware Version: BXW1SA0Q
User Capacity:    251 000 193 024 bytes [251 GB]
Sector Sizes:     512 bytes logical, 4096 bytes physical
Rotation Rate:    Solid State Device
Device is:        Not in smartctl database [for details use: -P showall]
ATA Version is:   ATA8-ACS T13/1699-D revision 4c
SATA Version is:  SATA 3.0, 6.0 Gb/s (current: 6.0 Gb/s)
...
SMART support is: Available - device has SMART capability.
SMART support is: Enabled

=== START OF ENABLE/DISABLE COMMANDS SECTION ===
SMART Enabled.

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID#  ATTRIBUTE_NAME          FLAGS    VALUE WORST THRESH FAIL RAW_VALUE
0x01 Raw_Read_Error_Rate     -O-RC-   200   200   000    -    0
0x05 Reallocated_Sector_Ct   PO--CK   100   100   000    -    0
0x09 Power_On_Hours          -O--CK   099   099   000    -    180
0x0c Power_Cycle_Count       -O--CK   099   099   000    -    650
0xa9 Unknown_Attribute       PO--C-   229   229   010    -    1975773037504
0xad Unknown_Attribute       -O--CK   200   200   100    -    4296081414
0xae Unknown_Attribute       -O---K   099   099   000    -    2547718
0xaf Program_Fail_Count_Chip -O---K   099   099   000    -    1304888
0xc0 Power-Off_Retract_Count -O--C-   099   099   000    -    1
0xc2 Temperature_Celsius     -O---K   059   022   000    -    41 (Min/Max 19/78)
0xc5 Current_Pending_Sector  -O---K   100   100   000    -    0
0xc7 UDMA_CRC_Error_Count    -O-RC-   200   199   000    -    0
                             ||||||_ K auto-keep
                             |||||__ C event count
                             ||||___ R error rate
                             |||____ S speed/performance
                             ||_____ O updated online
                             |______ P prefailure warning

ATA_READ_LOG_EXT (addr=0x00:0x00, page=0, n=1) failed: 48-bit ATA commands not implemented
Read GP Log Directory failed

Device Statistics (GP/SMART Log 0x04) not supported
| improve this answer | |
0

smartctl outputs different results for different types of SSDs (NVMe vs SATA via AHCI).

TL;DR

NVMe - specific NVMe health info

e.g. Data Units Written: 44,739,539 [22.9 TB]

SATA / SATA Express (AHCI)

For Mid 2015 MacBookPro11,5 (512GB PCI based SSD)

175 Host_Writes_MiB         0x0022   099   099   000    Old_age   Always       -       19170887

Do the math: TB written / designed TBW * 100%, this can be used as an reference indicator for how much longer the SSD can last but there are other factors of course.

NOTE: That's how Samsung Magician (useless) Windows application calculates health status ;-)

Detailed discussion: https://apple.stackexchange.com/a/395220/37419

| improve this answer | |
-2

A very detailed answer has been given in this question here

The following command

iostat -Id disk0

reflects data transfer statistics from the moment the device was mounted to the moment the iostat command was run.

| improve this answer | |
  • 6
    Whilst this provides useful information, how does this apply to 'through the whole lifetime of the disk'? – grg Feb 18 '15 at 16:11
  • 2
    This only writes out the sum of read + write MB since boot or something. Generally the same stats as in Activity Monitor, Disk tab. – Adam Hošek Apr 7 '15 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .