Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

This link sums it up pretty well -- One call to sync should suffice. Doing it more than once is definitely a holdover (and one I stick to myself), but if you're doing it programmatically you aren't gaining anything - it's the delay it takes you to type out those 5 keystrokes that you were really going for.

Of course the real answer is to officially discourage yanking the power, and instead provide a shutdown feature that users are told to use, but you'll always have to deal with plug-yankers...

share|improve this answer
    
+1 for giving the user a way to gracefully shutting down the system within the UI. –  mrdenny Jan 5 '11 at 23:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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