Files
master/chapter02/mounting.html
2015-05-23 18:50:06 +08:00

139 lines
6.9 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content=
"application/xhtml+xml; charset=utf-8" />
<title>
2.4.&nbsp;挂载新分区
</title>
<link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
<meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
<link rel="stylesheet" href="../stylesheets/lfs-print.css" type="text/css"
media="print" />
</head>
<body class="lfs" id="lfs-7.7-systemd">
<div class="navheader">
<h4>
Linux From Scratch - Version 7.7-systemd
</h4>
<h3>
第二章&nbsp;准备新分区
</h3>
<ul>
<li class="prev">
<a accesskey="p" href="creatingfilesystem.html" title=
"在分区上创建文件系统">上一页</a>
<p>
在分区上创建文件系统
</p>
</li>
<li class="next">
<a accesskey="n" href="aboutlfs.html" title=
"设置 $LFS 变量">下一页</a>
<p>
设置 $LFS 变量
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter02.html" title=
"第二章&nbsp;准备新分区">返回</a>
</li>
<li class="home">
<a accesskey="h" href="../index.html" title=
"Linux From Scratch - Version 7.7-systemd">主页</a>
</li>
</ul>
</div>
<div class="sect1" lang="en" xml:lang="en">
<h1 class="sect1">
<a id="space-mounting" name="space-mounting"></a>2.4. 挂载新分区
</h1>
<p>
至此,文件系统已经创建妥当,下一步就是访问这些分区了。为此,需要将这些建立的分区挂载到选定的挂载点。本书假定的挂载点为 <code class="filename">/mnt/lfs</code>,这里,你可以根据喜好自行更改(译者注:这里强烈建议,看这本书的读者就将挂载点设置为 /mnt/lfs 吧,这样在自行后面的命令时,大多数命令都无需做任何的修改)。
</p>
<p>
运行以下命令,将欲选定的挂载点设置为 <code class="envar">LFS</code> 环境变量赋值:
</p>
<pre class="userinput">
<kbd class="command">export LFS=/mnt/lfs</kbd>
</pre>
<p>
下一步,创建挂载点并用下面的命令挂载 LFS 文件系统:
</p>
<pre class="userinput"><kbd class="command">mkdir -pv $LFS <font color="#999999"># 建立挂载点</font>
mount -v -t ext4 /dev/<em class="replaceable"><code>&lt;xxx&gt;</code></em> $LFS</kbd> <font color="#999999"># 将 /dev/<em class="replaceable"><code>&lt;xxx&gt;</code></em> 挂载到 $LFS</font>
</pre>
<p>
此处 <em class="replaceable"><code>&lt;xxx&gt;</code></em>
用实际的设备名称代替(下同)</em>
</p>
<p>
如果 LFS 使用了多个分区,(比如、一个 <code class=
"filename">/</code>,一个 <code class=
"filename">/usr</code>),用下面的命令挂载它们:
</p>
<pre class="userinput"><kbd class="command">mkdir -pv $LFS <font color="#999999"># 建立 / 分区的挂载点</font>
mount -v -t ext4 /dev/<em class="replaceable"><code>&lt;xxx&gt;</code></em> $LFS <font color="#999999"># 将 </font></kbd><font color="#999999"><kbd class="command">/dev/<em class="replaceable"><code>&lt;xxx&gt; 挂载到 </code></em></kbd></font><kbd class="command"><font color="#999999"><em class="replaceable"><code>$LFS</code></em></font>
mkdir -v $LFS/usr <font color="#999999"># 建立 </font></kbd><kbd class="command"><font color="#999999">$LFS/usr 挂载点,用于挂载 /usr</font>
mount -v -t ext4 /dev/<em class="replaceable"><code>&lt;yyy&gt;</code></em> $LFS/usr</kbd> <font color="#999999"># 将 /dev/<em class="replaceable"><code>&lt;yyy&gt;</code></em> 挂载到 <kbd class="command"></kbd><kbd class="command">$LFS/usr</kbd></font>
</pre>
<p>
(译者注:挂载是有顺序的!假如需要挂载以下分区:/、/usr、/usr/bin在挂载的时候只能按照这样的顺序挂载假如先挂载
/,然后挂载 /usr/bin再挂载 /usr 将会出错!)</p>
<p>
需要注意的是挂载的时候请不要使用过于严格的权限参数(比如 <code class="option">nosuid</code><code class="option">nodev</code> 选项)。用不带任何参数的 <span class="command"><strong>mount</strong></span> 命令查看挂载的 LFS 分区具体使用了哪些参数。如果设置了 <code class="option">nosuid</code><code class="option">nodev</code> 参数,请重新挂载。
</p>
<pre class="userinput"><kbd class="command">(译者注:使用不带任何参数的 mount 命令,可以得到类似如下的输出:<br>devtmpfs on /dev type devtmpfs (rw,relatime,size=500896k,nr_inodes=125224,mode=755)<br>其中,括号内的内容为挂载的参数<br></kbd>
</pre>
<p>
如果你正在使用<code class="systemitem">交换</code>分区,用 <span class="command"><strong>swapon</strong></span> 命令确保它已经启用。
</p>
<pre class="userinput">
<kbd class="command">/sbin/swapon -v /dev/<em class=
"replaceable"><code>&lt;zzz&gt;</code></em></kbd>
</pre>
<p>
<code class="systemitem">swap</code> 分区的名字替换<em class="replaceable"><code>&lt;zzz&gt;</code></em>
</p>
<p>
到现在,所有的准备工作都做的差不多了,是时候下载软件包了。
</p>
</div>
<div class="navfooter">
<div class="book">
<div class="titlepage">
<div class="author">
<span class="firstname">翻译团队:<a href="http://lctt.github.io/" target="_blank">LCTT</a></span>
<span class="surname">译者/校对:<a href="http://github.com/ictlyh" target="_blank">ictlyh</a>,<a href="http://github.com/dongfengweixiao" target="_blank">dongfengweixiao</a>,<a href="http://github.com/wxy" target="_blank">wxy</a></span>
</div>
</div>
</div>
<ul>
<li class="prev">
<a accesskey="p" href="creatingfilesystem.html" title=
"在分区上创建文件系统">上一页</a>
<p>
在分区上创建文件系统
</p>
</li>
<li class="next">
<a accesskey="n" href="aboutlfs.html" title=
"设置 $LFS 变量">下一页</a>
<p>
设置 $LFS 变量
</p>
</li>
<li class="up">
<a accesskey="u" href="chapter02.html" title=
"第 二章&nbsp;准备新分区">返回</a>
</li>
<li class="home">
<a accesskey="h" href="../index.html" title=
"Linux From Scratch - Version 7.7-systemd">主页</a>
</li>
</ul>
</div>
</body>
</html>