5

I'm trying fully understand the sync command operations in linux OS.

After reading: https://en.wikipedia.org/wiki/Sync_(Unix) https://lwn.net/Articles/457667/

I understood that sync command responsible for flushing data all the way from application's buffers to permanent storage.

  1. how linux tracks it's permanent storage devices and their suitable writing requests? (inside /dev we have many device files not all of them represnt permanent storage devices) where can I see each device's awaiting writing requests?

  2. does sync (specifically sync command) scans all system's devices for writing requests and performs all of them? does it maintain some efficient list?

  3. how virtual file systems related to sync command? does sync command scans each filesystem? if so why?

  4. is there any literature regarding this command and its "backstage" operations?

3
  • One small correction: sync doesn't touch applications' buffers, only kernel buffers. Nov 26, 2019 at 15:07
  • this Q is related: unix.stackexchange.com/questions/545917/… (gives a practical side to the Q)
    – user373503
    Nov 27, 2019 at 16:25
  • Your question is massively interesting, but it is very broad: each point would require a thoroughful answer and, together, they could be too much. Why don't you consider splitting the question?
    – BowPark
    Nov 29, 2019 at 11:44

1 Answer 1

4

This manpage might clarify things a bit.

What I read between the lines is that every filesystem implementation has to provide a sync-method.

So the sync command just calls the Kernel, which in turn calls all sync-methods - propably for all mounted filesystems.

Perhaps you can find better explanations of what is happening there when looking into the kernel-code for sync.

Not the answer you're looking for? Browse other questions tagged .