Linux – When is /bin/sync ever useful in modern linux

linux

I'm curious why /bin/sync exists. I understand what it does, why paging happens and why it's important that an operating system sync. However, I'm still failing to see when calling /bin/sync is useful.

It seems to me that Linux must already sync whenever anything important is going to happen (such as before a shutdown, the lack of which in proto-Linux lead to the sync; sync; sync; myth). If Linux is going to be reliable, and we all seem to believe it is, then I must assume it's going to ensure blocks are written to the FS before it runs a command that would harm the OS without a sync.

The sync(8) man page suggests that sync be run when a program is going to close in an improper manner. I sort of see this, though I think only a very tiny number of programs would have reason to use sync (and wait around to make sure the suggestion worked), but wouldn't be able to close through a cleaner method that lets the OS sync for them.

In any case sync(8) is not the same as the /bin/sync binary. I think I must be missing a situation where the binary is useful? The only use case I've seen is running it right before making a call to mem to free up more memory and perhaps give a slightly better idea of you 'available' memory. It would be useful if you somehow realized your computer was going to explode and had just enough time to type sync before it happened perhaps, but no one is doing that by hand, instead of some watchdog program calling sync(8).

Are there other advantages to the binary I'm missing?

Best Answer

"history of sync" is a tough thing to google for ;-) A totally uninformed guess is that at least one legitimate use is for kernel developers making changes to the sync(2) system call to test. They need a way to invoke the syscall that's a little more convenient than halting or umounting a filesystem?

Related Question