My embedded linux device uses an SD card for saving certain diagnostics data, far too copious for internal flash.
The problem is if the device is switched off unexpectedly, the filesystem (FAT32) on the card is corrupted.
There is no way to prevent unexpected power outages or user switching it off like that, and the device should be relatively maintenance-free. Worse, the data is written continuously, so the corruptions are very frequent, and Linux upon detecting faulty FS remounts it read-only silently.
What methods would you suggest to mitigate this? Will running fsck.vfat automatically on startup suffice?
Some more info:
- The card is not to be considered removable by user. It's to be thought of as internal disk. Any data stored on it will be accessible for download over the network or to a usb drive, and the system automatically purges oldest entries. That means it does not need to be readable in your average PC.
- The system currently supports FAT, yaffs and jffs2. Adding other filesystems to the kernel is possible but if other avenues exist, we'd prefer them first.
- Writing can be suspended on demand even for several minutes without data loss.
- partial data loss or minor corruption is acceptable. Complete stopping of logging is not.
- the poweroff events are completely unpredictable most of the time.
- the system is running on ARM9, 200MHZ, 64MB RAM, 32MB internal flash and uses up most of CPU power for its primary role. Take this into consideration while thinking of fancy resource-heavy solutions.