Re: how to sync / commit data to disk?

Geir A. Myrestrand
2007-01-23T16:40:37Z

Peter Gervai wrote:
> Hello,
>
> [Tried to search archieves, found nothing, probably my keywords are bad.
> :-)]
>
> What is the recommended way to make sure that a file is written
> physically to the disk? (apart from the cache of the disk.)
>
> This problem seem to have arisen in grub bootloader under Debian linux
> (and most probably everywhere else): it must be sure that the copied
> files are there, and can be addressed by C/H/S and modified there, at
> the given sector address.
>
> My educated guess would be
> xfs_freeze -f
> sync
> xfs_freeze -u
>
> but I give a large chance to be wrong about it.
>
> Ideas?
>
> Please cc on me if possible. Thanks.

Call the sync before you freeze the file system, not after. You can't
write to the file system when it is frozen, so it makes no sense to call
sync after a freeze.

I don't think you have any control of whether the data is written
physically to the disk or is still in the disk(s) buffer, the buffer you
can flush is on the software side. Call sync and freeze.

--

Geir A. Myrestrand