📄 273-275.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=273-275//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="270-273.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="275-278.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>In this sample file, you can see several different file systems. First, notice that comments in the file are prefixed by a <TT>#</TT> character. In this fstab file, two normal Linux file systems are mounted—the disk partitions /dev/hda1 and /dev/hda2. These are listed as being of type <TT>ext2</TT> and are mounted under the root directory, /, and /usr respectively.</P>
<P>The entry <TT>defaults</TT> listed under the <TT>options</TT> field indicates that this file system should be mounted by using a common set of default options. Specifically, the file system is mounted read/write enabled, it’s to be interpreted as a block special device, all file I/O should be done asynchronously, the execution of binaries is permitted, the file system can be mounted with the <TT>mount -a</TT> command, the set UID (user ID) and set GID (group ID) bits on files are interpreted on this file system, and ordinary users aren’t allowed to mount this file system. As you can see, it’s a lot easier just to type <B><TT>defaults</TT></B> for the option instead.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR>• <B>See</B> “Creating the Swap Partition,” <B>p. 72</B> and <B>p. 99</B><HR></FONT>
</BLOCKQUOTE>
<P>The partition /dev/hda3 is a swap partition that’s used for kernel virtual-memory swap space. Its mount point is specified as <TT>none</TT> because you don’t want it to appear in the file system tree. It still has to be in the /etc/fstab file, so the system knows where it’s physically located. Swap partitions are also mounted with the option <TT>sw</TT>.</P>
<P>The /proc file system is a virtual file system that points to the process information space in memory. As you can see, it doesn’t have a corresponding physical partition to mount.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>TIP: </B>For full information on all options available in the /etc/fstab file, refer to the man page for <TT>fstab</TT>.<HR></FONT>
</BLOCKQUOTE>
<P>MS-DOS file systems can also </TT>be mounted automatically. The partition /dev/sda1 is the first partition on the SCSI hard drive sda. It’s mounted as an MS-DOS partition by specifying <TT>msdos</TT> as the type and by giving <TT>/dosc</TT> as its mount point. You can place the mount point for the MS-DOS file system anywhere—there’s no requirement that it be under the root directory.</P>
<H4 ALIGN="LEFT"><A NAME="Heading6"></A><FONT COLOR="#000077">Unmounting File Systems</FONT></H4>
<P>Now that you know all sorts of stuff about mounting file systems, it’s time to look at how to unmount. You use the <TT>umount</TT> command to unmount file systems. You would want to unmount a file system for several reasons: so that you can check/repair a file system with <TT>fsck</TT>, unmount NFS-mounted file systems in case of network problems, or unmount a file system on a floppy drive.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>This command is <TT>umount</TT>, not “unmount.” Make sure that you type it correctly. <HR></FONT>
</BLOCKQUOTE>
<P>There are three basic forms of the <TT>umount</TT> command:</P>
<!-- CODE SNIP //-->
<PRE>
umount <I>device | mountpoint</I>
umount -a
umount -t <I>fstype</I>
</PRE>
<!-- END CODE SNIP //-->
<P><I>device</I> is the name of the physical device to unmount; <I>mountpoint</I> is the mount point directory name (specify only one or the other). The <TT>umount</TT> command has only two command-line parameters: <TT>-a</TT>, which unmounts all file systems, and <TT>-t <I>fstype</I></TT>, which acts only on file systems of the type specified.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>CAUTION: </B><BR>The <TT>umount</TT> command doesn’t unmount a file system that’s in use. For example, if you have some file system mounted under /mnt and you try
<!-- CODE SNIP //-->
<PRE>
cd /mnt
</PRE>
<!-- END CODE SNIP //-->
<!-- CODE SNIP //-->
<PRE>
umount /mnt
</PRE>
<!-- END CODE SNIP //-->
<P>you get an error telling you that the file system is busy. You have to change to a different directory in another file system to unmount the file system mounted under /mnt.<HR></FONT>
</BLOCKQUOTE>
</P>
<H3><A NAME="Heading7"></A><FONT COLOR="#000077">Understanding the Network File System</FONT></H3>
<P>The Network File System (NFS) is a system that allows you to mount file systems from a different computer over a TCP/IP network. NFS allows you to share data among PC, Mac, UNIX, and Linux systems. Under NFS, a file system on a remote computer is mounted locally and looks just like a local file system to users. The illusion of being mounted locally has numerous uses. For example, you can have one machine on your network with a lot of disk space acting as a file server. This computer has all the home directories of all your users on its local disks. By mounting these disks via NFS on all your other computers, your users can access their home directories from any computer.
</P>
<P>NFS has three essential components:</P>
<DL>
<DD><B>•</B> The computers with the file systems that you want to NFS mount must be able to communicate with each other via a TCP/IP network.
<DD><B>•</B> The computer with the file system that you’re interested in as a local file system must make that file system available to be mounted. This computer is known as the <I>server</I>, and the process of making the file system available is known as <I>exporting the file system</I>.
<DD><B>•</B> The computer that wants to mount the exported file system, known as the <I>client</I>, must mount the file system as an NFS file system via the /etc/fstab file at boot time or interactively via the <TT>mount</TT> command.
</DL>
<P>The following sections discuss exporting the file system and mounting it locally.
</P>
<H4 ALIGN="LEFT"><A NAME="Heading8"></A><FONT COLOR="#000077">Exporting an NFS File System</FONT></H4>
<P>For clients to mount an NFS file system, this file system must be made available by the server. Before the file system can be made available, you must ensure that it’s mounted on the server. If the file system is always going to an NFS exported file system, you should make sure that you have it listed in the /etc/fstab file on the server so that it automatically mounts when the server boots.
</P>
<P>When you have the file system mounted locally, you can make it available via NFS. This is a two-step process. First, you must make sure that the NFS daemons <TT>rpc.mountd</TT> and <TT>rpc.nfsd</TT> are running on your server. These daemons are usually started from the startup /etc/rc.d/init.d/nfs script. Usually, all that’s needed is to make sure that the following lines are in your script:</P>
<!-- CODE SNIP //-->
<PRE>
daemon rpc.mountd
daemon rpc.nfsd
</PRE>
<!-- END CODE SNIP //-->
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>As RPC-based programs, the <TT>rpc.mountd</TT> and <TT>rpc.nfsd</TT> daemons aren’t managed by the <TT>inetd</TT> daemon but are started up at boot time, registering themselves with the <TT>portmap</TT> daemon. You must be sure to start them only after <TT>rpc.portmap</TT> is running.<HR></FONT>
</BLOCKQUOTE>
<P>Second, you must enter the NFS file system in a configuration file named /etc/exports. This file contains information about what file systems can be exported, what computers are allowed to access them, and what type and level of access is permitted.
</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="270-273.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="275-278.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 + -