[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sleep(1) vs. sync(1) twice before umount(8)



Hi,

fxkl47BF@protonmail.com wrote:
> > The only reason I ever got was that the second sync was a time delay

The web has it that the time to toggle s-y-n-c-Enter would be enough
to have the first sync succeed.
Another story is that some ancient tape drives (or drivers) rewound the
tape if a second SYNCHRONIZE CACHE command arrived (or some ancestor of
said SCSI command).
I dimly remember a MicroVAX where the shutdown command was: sync;sync;halt

sync;sleep seems to have been necessary with Linux in the previous century.
man 2 sync:

  BUGS
   According to the standard specification  (e.g.,  POSIX.1-2001),  sync()
   schedules the writes, but may return before the actual writing is done.
   However, since version 1.3.20 Linux does actually  wait.   (This  still
   does not guarantee data integrity: modern disks have large caches.)

I had no USB devices back then and always cared to shutdown properly.


David Christensen wrote:
> I sometimes type sync(1) twice when I am
> distracted with several irons in the fire and/or when the system is making
> me worried,

I think one sync per participating device in the dev-mapper stack should be
enough nowadays.

But i would not rely on umount to make a USB stick ready for pulling,
even if experiments show that it happens reliably.
The man pages umount(8) and umount(2) do not guarantee that the device
gets synced. Future programmers might take this as permission to break
things in favor of improved performance.


Have a nice day :)

Thomas


Reply to: