<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
  <!ENTITY % general-entities SYSTEM "../general.ent">
  %general-entities;
]>

<sect1 id="space-creatingfilesystem">
  <?dbhtml filename="creatingfilesystem.html"?>

  <title>在分区上建立文件系统</title>

  <!--para>Now that a blank partition has been set up, the file system can be
  created.  LFS can use any file system recognized by the Linux kernel, but the 
  most common types are ext3 and ext4.  The choice of file system can be 
  complex and depends on the characteristics of the files and the size of 
  the partition.  For example:</para-->
  <para>现在我们建立好了空白分区，可以在分区上建立文件系统。
	  LFS 可以使用 Linux 内核能够识别的任何文件系统，
	  最常见的是 ext3 和 ext4。
	  文件系统的选型是一个复杂的问题，要综合考虑分区的大小，
	  以及其中所存储文件的特征。例如：</para>

  <variablelist>
    <varlistentry>
      <term>ext2</term>
      <listitem><para>适用于不经常更新的小分区，例如 /boot。</para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>ext3</term>
	  <listitem><para>是 ext2 的升级版本，拥有日志系统，
			  能够在非正常关机的情况下恢复分区的正常状态。
			  它被广泛用于一般场合。
      </para>
      </listitem>
    </varlistentry>
    <varlistentry>
      <term>ext4</term>
      <listitem><para>是 ext 文件系统家族的最新成员，它具有纳秒精度时间戳、
      	  超大 (16 TB) 文件支持等新功能，速度也更快。</para>
      </listitem>
    </varlistentry>
  </variablelist>

  <!--para>Other file systems, including FAT32, NTFS, ReiserFS, JFS, and XFS are
  useful for specialized purposes.  More information about these file systems
  can be found at <ulink
  url="http://en.wikipedia.org/wiki/Comparison_of_file_systems"/>.</para>

  <para>LFS assumes that the root file system (/) is of type ext4.  To create
  an <systemitem class="filesystem">ext4</systemitem> file system on the LFS
  partition, run the following:</para-->
  <para>其他文件系统，包括 FAT32, NTFS, ReiserFS, JFS 和 XFS
	  在特定场合也很有用。关于这些文件系统的更多信息，可以在
	  <ulink url="http://en.wikipedia.org/wiki/Comparison_of_file_systems"/>
	  找到。</para>

  <para>LFS 假设根文件系统 (/) 采用 ext4 文件系统。
	  输入以下命令在 LFS 分区创建一个 ext4 文件系统：</para>

<screen role="nodump"><userinput>mkfs -v -t ext4 /dev/<replaceable>&lt;xxx&gt;</replaceable></userinput></screen>

<!--
  <para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the LFS
  partition (<filename class="devicefile">sda5</filename> in our previous
  example).</para>

  <note>
    <para>Some host distributions use custom features in their filesystem
    creation tools (E2fsprogs). This can cause problems when booting into your new
    LFS in Chapter&nbsp;9, as those features will not be supported by the LFS-installed
    E2fsprogs; you will get an error similar to <quote>unsupported filesystem
    features, upgrade your e2fsprogs</quote>. To check if your host system
    uses custom enhancements, run the following command:</para>

<screen role="nodump"><userinput>debugfs -R feature /dev/<replaceable>&lt;xxx&gt;</replaceable></userinput></screen>

    <para>If the output contains features other than
    <option>has_journal</option>, <option>ext_attr</option>,
    <option>resize_inode</option>, <option>dir_index</option>,
    <option>filetype</option>, <option>sparse_super</option>,
    <option>large_file</option> or <option>needs_recovery</option>, then your
    host system may have custom enhancements.  In that case, to avoid later
    problems, you should compile the stock E2fsprogs package and use the
    resulting binaries to re-create the filesystem on your LFS partition:</para>

<screen role="nodump"><userinput>cd /tmp
tar -xzvf /path/to/sources/e2fsprogs-&e2fsprogs-version;.tar.gz
cd e2fsprogs-&e2fsprogs-version;
mkdir -v build
cd build
../configure
make #note that we intentionally don't 'make install' here!
./misc/mke2fs -jv /dev/<replaceable>&lt;xxx&gt;</replaceable>
cd /tmp
rm -rfv e2fsprogs-&e2fsprogs-version;</userinput></screen>
  </note>
-->
  <!--para>If you are using an existing <systemitem class="filesystem">swap
  </systemitem> partition, there is no need to format it. If a new
  <systemitem class="filesystem"> swap</systemitem> partition was created,
  it will need to be initialized with this command:</para-->
  <para>如果您拥有一个现成的
	  <systemitem class="filesystem">swap</systemitem>分区，
	  就不需要格式化它。如果新创建了一个
	  <systemitem class="filesystem">swap</systemitem>分区，
	  需要执行以下命令以初始化它：
  </para>

<screen role="nodump"><userinput>mkswap /dev/<replaceable>&lt;yyy&gt;</replaceable></userinput></screen>

  <!--para>Replace <replaceable>&lt;yyy&gt;</replaceable> with the name of the
  <systemitem class="filesystem">swap</systemitem> partition.</para-->
  <para>命令中 <replaceable>&lt;yyy&gt;</replaceable> 应该替换成
	  <systemitem class="filesystem">swap</systemitem> 分区的名称。</para>

</sect1>
