Dear ALL, Could you please share your solutions on how to ensure filesystem consistency of SD card (didn't check NAND with YAFFS filesystem) when power of the board is turned off unexpectedly. Currently I have a problem with this issue. I'm using ext2 filesystem on SD card. The board is running application and when the power cut off without proper shutdown sequence the SD card filesystem has errors. These errors may cause any unpredictable behavior of further operation or might make the card unbootable. Ofcourse it is possible to use fsck to check and fix the errors, however sometimes it is impossible to make it silently, because if the serious error is found fsck asks the user to confirm repairement. So, my question is how to ensure filesystem consistency? Is there any solution that may help here?
Filesystem consistency when power off unexpectedly
A technique that seems common on 8bit system, like the AVR ATmega series is BOD (brown-out detection). The process is: a brown-out is detected and using sufficient power supply storage you shut the system down gracefully. Searched the S3C2440 datasheet and found no mention of <brown-out>. We use this part in power board supervisory equipment but am not familiar with our shut-down procedure. If no one else replies with a helpful answer in the next 12 hours I'll talk to the man who knows the answer. Dave
I'm using the "FSCKFIX=yes" option in /etc/default/rcS. The default is "no" and for me the board just stopped at startup because it wanted me to confirm that all errors should be fixed. Now with yes it seems to work just fine, but I've read that it maybe doesn't fix all errors perfectly, no idea how serious that problem is. But I would be happy to hear if someone has any better solutions. Some more info: http://www.linuxquestions.org/questions/linux-general-1/how-to-auto-answ...
Actually I'm using ext3, forgot to write it. But I think ext3/ext4 does some more writing/reading to the SD card which after some time might do some "bad sectors", no idea how big the problem actually is, would be nice to hear if someone actually has destroyed a SD card with too many reads/writes.
Many thanks Dave, I will take the BOD facility in view if I use systems other than S3C2440. stereo_m, my testers tried to play with the system by turning off power in some various way while application was running and I saw several types of filesystem errors up to disappearing files and folders. I don't know how to say it correctly, but disappeared files were highlighted with red color in midnight commander, anyway it made them missing. Now I'm trying to use journaled filesystem and test it.
I'll throw another idea in. The guys here use an external watchdog chip and it's reset triggers a database save . . . somehow. On a reset could you save to whatever non-volatile memory you can write to the fastest and on resumption of the system then write that to the SD card? Maybe you can write fast enough to the SD card.
Why are you not trying it with special filesystem for flash media like JFFS2 or YAFFS2? As far as I know at least YAFFS2 has high priority on data integrity so data can't get lost easily.