Re: sync seems does not work fine?

Pawel S. Veselov (vps@beta.niimm.spb.su)
Tue, 13 May 1997 09:40:12 -0300 (GMT)


Hello, Jordi!

On Mon, 12 May 1997, Jordi Sanfeliu wrote:

>Before explain the problem, the better way is test it. Please, test this
>with a big file (hmmm ... 1Mb of data, more or less)
>
># tar cvf /dev/fd0 ./bigfile
>
> or
>
># mount /dev/fd0 /mnt
># cp bigfile /mnt

I copied 1.44M files and everything was OK.

>Well, when you press Enter the copy is begin (obvious), in this moment,
>Linux starts the copy of this file to /dev/fd0, and Linux give you the
>prompt in 2 or 3 seconds. Note that, in this point, the file is not still
>copied totally.

No, actually it does. The copy starts just after you pressed ENTER.

>BUT, if you executes a "sync" command in this moment (so you are requesting
>to Linux that this should be copied NOW !!), then you will haven't the
>prompt until the file be copied totally and this session will be "locked". (?)

sync is a command for flushing disk caches. When you do cp, linux reads the
file into cache, then began to slowly write it down to the destination. Why
overload disks, if there is enough free memory ? You can believe, when you
try to copy enough large file from/to HDD you'll get the same situation.
The sync can guarantee you, that all data in cache, intented for writing is
actually written. This is why it "locks" you session -- it just say to the
kernel to flush the cache, and wait for the completion. It can guarntee you,
that after this command you can eject you floppy.

Bye.

--
$100 invested at 7% interest for 100 years will become $100,000, at
which time it will be worth absolutely nothing.
		-- Lazarus Long, "Time Enough for Love"

--
    With best of best regards, Pawel S. Veselov (aka Black Angel)
                 internet : vps@beta.niimm.spb.su
                  fidonet : 2:5030/5.412
                schoolnet : 21:9000/412
                 Web page : http://www.niimm.spb.su/~vps/