source: chapter02/creatingfilesystem.xml@ f001ece

11.3 11.3-rc1 multilib trunk xry111/arm64 xry111/clfs-ng xry111/glibc-2.37 xry111/kcfg-revise xry111/pip3 xry111/rust-wip-20221008
Last change on this file since f001ece was f001ece, checked in by Xi Ruoyao <xry111@…>, 6 months ago

creatingfilesystem: Refine the condition where a FS is needed

For example, a swap partition does not contain any FS. And, if you want
to clone a partition, you can use

dd if=/dev/<old-partition> of=/dev/<new-partition>

then it's unnecessary to create a FS on new-partition before operation.
This is sometimes faster than creating a new FS, mounting both
partition, then "cp -av" if the old-partition contains many small files.

  • Property mode set to 100644
File size: 3.4 KB
1<?xml version="1.0" encoding="ISO-8859-1"?>
2<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "" [
4 <!ENTITY % general-entities SYSTEM "../general.ent">
5 %general-entities;
8<sect1 id="ch-partitioning-creatingfilesystem">
9 <?dbhtml filename="creatingfilesystem.html"?>
11 <title>Creating a File System on the Partition</title>
13 <para>A partition is just a range of sectors on a disk drive, delimited by
14 boundaries set in a partition table. Before the operating system can use
15 a partition to store any files, the partition must be formatted to contain a file
16 system, typically consisting of a label, directory blocks, data blocks, and
17 an indexing scheme to locate a particular file on demand. The file system
18 also helps the OS keep track of free space on the partition, reserve the
19 needed sectors when a new file is created or an existing file is extended,
20 and recycle the free data segments created when files are deleted. It may
21 also provide support for data redundancy, and for error recovery.</para>
23 <para>LFS can use any file system recognized by the Linux kernel, but the
24 most common types are ext3 and ext4. The choice of the right file system can be
25 complex; it depends on the characteristics of the files and the size of
26 the partition. For example:</para>
28 <variablelist>
29 <varlistentry>
30 <term>ext2</term>
31 <listitem><para>is suitable for small partitions that are updated infrequently
32 such as /boot.</para>
33 </listitem>
34 </varlistentry>
35 <varlistentry>
36 <term>ext3</term>
37 <listitem><para>is an upgrade to ext2 that includes a journal
38 to help recover the partition's status in the case of an unclean
39 shutdown. It is commonly used as a general purpose file system.
40 </para>
41 </listitem>
42 </varlistentry>
43 <varlistentry>
44 <term>ext4</term>
45 <listitem><para>is the latest version of the ext family of
46 file systems. It provides several new capabilities including
47 nano-second timestamps, creation and use of very large files
48 (up to 16 TB), and speed improvements.</para>
49 </listitem>
50 </varlistentry>
51 </variablelist>
53 <para>Other file systems, including FAT32, NTFS, ReiserFS, JFS, and XFS are
54 useful for specialized purposes. More information about these file systems,
55 and many others, can be found at <ulink
56 url=""/>.</para>
58 <para>LFS assumes that the root file system (/) is of type ext4. To create
59 an <systemitem class="filesystem">ext4</systemitem> file system on the LFS
60 partition, issue the following command:</para>
62<screen role="nodump"><userinput>mkfs -v -t ext4 /dev/<replaceable>&lt;xxx&gt;</replaceable></userinput></screen>
64 <para>Replace <replaceable>&lt;xxx&gt;</replaceable> with the name of the LFS
65 partition.</para>
67 <para>If you are using an existing <systemitem class="filesystem">swap
68 </systemitem> partition, there is no need to format it. If a new
69 <systemitem class="filesystem"> swap</systemitem> partition was created,
70 it will need to be initialized with this command:</para>
72<screen role="nodump"><userinput>mkswap /dev/<replaceable>&lt;yyy&gt;</replaceable></userinput></screen>
74 <para>Replace <replaceable>&lt;yyy&gt;</replaceable> with the name of the
75 <systemitem class="filesystem">swap</systemitem> partition.</para>
Note: See TracBrowser for help on using the repository browser.