I'm playing with a Raspberry system, however I think my question is about Linux embedded in general.
We all know that the OS (linux or windows or whatever) *should* be gracefully powered down with a shutdown procedure (shutdown command in Linux). We must avoid cutting the power abruptly.
If this is possible for desktop systems, IMHO it's impossible to achieve in embedded systems. The user usually switch off a small box by pressing an OFF button that usually is connected to the main power supply input. In any case, he could immediately unplug the power cord without waiting for the end of the shutdown procedure.
I'm interesting to know what are the methods to use to reduce the probability of corruption.
For example, I choose to use a sqlite database to save non-volatile user configurable settings. sqlite is transaction based, so a power interruption in the middle of a transaction shouldn't corrupt the entire database. With normal text files this should be more difficult.
I know the write requests on non-volatile memories (HDD, embedded Flash memories) are usually buffered by OS and we don't know when they will be really executed by the kernel. Is there a method to force the buffered writing requests immediately?
Other aspects to consider?