96 points · by goodburb · 2y ago · 68 comments
One of the anecdotes I distinctly recall was about a batch of cards that (for obvious cost saving reasons) used the actual data flash to store its own firmware as well.
IIRC due to a bug in the wear leveling accounting, once the card got sufficiently full, the wear leveling code ended up partially overwriting the firmware itself.
USB sticks seem to have the same issue with durability though. I've also had multiple of those fail on me. I'm currently eyeing those SSD USB sticks and I wonder how much more durable they might be.
The card is almost a decade old at this point but is there a way to recover data ?
10 years without power makes me think most of it wont be recoverable even if they can get to the data on it, but then again it depends on a lot of factors when it comes to flash memory.
You usually you have to read the entire drive to maintain, in my case S.M.A.R.T. reported changes to reserve blocks after doing that on an old drive.
I have a 16 year old 4GB SDcard with all data still intact.
I'm unsure if this is just urban legend or not, though. I've never tried myself.
It maybe stopped working once the OS decided the bytes were available for use (which it would only have done without the file marking that space as unavailable) and overwrote that section. I suspect defragmenting or otherwise moving the file about for whatever reason would have had the same effect.
Exposing the firmware in this fashion would be a bad idea for all of these reasons. It is a good thing that SD card manufacturers don't do this any more, if they ever did.
It's $6.84 per day for a membership.
If that's an outrageous amount to you, then: Please remember that you are absolutely free to direct your rage into creating your own competing portable flash storage systems, and to license them in any way that you wish.
You may even include a free pony, if you choose. It's your world.
Also, interesting thing one can do if you have a need for a CFExpress card (like a camera) and want to save some money. You can buy an adapter online such as the linked one, and then buy an m2.2230 ssd and put it in there. That’s how I made myself a cheaper 1TB CFExpress B card for my camera, and it’s doing just fine, even with 8k30fps at ~3.5Gb/s.
https://www.bhphotovideo.com/c/product/1685487-REG/monster_a...
Maybe someone here will know the answer to something I've been wondering for a while: When appending to a file with writes smaller than a sector, does this remapping process trigger every time? Or is the controller smart enough that it can append without remapping, even though to overwrite would need remapping?
Obviously for an SD card used for saving photos or videos you could write a sector at a time - but for an SD card in a temperature logger or similar, your appends might be a lot smaller.
Directly logging to an SD card (i.e. lots of small writes) is the fastest way to destroy it.
Couldn't you perform a file append without the need for a block erase? By keeping the unwritten area as all ones until written?
If you attempt to clear bits from 1 to 0 on an already written page, it will generally not work.
I say generally, because I have actually tried this using raw NAND flash on an embedded Linux device. I found a chip, where it did work, but not very reliably.
I also had an MLC chip, where it did not work, but instead caused random bit-flips on seemingly unrelated pages. I used this trick to systematically hammer down on the pages and figure out the pairings (only document in the NDA version of the datasheet), but failed to reproduce this on a different, more expensive MLC NAND.
But even if appending in this fashion did somehow work, you would still need to update a data structure somewhere else anyway, telling you the exact amount of data written (including cases where you actually append 0xff bytes).
I do know that very old flash firmwares applied that idea, and that new flash evolved in a direction where the wear caused by an erase is closer to the one caused by a write. If modern firmwares do not use it, it's probably because there isn't a lot to gain.
What are you supposed to do, then? Buffer up writes and accept that you'll lose logs a minute or so before a power outage?
As much hell as we had with those SD cards I'd rather put tiny iPod spinners in them...
When you are designing the hardware, you have lots and lots of choices.
They prepare and erase a new pool only when it's full causing bursts in speeds and long periods of unresponsiveness (10 sec) while writing, reading is blocked as well. You can see it as a zigzag in file transfer speed graphs. This is not to be confused with OS buffer flushing.
While I couldn't find any official info for the reasons behind it, it's assumed that the erase speed is slow on low quality flash and hence the controller has to pool in order to erase pages in parallel, increasing speed when copying small files between computers on plug and unplug.
In my case it was about 500MB before before freezing on a 128GB flash drive.
At the lowest level this means to update a page you have to first read it all back out, apply your modifications, then write back in a single operation. You must always write the full page size.
In high level contexts like SD cards or SSDs being driven by an operating system, all of this is handled transparently in the background. If you're using raw flash in an embedded context, you usually have to manage this yourself (or let a library do it for you).
I would like to see a card design which, instead of failing when there is flash wear, instead just gets smaller.
For compatibility with existing OS's, that would take the form of a self-partition-resizing sd card. It would understand fat32, ext3, NTFS, afs etc, and when the card is next powered up the partition would be slightly smaller and files physically at the 'end' would be moved inwards.
For newer OS's, a new API could be introduced which tells the OS 'this card is smaller now, please give me some blocks to mark as unavailable'.
The now-smaller card can use the removed-and-worn-out blocks to store error correction data for the remaining blocks. Ie. Additional error correction data on top of the data already stored within each page.
That effectively dramatically increases the lifespan of each page, at the cost of reduced IO performance.
You can get Swissbit pSLC (pseudo-SLC) SD cards from component distributers like Mouser and Digikey, and they are much more expensive, but should be "industrial grade". I've recently purchased a couple of their 8GB microsd cards for about $30 each (but haven't put them through a lot of real usage yet ...)
Develop it once, and you can make as many SD cards as you like reliable for no extra money...
The fact that they're used in dash cams, exposed to high temperature thermal cycles, and recording tens of terabytes of data which can be more than the typical consumer HDD/SSD in it's lifetime is quite impressive.
I imagine the RC plane's owner would get a real kick if years later the camera was found and they got the footage back.
(I used to work at Philmont Scout Ranch and would do a lot of detective work to get people their cameras back.)
So that for instance a 64 gigabyte would have a filesystem with 32 gigabyte space but with a lot of redundancy?
I know there are many ways to achieve similar outcomes but all I know of relies on knowing beforehand how to mount the thing.
And since it's a dataset setting instead of a pool setting, it can be applied selectively on a storage device.
"Oh, those photos are also backed up to Google Photos. It's maybe not ideal, but it's a lot of data and not worth keeping 2 copies those locally, so I'll leave those at the default of copies=1. But the this collection of code and short stories and I've written? That's pretty important to me, and it's actually kind of small -- I'll set that as copies=2. Actually, maybe copies=3 would be even better..."
The setting will stick with it between machines/sessions/whatevers without further user input. Things with copies=2 get mounted the same way as anything else is with ZFS in a given environment.
ZFS already detects bitrot very well even with copies=1, but it can't fix bitrot with chechsums alone. With copies=2, it has a non-zero chance at actually fixing it (or at least being completely readable so the data can be transitioned to the next storage device, completely intact).
https://docs.oracle.com/cd/E19253-01/819-5461/gevpg/index.ht...
The card is unaware of which bits of data are duplicates, and therefore can easily end up storing both copies of some data on areas of the physical flash that are weak - and this is even more likely considering they will probably be written around the same timestamp.