How to check how much data your SSD has written in total on Linux?
SSDs are much faster than old HDDs, but they also have much lower typical number of TiBs written before failure (TBW). That number is 70 to 150 TiB for an average SSD today. Now it would be nice to determine how much data you've actually written to your own SSD. It doesn't guarantee anything, but it can give you a better picture about how much longer you can expect it to last. Here is a good article about the lifespan of SSDs. If your SSD has SMART capabilities, it's very easy to do on Linux (given that you know the commands), but here's a one-liner that could help you...
1 | export LBAsW="Total_LBAs_Written" ; sudo smartctl -a /dev/sda | grep -q "$LBAsW" && echo "$(echo "scale=3; $(($(sudo smartctl -a /dev/sda | grep "$LBAsW" | awk '{ print $10 }') * 512)) / 1024 / 1024 / 1024 / 1024" | bc -l) TiB written in total" || echo "Not supported on your storage drive." ; unset LBAsW |
Copy and paste this in your Linux terminal. If the SSD you'd like to check is not /dev/sda (/dev/sdb, for instance), feel free to change that accordingly. Basically, this command relies on the smartctl tool and its total number of LBAs written. Since there are 512 bytes at every LBA, we multiply the number of LBAs by 512. The number we get is the total number of bytes written. To convert this number into something that is more human-friendly, we divide by 1024 four times to get the number of TiBs written.
1 | scale=3; |
This parameter scale=3 means that the final number's going to have 3 decimal places.