Curious about sync(2)

So of course I had a power failure and ended up with a dirty file system and needed to run fsck manually.

Which leads me to the sync(2) system call. I understand according to the man pages that it runs every 30 seconds. Is that still true in version 10.x and 11.x? Just asking.

Is there any advantage in a home use environment (desktop, NAS, etc) to have that called more frequently? Can I turn off the cache? Remember this is a home environment, not Yahoo or Netflix. :)

Oh, no need to say it - yes I will go buy me a UPS eventually. :D
 
You may also want to read mount(8). The default is to just ensure metadata is always written consistently ( man mount | less -p noasync) and not data as a synchronous mount will be much slower. It's the metadata that ensures the filesystem itself is always consistent. In practice, when a program like a database or mail server needs data written to disk it will ask for a synchronous write before it can return success to the upper layers. A normal program that doesn't need that level of integrity for its data will end up queued in a buffer waiting for a sync(2). There's always a synchronous mount if you are that concerned about protecting the data along with the metadata and aren't concerned about the speed differences.
 
Back
Top