Hi, I'm working on a data logger project. My system is running with a custom kernel (version 2.6.32.2). The main program was written in c++ and uses a database (sqlite 3.7.8) to store all collected data. I need to save everything on the database wich is placed on a sd card. The sdcard was formatted with FAT. Sometimes the files inside it gets corrupted. So I need to run the "chkdsk" windows command to try to recover those files (sometimes I can't recover the files, and this is really boring). Sometimes the equipment is suddenly powered down (I can't avoid it), and I think that's a possible (or the main) reason of the problem. I decided to change from FAT to EXT3, because EXT3 have the journaling system (I read that journal keeps the information about file operations). I think that journal could help me, but I'm not sure. I'm noob on linux. So, I have 2 questions. 1 - Using the EXT3 filesystem, will really help to prevent those corruptions? 2 - Is there another way to prevent that? Tutorials, books and any links are welcome
Avoid file corruption - SD card
Mount the filesystem on this SD card with option "sync". This will slow down disk accesses but keeps your data more save. The "sync" setting is independent of the filesystem you are use.
Hi Juergen, Thanks for your response. I'm already using this option. The mount script is: /bin/mount -o sync -o noatime -o nodiratime -t vfat /dev/$DEVNAME $MOUNTPOINT from "/bin/hotplug.sh"
Then it seems the SD card itself loses the data when the supply is cut. When the operating system has written the data to the card, and the card fails after that, there is no hope for you.
I discovered that EXT3 have 3 operation modes (http://linux.die.net/man/8/mount): journal - All data is committed into the journal prior to being written into the main filesystem. ordered (default) - This is the default mode. All data is forced directly out to the main file system prior to its metadata being committed to the journal. writeback - Data ordering is not preserved - data may be written into the main filesystem after its metadata has been committed to the journal. This is rumoured to be the highest-throughput option. It guarantees internal filesystem integrity, however it can allow old data to appear in files after a crash and journal recovery. Journal mode seems to be the safest, but is slower. I think this will prevent any folder/file structure corruption as happened with FAT.