One of the limitations of Solid State Drives is that the Flash cells can’t be rewritten indefinitely. The cells on the SSD drive I recently bought can only be rewritten around 1000 times. That doesn’t sound like much but wear leveling ensures that desktop users with normal use don’t have to worry about it. AnandTech has a good analysis on how wear leveling works and how long I should be able to use my SSD here. According to these calculations, my 500 GB version should be good for at least 14 years, based on a daily write amount of 10 GB and and a write amplification factor of 10. So while I believe those numbers I was wondering how how much data I actually write to disk on average per day. As I use Ubuntu Linux I found a couple of interesting counters that shed some more light on this:
The first one is /proc/diskstats. It lists all block devices and lots of counters for them. For my SDD which is the ‘sda’ device in the list, field 7 contains the number of sectors written since boot time. A sector is 512 bytes so one can easily calculate the number of bytes written since power on.
The second is /sys/fs/ext4/sda1/lifetime_write_kbytes. As the name suggests this counter contains the overall total and is only available for ext4 formated volumes. Since I only use one volume and no swap partition (due to my 8 GBs of RAM) these two counters should actually increase by the same value over time.
Here’s a command line displays both counters and strips away all other information the commands also output:
date; awk '/sda/ {print $3"\t"$10 / 2 / 1024}' /proc/diskstats; cat /sys/fs/ext4/sda1/lifetime_write_kbytes
The result: I am using this computer for about half a year now and the total lifetime writes give me 922 GB. Divided by approx. 180 days, that’s approx. 5 GB of data written to the drive per day on average. The data written since power on gives me a similar value, around 4 GB per day. Comparing that to the 10 GB a day used in the AnandTech post for estimating my SSD lifetime, I should be good for twice their calculated amount, i.e. no write issues due to wear out of the flash cells due to writing for the next 30 years. A comforting result.
So while it is comforting that my average daily use is less than what was used in AnandTech’s caclulations, I’d still like to understand a bit better why my daily average is around 5 GB of data written to the drive as it seems to be quite a lot and I am not using the drive (or the sda1 volume queried) for memory swapping at all.
Browser caching and video consumption? Is there a difference in between block sizes and actual file sizes too.
It seems with the below findings, Notebooks are the only safe place to put SSDs, for now:
https://www.usenix.org/system/files/conference/fast13/fast13-final80.pdf
[quote] Our experimental results reveal that thirteen out of the fifteen tested SSD devices exhibit surprising failure behaviors under power faults, including bit corruption, shorn writes, unserializable writes, meta- data corruption, and total device failure. [/quote]
(via http://www.zdnet.com/how-ssd-power-faults-scramble-your-data-7000011979/)