As is common knowledge, SSDs have a limited number of PE (Program-Erase) cycles before the NAND cells die.
Therefore, it is very helpful to know how much data has been written to your SSD, in order to determine how much longer it will last before the NAND dies.
I have a Samsung 850 Pro 512GB SSD, and I am running Ubuntu 14.04.
How can I get the TBW (Total-Bytes-Written) for my drive?
FULL DISCLOSURE: The scipt/commands present in this answer are not my own, but rather the work of J. D. G. Leaver. They were sourced from a blog post on his website.
NB:
smartctl
installed, from the packagesmartmontools
.Method 1:
Here's a handy little script that will allow you to monitor the TBW of your SSD, along with some other information:
Here's a sample of the output:
This data is accurate, as I only just installed my new 850 Pro.
Method 2:
Alternatively, here's a one-liner to get the TBW only:
How to find the information
We can use
smartctl
to find the value of TBW.Install
smartctl
with$ sudo apt install smartmontools
Get sector size and LBA written with
$ sudo smartctl -Ai /dev/sda
in this case for device/dev/sda
Some math:
[sector size] * [LBA written] / 1024^3 = X GiB
written so farExample for device /dev/sda
In this case the sector size is 512 bytes, which is common, and total LBA written is 1214641768. The result is 579 GiB written so far. This makes sense since this drive is relatively new.
Command
calc
can be install with$ sudo apt install calc
or use something else.More info
The command
$ sudo smartctl -A /dev/sda
gives information on "vendor specific SMART Attributes" meaning what your drive shows may not be the same as this one. In the example I used a Samsung SSD which has the needed information.Kingston SSD
Following what @JuliSmz said in their comment, and this PDF, I suspect
Total_LBAs_Written
returned by (at least some) Kingston SSDs is already in GB.Look for id 241 on the last page of the PDF. It says:
Crucial SSD Lifetime remaining
For Crucial SSD percentage lifetime remaining see
https://www.crucial.com/support/articles-faq-ssd/ssds-and-smart-data
This doc identifies 202 as Percent Lifetime Remaining. As an example on Ubuntu 16.04 (sudo smartctl /dev/sda1 -a)(part of smartmontools) reports 202 as unknown, but the value of 90 indicates 90% life remaining. On Ubuntu 20.04, the Lifetime Remaining is recognized and listed correctly
The accepted answer has bloated output, too much useless script-wizardry and hides initial parameter names from
smartctl
. Here is a better version;sample output:
and the one-liner