Is it really necessary to call /bin/sync twice before an unmanaged power-off?
- by Jeremy Friesner
Hi all,
My company sells an "embedded device" which is implemented as a headless Linux box with ext4 on an internal SSD. Some of our users have a habit of doing a "save current settings" on this box, and then cutting power to the unit as soon as the unit reports that the save completed (ie two seconds later). This was causing occasional corruption of the saved files, as the data wouldn't always get flushed to the SSD before the power went out. So I tweaked my software to run /bin/sync immediately after writing the file (after closing the file handle but before notifying the user that the save completed). This appears to fix the issue, but my coworker says that one call to /bin/sync isn't sufficient, and that to be really safe I ought to run /bin/sync twice in a row.
That sounds like paranoia to me... Perhaps a habit from earlier versions of Linux or unix whose sync utility didn't work reliably. Does his advice have merit, or should one call to /bin/sync suffice?