std_match
Advanced Member level 4
I have an embedded linux system with a mounted SD-card.
Normally, only read operations are done, but sometimes a file must be updated.
What is the best way to minimize the risk for a corrupted file system?
Power down can occur at any time.
Here are the two alternatives I'm considering now:
1. The file system is normally mounted "rw" (read/write).
After a write, the "sync" command is executed immediately to flush the buffers and write to the SD-card.
2. The file system is normally mounted "ro" (read only).
Before a write, the file system is remounted as "rw".
After the write, it is remounted again as "ro".
Alternative 1 can probably not be safer than alternative 2, but maybe they are equal?
Are there other alternatives?
Normally, only read operations are done, but sometimes a file must be updated.
What is the best way to minimize the risk for a corrupted file system?
Power down can occur at any time.
Here are the two alternatives I'm considering now:
1. The file system is normally mounted "rw" (read/write).
After a write, the "sync" command is executed immediately to flush the buffers and write to the SD-card.
2. The file system is normally mounted "ro" (read only).
Before a write, the file system is remounted as "rw".
After the write, it is remounted again as "ro".
Alternative 1 can probably not be safer than alternative 2, but maybe they are equal?
Are there other alternatives?