Thanks for the very informative replies!
I try to address some questions, and maybe ask some more.
The original question was:
> What is the recommended way to make sure that a file is written
> physically to the disk? (apart from the cache of the disk.)
On 1/23/07, Eric Sandeen <sandeen@xxxxxxxxxxx> wrote:
Another issue that I've seen with grub is that it seems to like to write
directly to the block device WHILE THE FILESYSTEM IS MOUNTED.
It does not seem to do evil in this case:
3243 open("//boot/grub/stage2", O_RDWR) = 5
3243 fstat64(0x5, 0xf7c2e9f4) = 0
3243 mmap2(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff7bc4000
3243 _llseek(5, 0, , SEEK_SET) = 0
512) = 512
512) = 512
3243 close(5) = 0
Now, for me it seems to be a very interesting question that why people
would CARE whether it's synced or not, since they write it by the
filesystem layer anyway? I do not know, and investigating the reason
why 'grub-install' would worry about sync is beyond my available time.
The original problem was because grub-install froze xfs, then tried to
do the above, which magically fail on the frozen filesystem, hanging
the install till the cows come home. I tried to fix this, then started
wondering how to do it properly, and now that you mentioned and I
checked the trace I really start wondering about why to care... :-o