6 ms·
Historic note (like from the 80's) - any time a machine was rebooted we'd type sync; sync; sync; reboot - the explanation was that the only guarantee was that t
by bbunix 8y ago
Historic note (like from the 80's) - any time a machine was rebooted we'd type sync; sync; sync; reboot - the explanation was that the only guarantee was that the second sync wouldn't start until the first sync successfully completed, plus one for good luck...
- yyx 8y agohttps://utcc.utoronto.ca/~cks/space/blog/unix/TheLegendOfSync https://utcc.utoronto.ca/~cks/space/blog/unix/TheLegendOfSyn... people were told 'do several sync commands, typing each by hand' But this mutated to just 'sync three times', so of course people started writing 'sync; sync; sync'
- sgt 8y agoI still type sync (just once) before I reboot. Just a habit.
- beefhash 8y agoI always get some kind of error message from dmraid about having been unable to stop the RAID array on shutdown/reboot. I thus manually do a sync(1) in hopes that the data survives. Hasn't failed me thus far, at least.
- slavik81 8y agoThe only machine I ever developed on that needed a sync before reboot was an ancient SPARC workstation. I forgot to sync almost every time, but it would always boot after a fsck.
- noir_lord 8y agoThe last thing I do before I leave my work desktop for the day is ./eod.sh && sync && sync 20+ year old habits die hard.
- Jerry2 8y agoI have a flash drive that I sometimes put a video on to watch it on a small TV in the basement and I've noticed that Linux doesn't copy the file right away. The 'cp' does finish quickly but the data is not on the flash drive yet. You either have to eject and wait or sync and wait for it to actually transfer. Needless to say, this tripped me up few times and videos weren't fully transferred.
- pmontra 8y agoI also noticed that on Gnome. I never investigated the implementation details of that progress bar but my gut feelings is that the file is read from (or written to) the buffer cache quickly and the progress bar goes near to 100%, then stays there until the last writes succeed and actually write to the USB stick. Then the eject button sometimes need extra time to finish the sync and tells me to wait a little. I always remove the stick when it tells me it's safe to do it.
- loeg 8y agoYour intuition is correct. The writes are quickly buffered to RAM and then fsync or close writes them out to the slo media. The (naive) progress bar probably only tracks progress buffering the writes — it's the simplest way to track progress, if inaccurate.
- spatular 8y agoYes. You can also run "watch cat /proc/meminfo" in console and watch "Dirty" and "Writeback" fields to see dynamics (and how long you have to wait).
- snthd 8y agoThat behaviour is defined by a mount option.
- Jerry2 8y agoWhat's the proper way to mount flash devices?
- hyc_symas 8y ago"sync;sync;halt" - followed by turning off the power so we could open up the cabinet to do maintenance...