I originally asked this in a Facebook group for the Raspberry Pi, and on the Raspberry Pi StackExchange, but they keep latching onto the "standard" method of making a "RAM drive" inside of the operating system. That's not what I'm looking for.
I don't trust a solution that needs to thrash the card a lot before it figures out that it shouldn't thrash the card.

So: Is there a hardware device that plugs into a standard microSD slot and works like a standard microSD card, but reverts to a captured image of itself when it loses power?

Similar to this question, except that my system will be inaccessible. So I can't remove the card, re-image it elsewhere, and re-insert. The card itself has to do that automatically. (or whatever it is that connects to the card slot)

In terms of functionality alone, you might look at the Immutable flag in VirtualBox. It relies on VB's "snapshot" functionality, which uses a base image and a difference image. The base image is read-only, and all writes go to the difference image. Reads go to the difference image first, and then to the base image if not found. To revert, simply delete the difference image.

Storing the difference image in some on-card RAM would be a convenient way to revert on power loss, like I'm looking for. The system that uses the card remains unchanged. It can write to the card and read back what it just wrote, so long as there hasn't been a power loss in between.

Another way to do it could be to have an equal amount of on-card RAM as it has flash. When power is first applied, copy the flash into the on-card RAM, and then run entirely from the on-card RAM. Again, the system has no idea that this is happening, and simply uses the card as usual.

A brute-force method could be to have twice the amount of flash as advertised, and use half of it to re-image the other half. This has the disadvantage of wearing out the flash cells faster than usual because all of them (in the working set) get erased and rewritten on every power cycle in addition to the normal use.

Regardless of how it actually works, is there a device that has this external functionality? Use it like a normal microSD card, then capture an image of itself and continue to use it normally...except that it now reverts to that captured image on a power cycle?

  • I'm intrigued, but frankly, I seriously doubt there's anything that exists like this; you seem to be fairly experienced in EE, so if you really, truly, want this, you'll probably have to build it yourself. I think the Pi StackExchange people have a point though: at some point, you're going to have to have a software solution dealing with sticking the data in the appropriate place. Sure, if you want to have this being done in some external box which appears as a microSD card, you probably can do it, but is it really worth the effort? (cont.)
    – JMY1000
    Sep 25 '19 at 3:39
  • 1
    There's a reason this is (usually) solved by booting from a network drive rather than a box attached to the actual physical port of a device. I very much understand the appeal of having such a device, but it's an immense amount of complexity for something that very well may be better dealt with another way.
    – JMY1000
    Sep 25 '19 at 3:43
  • Some OS like opensuse support booting into a read only file system. Others can use BTRFS snapshots to captures changes, and then revert to the original snapshot. Probably setup a cron job to periodically delete the old snapshots. I don't know the exact HOW TO but you can research those options.
    – cybernard
    Aug 19 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.