2 ms·
> SD not handing power loss well Is it that SD cards themselves don't "handle power loss well", or is it bad assumptions made by the filesystems chosen to be u
by derefr 7y ago
> SD not handing power loss well
Is it that SD cards themselves don't "handle power loss well", or is it bad assumptions made by the filesystems chosen to be used on them? Could a filesystem with a specific design avoid SD card corruption?
- aidenn0 7y agoPartial out-of-order writes can happen with an SD card. Most filesystems do not handle partial writes well, particularly when they happen out-of-order. A redundant checksumming filesystem like ZFS might be better, but that's only because ZFS can totally handle up to N drives per vdev going totally batshit (where N is configurable when setting up the vdev), not because it is designed for SD cards. Spinning drives can also have misdirected writes, but enterprise drives have for decades now (older than SATA) supported commands for flushing their caches, so proper barriers can be maintained.
- jrockway 7y agoMy limited understanding from reading articles on the topic is that the SD card is doing things like wear leveling in a way that the OS can't control, so if it loses power while it's doing that, your data is gone. It's like a separate computer, and the integrity of your data requires running the program to completion. It seems like a bad model if you ask me, but performance is what reviewers publish, not reliability under failing power, so this is what we get. It is obviously possible to fully journal these internal operations and recover them when power is next available (resulting in FS-level errors, instead of internal errors). But the cards do not do this. With eMMC, you just have the raw flash cells available directly, so you can write this code. With SD, you don't have enough control to write correct code, so you are stuck with what the vendor gives you.
- derefr 7y agoWhy does this same problem never occur with USB flash drives? Is it just that a USB device is usually large enough to have room for some power capacitors?
- Dylan16807 7y agoUSB is also designed so that data disconnects before power. I'm not sure if that's enough by itself.
- solarkraft 7y agoNot if the device loses power, right? I'm guessing USB flash drives will have the same internal mechanisms as SD cards and thus suffer from the same problems.
- Dylan16807 7y agoOh, are you talking about flash drives used as system drives on a Pi? Because in desktop use power rarely goes out and even more rarely has anything been written recently. In the Pi use case I have no idea.
- solarkraft 7y agoI have had 2 USB flash drives fail, one definitely after being unexpectedly disconnected (about the other one I don't know).