0

I'm writing some bytes to the filesystem. Afterward I'm calling sync to ensure the buffered data is flushed to the SD card. This command takes several seconds!

I'm working with raspbian. My SD Card is a 16GB Kingston Class 10 (industrial). Logging the disk io with sudo iotop -o -d 1 -a say, that only some 100 KBytes are written to disk.

To find out the source of the problem I'm doing following:

  • Watching the output of sudo iotop -o -d 1 -a in one Terminal
  • Run some application that writes about every minute some 100Kbytes
  • Calling time sync in an other terminal after the write is done. This one takes sometimes several seconds (up to 5sec). (if nothing is written to disk it takes only some milliseconds)

Whats wrong that sync takes as long?

  • How are you calling sync? What command line options? – Craig Jun 20 '18 at 14:52
  • How often are you calling sync? – Craig Jun 20 '18 at 15:38
  • sync has no args. Calling sync after writing some kb to the filesystem. – powerpete Jun 21 '18 at 6:39
  • What is the frequency of the calls? How many times per second/minute/hour? – Craig Jun 21 '18 at 14:06
  • Added some additional info – powerpete Jun 22 '18 at 7:03
0

Until sync or flush is called, the writes to the filesystem might be cached in RAM. Or perhaps metadata to the filesystem isn't written yet.

Once sync is called, all this data must be really written to the filesystem.

This is why it's a bad idea to turn any linux system off until you've shutdown, which does the equivalent of a sync. Some cached data might not have been written yet, or you could be turning it off in the middle of a write.

  • 1
    nice explanation what sync is doing. The Question why it takes so long remains open. – powerpete Jun 25 '18 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.