5

I'm working on an embedded system these days. It's needed to power off without the proper shutdown. We are thinking about Aufs like read-only file system. But the problem is there are some updatable data in the application as well as the user is allowed to change IP,date time etc. So, System needs an extra R/W partition.

I have several questions to clarify.

  1. How can we protect system corruption on sudden power failure?
  2. I want to know, what is the best filesystem for embedded system like this?
  3. Is ext3/ext4 like journal file system can be auto-recovered an incomplete file to back one always?
  4. Is BTRFS in RAID1 the best solution at the moment?
  5. Is there any other widely using solution in embedded systems for avoiding system corruption?
3

From a filesystem perspective using ext3 or ext4 with default options will normally provide you with enough crash consistency. You certainly won't suffer filesystem loss or damage to any files that haven't been written to right before the power loss.

There are many considerations about how to handle crash consistency on any filesystem. If your application only creates new files, or overwrites existing files by creating a temporary file and atomically overwriting with rename, then the default data=ordered mode of ext4 will be fine. Though until a call to fsync() on the file AND directory entry completes, or the OS flushes its cache there is no guarantee that the data will be there after a power failure. That's also assuming your storage devices honor the fsync().

If the application needs to guarantee consistency between file metadata and data while not caring about performance you could use data=journal so that all changes to files and filesystem metadata will be journaled, rather than just metadata. This will avoid incomplete write situations like a file size getting larger, but the data that was appended being lost and replaced with null chars.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.