0

I have a problem with a MySQL application that write on a SD card or a Compact Flash. After a data loss (a power failure, for example), if I try to retrieve the data of my db, it fails and the error code is incorrect format table. If I try to see the files of my DB in filesystem I get can't stat file or directory (I/O error).

How can I overcome this problem: prevent it from happening or recover the contents of the db?

Setup:

  • A filesystem with ext2 filesystem (to prevent SD card multiple writings)
  • SD cards or DOM or Compact Flash as physical support
  • OS: TinyCore Linux Embedded - loaded in RAM
Chris S
  • 77,945
  • 11
  • 124
  • 216

1 Answers1

1

Those errors mean your file system is becoming corrupt (because it was in the middle of being written to when the power went out).

ext2 is not a journaling file system. Journaling file systems have more writes because they are keeping track of what they are about to do, then they actually go ahead and do it. When the power fails in the middle of the write, the OS can look at the log and say "oh, I was about to write this data over there", and repeat the step that was interrupted.

Switch to using something that has journaling. ext3 works, but isn't really designed for flash media. JFFS2 might be an option. There are dozens of other filesystems designed for exactly this use case, so try a few out and see what works well.

Grant
  • 17,859
  • 14
  • 72
  • 103