First, let's take a look at buffer and cache:
Buffer, to solve the disk write efficiency;
Cache to improve Disk Read efficiency.
In Linux, data is first placed in a buffer to improve the efficiency of disk reading and writing.
Writing data to a disk is not immediately written to the disk, but to the buffer.
If the system is restarted, data may be lost.
The sync command is used to flush the buffer of the file system so that the data is actually written to the disk and the buffer can be released.
Flush is used to clear the buffer.
The sync command forcibly writes data to the disk and releases the buffer corresponding to the data,
Therefore, you often enter the sync command after writing data to the disk to write data to the disk.
If you do not manually enter the sync command to write data to a disk, there will be two disk write times in linux:
1. kflush kernel threads periodically write data to disks;
2. The buffer is full and has to be written.
Questions to be confirmed:
Is there a kflush thread for periodic sync?