SSD wear for overwriting the same bytes

1

If writing to an ssd wears out its cells but reading does not, does an ssd read cells to avoid unnecessary writes?

For example, suppose I already zero'd an SSD, would the SSD write anything at all if I were to try and re-zero it?

I think this may be covered by the general technique of SSD "data buffering & caching", but I've not read explicit details...

Is this dependent on the exact scenario, for example:
- The amount being written vs. the size of the SSD cache?
- The speed of the write being pushed vs. the speed SSD's reads (to check) and writes (as necessary)?
- The SSD controller?
- The SSD brand?

dumb0

Posted 2019-02-07T02:49:15.217

Reputation: 13

The only way you'll know from any specific hardware is to read the SMART information after writing to determine if it recorded it as writes. That said, using this data I've been able to determine that my own SSDs are going to far outlive any conventional drives I've ever had. – shawn – 2019-02-07T08:16:20.140

The actual likelihood that the sector data is 100% identical in practice is typically very low, so the overhead of performing such a read and compare is pure wasted time. Adding (unnecessary) overhead to a write operation is detrimental to performance. A manufacturer would probably choose to maintain performance (i.e. not add dubious overhead to every write operation) than possibly extend device life by occasionally not perform an erase/write cycle. – sawdust – 2019-02-07T10:04:57.557

Somewhat related to your example: How to fill a device with zeros, without overwriting the bytes that are already zeros?

– Kamil Maciorowski – 2019-02-07T10:36:00.990

Answers

2

It might, or it might not. Without knowing the exact model and it's exact firmware I don't think you can tell (and even then, unless you wrote the firmware it's still hard to be sure).

It's safe to assume that an SSD (or basically any flash media) might not overwrite what you want it to, it could:

  • write any sector anywhere
  • move old sectors to normally inaccessible "reserve" areas
  • some use compression, so writing GB's of zeros could take up virtually no space & actually write almost nothing
  • some always use encryption (whether or not you enter a password), and issuing a special "wipe drive" command only forgets the old encryption key & sets a new one, writing virtually nothing. (I've read some could implement this very poorly too)

The only constant should be that if you just wrote zeros somewhere, then you should read back zeros from there. But what actually happens behind the scenes is almost a literal "black box".

Xen2050

Posted 2019-02-07T02:49:15.217

Reputation: 12 097

"I've read some ignore zero writes and do a discard/TRIM instead" -- I'd be interested in reading about that. Please provide some links. Re: https://superuser.com/questions/1242000/can-i-emulate-trim-by-writing-all-zeros – sawdust – 2019-02-07T10:32:22.140

@sawdust I thought I remember reading something similar, but didn't find any concrete hits, so may have misremembered that detail, I'll remove it (it's kind of overlapping the compression case anyway, and the main idea is still "an ssd could do almost anything" ;-) – Xen2050 – 2019-02-07T11:02:25.493