📄 280-283.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=280-283//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="278-280.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="283-286.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>It’s a good idea to unmount a file system before checking it. This ensures that none of the files on the file system are in use when they’re being checked.
</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Remember, you can’t unmount a file system if any of the files on it are busy. For example, if a user is now in a directory on a file system that you try to unmount, you get a message saying that the file system is busy.<HR></FONT>
</BLOCKQUOTE>
<P>Trying to check the root file system presents an additional problem. You can’t directly unmount the root file system, because Linux must be able to access it in order to run. To check the root file system, you should boot from a maintenance floppy disk that has a root file system on it, and then run <TT>fsck</TT> on your real root file system from the floppy by specifying the special device name of your root file system. If <TT>fsck</TT> makes any changes to your file system, it’s important that you reboot your system immediately. This allows Linux to reread important information about your file system and prevents your file system from further corruption.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR>Be sure to reboot your computer immediately after you run <TT>fsck</TT> if any changes were made to your file system to prevent further corruption to your file system. Use the <TT>shutdown -r</TT> command or the <TT>reboot</TT> command to reboot.<HR></FONT>
</BLOCKQUOTE>
<H3><A NAME="Heading13"></A><FONT COLOR="#000077">Creating and Formatting File Systems</FONT></H3>
<P>When you add a new hard disk to your computer or want to change the partition information on an old hard disk, you go through the steps of creating a file system from a raw disk. Assuming that you’ve added a new hard disk to your system, you must set the disk partition information and then create the actual file systems on the disk before Linux can use the disk. To change disk partition information, you use the <TT>fdisk</TT> command. After you partition the hard drive, you need to create the file systems by using the <TT>mkfs</TT> command.</P>
<H4 ALIGN="LEFT"><A NAME="Heading14"></A><FONT COLOR="#000077">Using <I>fdisk</I> to Create Disk Partitions
</FONT></H4>
<P>The <TT>fdisk</TT> command is used to create disk partitions and set the attributes that tell Linux what type of file system is on a particular partition. If you installed Linux from scratch on an MS-DOS system, you had to run <TT>fdisk</TT> to change the disk partition information before you could install Linux.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR>Using <TT>fdisk</TT> on a disk can destroy all data on the disk. Because <TT>fdisk</TT> completely rewrites the file table on the disk, all your former files may be lost. Make sure that you have a complete, current backup of your disks before using <TT>fdisk</TT>.<HR></FONT>
</BLOCKQUOTE>
<P>You should always run the <TT>fdisk</TT> command on an unmounted file system. <TT>fdisk</TT> is an interactive, menu-driven program, not just a single command. To start <TT>fdisk</TT>, type this command</P>
<!-- CODE SNIP //-->
<PRE>
<B>fdisk [<I>drive</I>]</B>
</PRE>
<!-- END CODE SNIP //-->
<P>where <I>drive</I> is the physical disk drive that you want to work on. If you don’t specify a disk, the disk /dev/hda is assumed. For example, to run <TT>fdisk</TT> on the second IDE hard drive in your system, enter</P>
<!-- CODE SNIP //-->
<PRE>
<B>fdisk /dev/hdb</B>
</PRE>
<!-- END CODE SNIP //-->
<P>at the superuser command prompt. Because <TT>fdisk</TT> is a menu-driven program, several different commands are available when you’re using <TT>fdisk</TT>, as summarized in Table 14.8.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 14.8</B> Commands Available from the <I>fdisk</I> Menu
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="18%" ALIGN="LEFT">Command
<TH WIDTH="72%" ALIGN="LEFT">Description
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD><TT>a</TT>
<TD>Toggles the bootable flag on a partition
<TR>
<TD><TT>c</TT>
<TD>Toggles the DOS compatibility flag on a partition
<TR>
<TD><TT>d</TT>
<TD>Deletes a partition
<TR>
<TD><TT>l</TT>
<TD>Lists partition types known to fdisk
<TR>
<TD><TT>m</TT>
<TD>Displays a menu listing all available commands
<TR>
<TD><TT>n</TT>
<TD>Adds a new partition
<TR>
<TD><TT>p</TT>
<TD>Prints the partition table for the current disk
<TR>
<TD><TT>q</TT>
<TD>Quits without saving any changes
<TR>
<TD><TT>t</TT>
<TD>Changes the file system type for a partition
<TR>
<TD><TT>u</TT>
<TD>Changes display/entry units
<TR>
<TD><TT>v</TT>
<TD>Verifies the partition table
<TR>
<TD><TT>w</TT>
<TD>Writes the table to disk and exits
<TR>
<TD><TT>x</TT>
<TD>Lists additional functions for experts:
</TABLE>
<TABLE WIDTH="100%">
<TD COLSPAN="3">
<TR>
<TD WIDTH="21%">
<TD WIDTH="5%"><TT>b</TT>
<TD WIDTH="74%">Moves the beginning location of data in a partition
<TR>
<TD>
<TD><TT>c</TT>
<TD>Changes the number of cylinders
<TR>
<TD>
<TD><TT>d</TT>
<TD>Prints the raw data in the partition table
<TR>
<TD>
<TD><TT>e</TT>
<TD>Lists extended partitions on disk
<TR>
<TD>
<TD><TT>h</TT>
<TD>Changes number of heads on disk
<TR>
<TD>
<TD><TT>r</TT>
<TD>Returns to main menu
<TR>
<TD>
<TD><TT>s</TT>
<TD>Changes number of sectors on disk
<TR>
<TH COLSPAN="3"><HR>
</TABLE>
<P><TT>fdisk</TT> can set the file system type of a disk partition to any of several different types. Only use Linux <TT>fdisk</TT> to create partitions used under Linux. For MS-DOS or OS/2 partitions, you should use the <TT>fdisk</TT> tool that’s native to that operating environment, and then use Linux’s <TT>fdisk</TT> to tag the partitions as Linux native or Linux swap.</P>
<P>Table 14.9 lists the partitions supported by Linux <TT>fdisk</TT>. Each partition type has an associated hexadecimal code that identifies it. You must enter the appropriate code in <TT>fdisk</TT> when you want to set a partition type.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 14.9</B> Partition Codes and Types in Linux fdisk
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="20%" ALIGN="LEFT">Hex Code
<TH WIDTH="80%" ALIGN="LEFT">Partition Type
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TD>0
<TD>Empty
<TR>
<TD>1
<TD>DOS 12-bit FAT
<TR>
<TD>2
<TD>XENIX root
<TR>
<TD>3
<TD>XENIX usr
<TR>
<TD>4
<TD>DOS 16-bit file system, less than 32MB
<TR>
<TD>5
<TD>Extended
<TR>
<TD>6
<TD>DOS 16-bit file system supporting more than 32MB
<TR>
<TD>7
<TD>OS/2 High Performance File System (HPFS)
<TR>
<TD>8
<TD>AIX
<TR>
<TD>9
<TD>AIX bootable
<TR>
<TD>a
<TD>OS/2 Boot Manager
<TR>
<TD>40
<TD>Venix 80286
<TR>
<TD>51
<TD>Novell?
<TR>
<TD>52
<TD>Microport
<TR>
<TD>63
<TD>GNU HURD
<TR>
<TD>64
<TD>Novell NetWare
<TR>
<TD>65
<TD>Novell NetWare
<TR>
<TD>75
<TD>PC/IX
<TR>
<TD>80
<TD>Old MINIX
<TR>
<TD>81
<TD>Linux/MINIX
<TR>
<TD>82
<TD>Linux swap, used for swap files under Linux
<TR>
<TD>83
<TD>Linux native, common Linux file system type
<TR>
<TD>93
<TD>Amoeba
<TR>
<TD>94
<TD>Amoeba BBT
<TR>
<TD>a5
<TD>BSD/386
<TR>
<TD>b7
<TD>BSDI file system
<TR>
<TD>b8
<TD>BSDI swap file system
<TR>
<TD>c7
<TD>Syrinx
<TR>
<TD>db
<TD>CP/M
<TR>
<TD>e1
<TD>DOS access
<TR>
<TD>e3
<TD>DOS R/O
<TR>
<TD>f2
<TD>DOS secondary
<TR>
<TD>ff
<TD>BBT
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="278-280.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="283-286.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 + -