Is it really necessary to call /bin/sync twice before an unmanaged power-off?

Posted by Jeremy Friesner on Server Fault See other posts from Server Fault or by Jeremy Friesner
Published on 2011-01-05T22:34:36Z Indexed on 2011/01/05 22:55 UTC
Read the original article Hit count: 268

Filed under:
|
|
|

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?

© Server Fault or respective owner

Related posts about linux

Related posts about ext4