Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Nov 2012 07:36:11 +0100
From:      Polytropon <freebsd@edvax.de>
To:        freebsd@dreamchaser.org
Cc:        FreeBSD Mailing List <freebsd-questions@freebsd.org>
Subject:   Re: why sync during shutdown when sync already done?
Message-ID:  <20121115073611.acfe39f5.freebsd@edvax.de>
In-Reply-To: <50A4544E.7030805@dreamchaser.org>
References:  <50A4544E.7030805@dreamchaser.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 14 Nov 2012 19:32:46 -0700, Gary Aitken wrote:
> It's my understanding that the sequence of numbers one sees output when
> shutdown is issued reflect writes of cached items.
> Is that correct?
> 
> If so, why does:
>   sync
>   shutdown -r now
> still show cached items being written?

Issuing the "sync" command simply tells the OS to sync
any modified file I/O buffers (cache) that aren't written
yet. It does not imply that the OS will do it _exactly now_,
and even more, that it will _have done_ it when the command
returns. So if you call sync(), the kernel will be
instructed to perform the syncing operation. But keep
in mind that the actual device drivers (e. g. for the
hard disk in question) may delay the transfer to the
disk, but tell the kernel that the operation has been
completed. This minimal time window can probably be
ignored, but from my understanding, syncing is a
"multi-staged process". The "shutdown sync" seems to
have a specific timeout that makes sure things get
written definitely.

That's why even the famous

	# sync ; sync ; sync ; reboot

sequence would have the same effect. :-)



-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121115073611.acfe39f5.freebsd>