How much data has been written to my SSD over its lifetime?
Solution 1:
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 }'
For some SSDs, like the Sandisk Plus 120Gb, the $8 value is already in GB so you'll need to use division to calculate the value.
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
Solution 2:
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.
Solution 3:
I installed GSmartControl with Homebrew (brew install gsmartcontrol
), and got this:
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
Solution 4:
smartctl
outputs different results for different types of SSDs (PCIe via NVMe vs SATA/PCIe via AHCI).
TL;DR
NVMe - specific NVMe health info
2017 touch bar MacBook Pro 15 inch
e.g. Data Units Written: 44,739,539 [22.9 TB]
SATA / SATA Express (AHCI)
For Mid 2015 MacBookPro11,5 (512GB PCIe-based SSD via AHCI)
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