How should I format/repair a write-protected laptop SSD with I/O errors?

Solution 1:

You don’t. Once the drive is dead, it’s dead.

The drive is bad. Write protected mode is a safety feature to hopefully allow you to recover the data that is still there.

It’s time to recover what data you can and replace it.

Solution 2:

Flash chips are limited to writing information onto blank pages. Although flash drives can erase and reuse areas of storage, this is a relatively slow process, and is limited to erasing fairly large blocks of memory (typically e.g. 512 pages of 528 bytes) at a time. While it would be theoretically possible to design a flash drive that would respond to a write requests by erasing the old data and then immediately reusing the same storage, no practical drives do that. Instead, they will write the new data to a new location, and record somewhere the facts that the data should be read from a new location, and that the copy in the old location is no longer needed. When the drive is idle, it will find the blocks that have the largest number of obsolete pages on them and erase them in preparation for reuse.

All of this can work very well and very efficiently provided that the mechanisms the drive uses for storing book-keeping information remain reliable. If the bookkeeping information becomes corrupted, however, the drive may erroneously reuse blocks that hold live data. This would obviously be bad if the drives hold user data, but can be downright disastrous if the blocks hold bookkeeping data.

Although quality drives should maintain bookkeeping data with enough cross-checks to minimize the likelihood of data loss in case part of it gets corrupted, there are limits to the amount of cross-checking that drives can do while maintaining a reasonable level of performance. Consequently, if corruption is detected, many drives will enter a "safe mode" to avoid any possibility of further corruption.

A nasty quirk of flash memory, btw, is that if a block of memory has been erased a certain number of times, it may get into a state where reading it immediately after writing will correctly yield the data written, but bits may spontaneously change later after month or so. When everything is working correctly, drives will keep track of how many times each block has been erased and will cease trying to use a block once it has been erased too many times. If a drive's bookkeeping information gets corrupted, however, it will have no way of knowing how many times blocks have been erased, and thus have no way of knowing which blocks are safe to use. Worse, it will have no way of knowing whether any particular block that it has just written will be reliable for any meaningful length of time.

If one has data recovery tools that know how the bookkeeping information for a particular drive is stored, they may be possible to do a much better job of recovering drive contents than would be possible using normal methods of reading and writing. If a drive has both a "current" and "obsolete" copies of a a few blocks of bookkeeping information, for example, and some of the information that was corrupted on the current copies is correct on the "obsolete" ones, a data recovery tool may be able to use different combinations of old and new data to see if any of them "make sense" when looking at the drives' contents as a whole. A drive would not have enough RAM and CPU horsepower to accomplish such things, but specialized data recovery tools could. Because different drives use different bookkeeping approaches, however, I would expect the necessary tools to be highly specialized and for many types of drive might only exist on if a data-recovery specialist has needed to create one.