📄 node69.html
字号:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->
<html>
<head>
<title>More about shutdowns</title>
<meta NAME="description" CONTENT="More about shutdowns">
<meta NAME="keywords" CONTENT="sag">
<meta NAME="resource-type" CONTENT="document">
<meta NAME="distribution" CONTENT="global">
<link REL="STYLESHEET" HREF="sag.css">
</head>
<body LANG="EN">
<a NAME="tex2html1162" HREF="node70.html"><img WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" ALT="next" SRC="./next_motif.gif"></a> <a NAME="tex2html1160" HREF="node66.html"><img WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" ALT="up" SRC="./up_motif.gif"></a> <a NAME="tex2html1154" HREF="node68.html"><img WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" ALT="previous" SRC="./previous_motif.gif"></a> <a NAME="tex2html1164" HREF="node1.html"><img WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" ALT="contents" SRC="./contents_motif.gif"></a> <a NAME="tex2html1165" HREF="node108.html"><img WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" ALT="index" SRC="./index_motif.gif"></a> <br>
<b> Next:</b> <a NAME="tex2html1163" HREF="node70.html">Rebooting</a>
<b>Up:</b> <a NAME="tex2html1161" HREF="node66.html">Boots And Shutdowns</a>
<b> Previous:</b> <a NAME="tex2html1155" HREF="node68.html">The boot process in </a>
<br> <p>
<h1><a NAME="SECTION00730000000000000000">关于关机的更多信息</a></h1>
<p>
关闭Linux系统时,遵循正确的过程是很重要的。否则,文件系统可能成为废物,文件可能变成杂乱的。
这是因为Linux使用磁盘缓存,并不立即将数据写到磁盘,而是间歇地回写。
这极大地改善了性能,但同时也意味着如果你只是关闭电源,cache可能保留着大量数据,而磁盘上的数据可能不是一个
全部的正在工作的文件系统(因为有些数据已经回写到硬盘,而有些没有)。
<a NAME="2033"> </a>
<a NAME="2034"> </a>
<a NAME="2035"> </a>
<a NAME="2036"> </a>
<p>
另一个不能直接关闭电源的原因是:在多任务系统中,后台可能运行着很多东西,关闭电源可能损失惨重。
使用正确的关机顺序,可以保证所有的后台进程得以保存他们的数据。
<a NAME="2037"> </a>
<p>
正常关闭Linux系统的命令是<tt>shutdown</tt><a NAME="2139"> </a>。
它通常使用2种方法之一。
<a NAME="2039"> </a>
<p>
如果系统只有你一个用户,使用<tt>shutdown</tt><a NAME="2141"> </a>的通常方法是退出所有运行程序,
从所有虚拟控制台注销,用<tt>root</tt>登录(如果你已经是<tt>root</tt>,当然不必再注销、登录,但应该换到
根目录,以免由于unmount出现问题),然后运行命令<tt>shutdown -h now</tt><a NAME="2044"> </a>
(虽然单用户时一般不必要,但如果需要一个延时,用一个加号加一个表示分钟的数目代替<tt>now</tt>)
<p>
如果系统是多用户,使用命令<tt>shutdown -h <i>+time message</i></tt>,
<i>time</i>是到系统停止的分钟数,<i>message</i>是告知所有用户系统关机原因的短信息。
<blockquote> <tt>
# shutdown -h +10 'We will install a new disk. System should <br>
> be back on-line in three hours.' <br>
#
</tt></blockquote>
上面的命令警告所有用户,系统将在10分钟后关闭,他们最好保存信息,否则将丢失。
警告将显示在所有登录的终端上,包括所有的<tt>xterm</tt><a NAME="2143"> </a>上:
<blockquote> <tt>
Broadcast message from root (ttyp0) Wed Aug 2 01:03:25 1995... <br>
<br>
We will install a new disk. System should <br>
be back on-line in three hours. <br>
The system is going DOWN for system halt in 10 minutes !!
</tt></blockquote>
警告在系统关闭前将自动重复数遍,随着时间流逝,间隔越来越短。
<a NAME="2054"> </a>
<p>
当延时之后关闭系统真正开始时,所有文件系统(除了根)被unmount,所有用户进程(如果有人还未注销)被终止,
守侯进程被关闭,所有东西都停下来。此后,<tt>init</tt><a NAME="2145"> </a>打印出一条信息告知
你可以关掉电源了。此时,<em>也只有在此时</em>,你才可以关闭电源。
<a NAME="2057"> </a>
<p>
有时(虽然在任何好的系统上极少),系统可能不能正常关闭。例如,核心紊乱、崩溃等不正常情况,可能无法键入任何命令,
因此正常关机可能有些困难,这是只能直接关机。问题可能没那么严重,比如,有人误动了你的键盘,核心和<tt>update</tt><a NAME="2147"> </a>
程序还在正常运行,等待一些时间可能是个好建议,这能使<tt>update</tt><a NAME="2149"> </a>有机会将缓冲cache
中的数据回存硬盘,然后再直接关机。
<a NAME="2060"> </a>
<a NAME="2061"> </a>
<a NAME="2062"> </a>
<a NAME="2105"> </a>
<a NAME="2064"> </a>
<a NAME="2065"> </a>
<a NAME="2106"> </a>
<p>
有人喜欢用<tt>sync</tt><a NAME="2151"> </a><a NAME="tex2html30" HREF="footnode.html#2107"><img ALIGN="BOTTOM" ALT="gif" SRC="./foot_motif.gif" WIDTH="15" HEIGHT="15"></a>
三遍来关闭系统,等到磁盘I/O停止,然后在关闭电源。如果没有什么程序运行着,这和用<tt>shutdown</tt><a NAME="2155"> </a>等效。
然而,它不unmount任何文件系统,可能导致ext2fs的"干净文件系统"标志出问题。这种3遍sync的方法是<em>不推荐使用</em>的。
<a NAME="2071"> </a>
<p>
(In case you're wondering: the reason for <em>three</em> syncs is
that in the early days of UNIX, when the commands were
typed separately, that usually gave sufficient time for most
disk I/O to be finished.)
<p>
<hr><a NAME="tex2html1162" HREF="node70.html"><img WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" ALT="next" SRC="./next_motif.gif"></a> <a NAME="tex2html1160" HREF="node66.html"><img WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" ALT="up" SRC="./up_motif.gif"></a> <a NAME="tex2html1154" HREF="node68.html"><img WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" ALT="previous" SRC="./previous_motif.gif"></a> <a NAME="tex2html1164" HREF="node1.html"><img WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" ALT="contents" SRC="./contents_motif.gif"></a> <a NAME="tex2html1165" HREF="node108.html"><img WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" ALT="index" SRC="./index_motif.gif"></a> <br>
<b> Next:</b> <a NAME="tex2html1163" HREF="node70.html">Rebooting</a>
<b>Up:</b> <a NAME="tex2html1161" HREF="node66.html">Boots And Shutdowns</a>
<b> Previous:</b> <a NAME="tex2html1155" HREF="node68.html">The boot process in </a>
<p><address>
<i>Lars Wirzenius <br>
Sun Jun 29 13:31:22 EEST 1997</i>
</address>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -