⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 286-288.html

📁 linux-unix130.linux.and.unix.ebooks130 linux and unix ebookslinuxLearning Linux - Collection of 12 E
💻 HTML
字号:
<HTML>

<HEAD>

<TITLE>Special Edition Using Linux, Fourth Edition:Managing File Systems</TITLE>

<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
        var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>

 -->




<!--ISBN=0789717468//-->

<!--TITLE=Special Edition Using Linux, Fourth Edition//-->

<!--AUTHOR=Jack Tackett//-->

<!--AUTHOR=Jr.//-->

<!--AUTHOR=Steve Burnett//-->

<!--PUBLISHER=Macmillan Computer Publishing//-->

<!--IMPRINT=Que//-->

<!--CHAPTER=14//-->

<!--PAGES=286-288//-->

<!--UNASSIGNED1//-->

<!--UNASSIGNED2//-->



<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="283-286.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="288-290.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>

<P><BR></P>

<P><FONT SIZE="+1"><B>Changing the Partition Type</B></FONT></P>

<P>The next thing that you need to do is change the partition type for each partition. To change the partition type, use the <TT>t</TT> command at the <TT>fdisk</TT> command prompt. The most common choice for a standard Linux file system partition is to set it to partition type 83, Linux native. Swap partitions should be set to partition type 82, Linux swap.</P>

<!-- CODE SNIP //-->

<PRE>

Command (m for help): <B>t</B>

Partition number (1-4): <B>1</B>

Hex code (type L to list codes): <B>83</B>

Command (m for help): <B>t</B>

Partition number (1-4): <B>2</B>

Hex code (type L to list codes): <B>82</B>

</PRE>

<!-- END CODE SNIP //-->

<P>When you use the <TT>t</TT> command, you&#146;re prompted for the partition number that you want to change. You&#146;re then prompted for the hex code for the file system ID that you want to set the partition to. Typically, Linux file systems are set to type 83 for normal file systems, and type 82 for swap partitions. You can type <TT>l</TT> at this point to see a list of file systems, if you want.</P>

<P><FONT SIZE="+1"><B>Finishing Up</B></FONT></P>

<P>Now that you&#146;ve created the partitions and labeled them, you should take one last look at the partition table before you exit just to make sure that everything is okay.

</P>

<!-- CODE SNIP //-->

<PRE>

Command (m for help): <B>p</B>

Disk /dev/hda: 14 heads, 17 sectors, 1024 cylinders

Units = cylinders of 238 * 512 bytes

Device       Boot    Begin    Start     End     Blocks    Id  System

/dev/hda1               1      1       861      102400    83  Linux native

/dev/hda2               862    862     1023     19159     82  Linux swap

Command (m for help):

</PRE>

<!-- END CODE SNIP //-->

<P>As you can see, the partitions are in the right place, they&#146;re the right size, and the file system types are set correctly. The last thing that you need to do is use the <TT>w</TT> command to write the partition table to disk and exit:</P>

<!-- CODE SNIP //-->

<PRE>

Command (m for help):  <B>w</B>



#

</PRE>

<!-- END CODE SNIP //-->

<P>None of the changes that you make during an <TT>fdisk</TT> session take effect until you write them to disk with the <TT>w</TT> command. You can always quit with the <TT>q</TT> command and not save any changes. This said, you should still always have a backup of any disk that you want to modify with <TT>fdisk</TT>.</P>

<P>After you make changes to a disk with <TT>fdisk</TT>, you should reboot the system just to make sure that Linux has the updated partition information in the kernel.</P>

<H4 ALIGN="LEFT"><A NAME="Heading15"></A><FONT COLOR="#000077">Using <I>mkfs</I> to Build a File System

</FONT></H4>

<P>After you create a file system partition with <TT>fdisk</TT>, you must build a file system on it before you can use it for storing data. This is done with the <TT>mkfs</TT> command. Think of building a parking lot. If you think of <TT>fdisk</TT> as physically building the parking lot, <TT>mkfs</TT> is the part of the process that paints the lines so that the drivers know where to park.</P>

<P>Just like <TT>fsck</TT> is a &#147;front-end&#148; program for checking different types of file systems, <TT>mkfs</TT> actually calls different programs to create the file system, depending on what file system type you want to create. The syntax of the <TT>mkfs</TT> command is this</P>

<!-- CODE SNIP //-->

<PRE>

mkfs  [-V] [-t <I>fs-type</I>] [<I>fs-options</I>] <I>filesys</I> [<I>blocks</I>]

</PRE>

<!-- END CODE SNIP //-->

<P>where <I>filesys</I> is the device of the file system that you want to build, such as /dev/hda1.</P>

<BLOCKQUOTE>

<P><FONT SIZE="-1"><HR><B>CAUTION:&nbsp;&nbsp;</B><BR>The <TT>mkfs</TT> command also accepts the name of a mount point, such as <TT>/home</TT>, as the file system name. You should be extremely careful about using a mount point. If you run <TT>mkfs</TT> on a mounted &#147;live&#148; file system, you might very well corrupt all the data on that file system.<HR></FONT>

</BLOCKQUOTE>

<P>Table 14.10 lists the various command-line parameters that you can specify with <TT>mkfs</TT>.</P>

<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 14.10</B> Command-Line Parameters for the <I>mkfs</I> Command

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TH WIDTH="20%" ALIGN="LEFT">Option

<TH WIDTH="80%" ALIGN="LEFT">Description

<TR>

<TH COLSPAN="2"><HR>

<TR>

<TD VALIGN="TOP"><TT>-V</TT>

<TD>Causes <TT>mkfs</TT> to produce verbose output, including all file system-specific commands that are executed. Specifying this option more than once inhibits execution of any file system-specific commands.

<TR>

<TD VALIGN="TOP"><TT>-t <I>fs-type</I></TT>

<TD>Specifies the type of file system to be built. If the file system type isn&#146;t specified, <TT>mkfs</TT> tries to figure it out by searching for <I>filesys</I> in /etc/fstab and using the corresponding entry. If the type can&#146;t be deduced, a MINIX file system is created.

<TR>

<TD VALIGN="TOP"><TT><I>fs-options</I></TT>

<TD>Specifies file system&#150;specific options that are to be passed to the actual file system&#150;builder program. Although not guaranteed, the following options are supported by most file system builders:

</TABLE>

<TABLE WIDTH="100%">

<TD COLSPAN="3">

<TR>

<TD WIDTH="20%">

<TD WIDTH="5%"><TT>-c</TT>

<TD WIDTH="75%">Checks the device for bad blocks before building the file system

</TABLE>

<TABLE WIDTH="100%">

<TD COLSPAN="3">

<TR>

<TD WIDTH="20%">

<TD WIDTH="20%" VALIGN="TOP"><TT>-l <I>file-name</I></TT>

<TD WIDTH="60%" VALIGN="TOP">Reads a list of the bad blocks on the disk from file-name

</TABLE>

<TABLE WIDTH="100%">

<TD COLSPAN="3">

<TR>

<TD WIDTH="20%">

<TD WIDTH="5%" VALIGN="TOP"><TT>-v</TT>

<TD WIDTH="75%">Tells the actual file system builder program to produce verbose output

</TABLE>

<TABLE WIDTH="100%">

<TD COLSPAN="3">

<TR>

<TD WIDTH="20%" VALIGN="TOP"><TT><I>filesys</I></TT>

<TD WIDTH="80%">Specifies the device on which the file system resides. This parameter is required.

<TR>

<TD><TT>blocks</TT>

<TD>Specifies the number of blocks to be used for the file system.

<TR>

<TD COLSPAN="2"><HR>

</TABLE>

<P>Although <TT>-t <I>fs-type</I></TT> is an optional argument, you should get in the habit of specifying the file system type. Just like <TT>fsck</TT>, <TT>mkfs</TT> tries to figure out the type of the file system from the /etc/fstab file. If it can&#146;t figure it out, it creates a MINIX file system by default. For a normal Linux file system, you probably want an ext2 partition instead.</P>

<H3><A NAME="Heading16"></A><FONT COLOR="#000077">Using Swap Files and Partitions</FONT></H3>

<P>Swap space on your Linux system is used for virtual memory. A complete discussion of all the issues involved with virtual memory is beyond the scope of this book. Any good general computer operating system text book discusses the issue in detail.

</P>

<P>Linux supports two types of swap space: swap partition and swap files. A <I>swap partition</I> is a physical disk partition with its file system ID set to type 82, Linux swap, and is dedicated for use as a swap area. A <I>swap file</I> is a large file on a normal file system that&#146;s used for swap space.</P><P><BR></P>

<CENTER>

<TABLE BORDER>

<TR>

<TD><A HREF="283-286.html">Previous</A></TD>

<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>

<TD><A HREF="288-290.html">Next</A></TD>

</TR>

</TABLE>

</CENTER>





</td>
</tr>
</table>

<!-- begin footer information -->





</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -