📄 490-492.html
字号:
<HTML>
<HEAD>
<TITLE>Using Linux:Managing the Filesystem</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=0789716232//-->
<!--TITLE=Using Linux//-->
<!--AUTHOR=William Ball//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=29//-->
<!--PAGES=490-492//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="487-490.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="493-495.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading4"></A><FONT COLOR="#000077">Using the <I>mount</I> Command
</FONT></H4>
<P>To mount a block device into the file system, use the <TT>mount</TT> command. You must specify what device contains the filesystem, what type it is, and where in the directory hierarchy to mount it.</P>
<P>A <TT>mount</TT> command looks like this:</P>
<!-- CODE SNIP //-->
<PRE>
mount [-t <I>typ</I>e] [-o <I>options</I>] <I>device</I> <I>mount-poin</I>t
</PRE>
<!-- END CODE SNIP //-->
<P><TT><I>device</I></TT> must be a block device; or, if it contains a colon, it can be the name of another machine from which to mount a filesystem. <TT><I>mount-point</I></TT> should be an existing directory; the filesystem appears at this position (anything previously in that directory is hidden). The filesystem type and options are optional, and the variety and meaning of options depend on the type of filesystem being mounted. If the filesystem you want to mount is specified in the <TT>/etc/fstab</TT> file, you need to specify only the mount point or the device name; the other details will be read from <TT>/etc/fstab</TT> by <TT>mount</TT>.</P>
<P><FONT SIZE="+1"><B><I>Mounting a floppy with the mount command</I></B></FONT></P>
<DL>
<DD><B>1.</B> Use the <TT>mount</TT> command, followed by the device name, the <TT>–t</TT> (filesystem type) option, the name of a filesystem, and the mount point in your system’s directory structure. For example, to mount a floppy disk, first log on as the root operator, and then use the <TT>mkdir</TT> command to create a mount point like this:
<!-- CODE SNIP //-->
<PRE>
<B># mkdir /mnt/floppy</B>
</PRE>
<!-- END CODE SNIP //-->
<DD><B>2.</B> Use the <TT>mount</TT> command, specifying your floppy drive’s device name, and the type of filesystem (such as DOS), like this:
<!-- CODE SNIP //-->
<PRE>
<B># mount /dev/fd1 -t vfat /mnt/floppy</B>
mount: block device /dev/fd1 is write-protected,
mounting read-only
</PRE>
<!-- END CODE SNIP //-->
<DD><B>3.</B> The disk’s contents become available at the specified mount point (directory). Use the <TT>ls</TT> (list directory) command to verify that the disk is mounted, like this:
<!-- CODE SNIP //-->
<PRE>
<B># ls /mnt/floppy</B>
grub-0.4.tar.gz
</PRE>
<!-- END CODE SNIP //-->
<DD><B>4.</B> After you have finished reading, copying, or deleting files on the disk, use the <TT>umount</TT> command, followed by the mount point, or pathname, to unmount the filesystem, like this:
<!-- CODE SNIP //-->
<PRE>
<B># umount /mnt/floppy</B>
</PRE>
<!-- END CODE SNIP //-->
</DL>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>SEE ALSO</B><BR>• To learn more about drivers, code modules, and the magic of the Linux kernel, see page 577.<HR></FONT>
</BLOCKQUOTE>
<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD>
<P><B>Is it magic, or the Linux <TT>kerneld</TT> daemon?</B><BR>Mounting a <TT>vfat</TT> floppy disk causes the Linux kernel to automatically load the <TT>vfat</TT> driver into the kernel while it is needed. These (and other) drivers are loaded by the system daemon <TT>kerneld</TT>; when the drivers are no longer being used, such as after a filesystem is unmounted, the drivers are unloaded to recover the memory.</TABLE>
</P>
<P>Any one of several things can cause the <TT>mount</TT> command to fail. It is possible to specify an incorrect device name (that is, to specify a device file that does not exist, one for which a driver is not available in the kernel, or one for which the hardware is not present). Other error conditions include unreadable devices (for example, empty floppy drives or bad media) and insufficient permissions (<TT>mount</TT> commands other than those sanctioned by the administrator by listing them with the option <TT>user</TT> in <TT>/etc/fstab</TT> are forbidden to ordinary users). Trying to mount a device at a mount point that does not already exist also will not work.</P>
<TABLE BORDER="2" BORDERCOLOR="#0000" ALIGN="CENTER">
<TR><TD><FONT SIZE="+1"><B>Don’t forget the mount point</B></FONT>
<BR>In order to mount a filesystem, the point at which it is to be mounted (that is, the mount point) must be a directory. This directory doesn’t have to be empty but after the filesystem is mounted, any files “underneath” it will be inaccessible. Be careful when mounting disks or other media!</TABLE>
<P>Still more error conditions are possible but unlikely (for example, exceeding the compiled-in limit to the number of mounted filesystems) or self-explanatory (for example, most usage errors for the <TT>mount</TT> command itself).</P>
<P>Linux provides a <I>singly rooted</I> filesystem, in contrast to those operating systems that give each filesystem a separate drive letter. Although this might seem less flexible, it is actually <I>more</I> flexible, because the size of each block device (that is, the hard disk, or whatever) is hidden from programs, and things can be moved around.</P>
<P>For example, if you have some software that expects to be installed in <TT>/opt/umsp</TT>, you can install it in <TT>/big-disk/stuff/umsp</TT> and make <TT>/opt/umsp</TT> a symbolic link. There is also no need to edit a myriad of configuration files that are now using the wrong drive letter after you install a new disk drive, for example.</P>
<P>There are many options governing how a mounted filesystem behaves; for example, it can be mounted read-only. There are options for filesystems such as <TT>msdos</TT>, and others, such as the <TT>nfs</TT> filesystem, which has so many options that it has a separate manual page (<TT>man nfs</TT>).</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="487-490.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="493-495.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 + -