Live data from Hacker News

SDcard wear leveling and translation layers (2014)

msreekan.com

51–60 of 72 posts

Re: SDcard wear leveling and translation layers (2014)

#51
post #49

Earlier quoted context omitted.

It isn't. Before a chip has firmware loaded, it can't decode filesystems.

Even after a chip has firmware loaded, which controller can make logical sense of a filesystem?

According to SDXC specs, the controller looks for exFAT markers to relocate the table and bitmap to smaller AU units.

exfatprogs can pack bitmap with table for SDHC and lower: https://manpages.debian.org/experimental/exfatprogs/mkfs.exf...

Re: SDcard wear leveling and translation layers (2014)

#52

Earlier quoted context omitted.

Pages that are already written cannot be overwritten, at least not without a full block erase, so it has to do a remap to append data. Directly logging to an SD card (i.e. lots of small writes) is the fastest way to destroy it.

As I understand it, you need a block erase to change bits from 0 to 1 then you can selectively set bits back from 1 to 0. Couldn't you perform a file append without the need for a block erase? By keeping the unwritten area as all ones until written?

Probably not for a variety of reasons. The SSD itself does not know about files or appends; only block reads and writes. If the OS fills the unused space with zeros then it's going to write a block with trailing zeros, not ones. Most SSDs also scramble or encrypt data before writing to flash.

Re: SDcard wear leveling and translation layers (2014)

#53

At a conference, I once met somebody who said his team had the joy of dismantling broken SD cards and figuring out why they broke. 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…

Have an SD card that was copying file on to and in the middle of transfer the card went kaput and hasnt seen since. No machine I try it on even acknowledges it existence. The card is almost a decade old at this point but is there a way to recover data ?

Best to consult a data recovery specialist, will cost you an arm and a leg though.

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.

Re: SDcard wear leveling and translation layers (2014)

#54
post #7

At a conference, I once met somebody who said his team had the joy of dismantling broken SD cards and figuring out why they broke. 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…

Man, I'd love to work in that team for a year. I've had so many SD cards fail on me (most recently a 1TB SanDisk Extreme which was used in my Steam Deck) and it feels like most of them are junk.

IIRC the denser the memory on the cards, the more likely problems are to arise. I forget the specifics but it has to do with the physics involving electronics on such a small scale. That's why industrial grade cards tend to be in much smaller capacities, but they are much longer lasting.

Re: SDcard wear leveling and translation layers (2014)

#55

Earlier quoted context omitted.

>> Couldn't you perform a file append without the need for a block erase? > You cannot do single byte writes on NAND. This isn't true - that the OP wrote here certainly does work (at least for many places I've tested and used it). I've used it to do all sorts of low level logging in small devices (and I've thoroughly tested many, many chips to complete destruction to see how things degrade). I have not yet seen a pla…

I was talking about bare NAND flash, not eMMC or anything otherwise "fancy" with builtin FTL. What you say is certainly true for those. None of the projects you describe sound "cheap" or like they involve devices first-and-foremost optimized for cost, and are unlikely to involve such dirt-cheap, raw NAND devices that are becoming increasingly rare even in the super-cheap embedded space. The original context of the di…

> I was talking about bare NAND flash

Same here.

> None of the projects you describe sound "cheap" or like they involve devices first-and-foremost optimized for cost

A lot of them are low cost PIC microcontrollers, which are super cheap, and the lowest cost MCUs were chosen precisely because at large commercial sale scale saving pennies on HW is very important. The reason we went to such lengths to reuse bits at the lowest level is because of needing the lowest cost devices on those projects.

Some were higher end, but I think it's more useful on low end chips.

Re: SDcard wear leveling and translation layers (2014)

#56
post #15

Earlier quoted context omitted.

ZFS can do this. Just set copies=2 on a dataset, and it'll always keep 2 copies of everything written thenceforth (with ~twice the storage usage). 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 th…

Is there even that much value to keeping multiple copies on the same device ? I fail to see what this adds over backups which can be done with any filesystem.

RAID is good (if one pays for it and makes it work).

Backups are better (if they actually get done, and if they are actually usable for recovery).

Backups + RAID is better yet.

But OP asked for a particular set of things that do not have any direct relationship to the traditional concepts of either backups or RAID, and ZFS can provide that set of things using copies=2.

It isn't for us to decide the value of this for them.

Re: SDcard wear leveling and translation layers (2014)

#57

Earlier quoted context omitted.

Have an SD card that was copying file on to and in the middle of transfer the card went kaput and hasnt seen since. No machine I try it on even acknowledges it existence. The card is almost a decade old at this point but is there a way to recover data ?

Best to consult a data recovery specialist, will cost you an arm and a leg though. 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.

Some amount of the data is almost certainly recoverable, but getting it done commercially is going to be $$$.

Re: SDcard wear leveling and translation layers (2014)

#58

Earlier quoted context omitted.

Pages that are already written cannot be overwritten, at least not without a full block erase, so it has to do a remap to append data. Directly logging to an SD card (i.e. lots of small writes) is the fastest way to destroy it.

That could explain why my dashcam is working fine after ten years whereas my previous job's IoT devices regularly ate SD cards. (Then again, the IoT devices were also overheating badly whereas the dashcam was designed for its purpose, kept cool while running, and runs on a low duty cycle) 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…

There are industrial microSD's with pSLC memory, e.g. Kingston's SDCIT2 line. Those are significantly more durable - in a few years of using them I haven't managed to kill a single one. Much pricier per-GB, though.

Re: SDcard wear leveling and translation layers (2014)

#59
post #29

Does anyone have access to the full specs of some SD cards? To get access to the full specifications it seems like you're forced to join the SD Association: 2500$ p/year

What is the point of charging for it, especially such an outrageous amount?

The SD Association is a non-profit organization, but that doesn't mean that they don't have expenses to pay and mouths to feed.

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.

Re: SDcard wear leveling and translation layers (2014)

#60
post #7

At a conference, I once met somebody who said his team had the joy of dismantling broken SD cards and figuring out why they broke. 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…

Man, I'd love to work in that team for a year. I've had so many SD cards fail on me (most recently a 1TB SanDisk Extreme which was used in my Steam Deck) and it feels like most of them are junk.

I read elsewhere here that if you fdisk/gdisk a partition that is one third of the drive and limit yourself to that space, then the drive will exhibit the reliability of SLC media, and last far longer than rated.
Post reply on HN