MacOS – How much data has been written to the SSD over its lifetime

disk-utilitymacosssdterminal

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.

Best Answer

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