122 lines
6.6 KiB
HTML
122 lines
6.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
|
|
<!Converted with LaTeX2HTML 95.1 (Fri Jan 20 1995) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
|
|
<HEAD>
|
|
<TITLE>4.8.1 Mounting filesystems</TITLE>
|
|
</HEAD>
|
|
<BODY>
|
|
<meta name="description" value="4.8.1 Mounting filesystems">
|
|
<meta name="keywords" value="gs">
|
|
<meta name="resource-type" value="document">
|
|
<meta name="distribution" value="global">
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html4120 HREF="node186.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html4118 HREF="node184.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html4112 HREF="node184.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html4122 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html4123 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4121 HREF="node186.html">4.8.2 Checking filesystems</A>
|
|
<B>Up:</B> <A NAME=tex2html4119 HREF="node184.html">4.8 Managing Filesystems</A>
|
|
<B> Previous:</B> <A NAME=tex2html4113 HREF="node184.html">4.8 Managing Filesystems</A>
|
|
<BR> <HR> <P>
|
|
<H2><A NAME=SECTION00681000000000000000>4.8.1 Mounting filesystems</A></H2>
|
|
<P>
|
|
<A NAME=4859> </A>
|
|
First, a few concepts about filesystems. Before a filesystem is
|
|
accessible to the system, it must be <b>mounted</b> on some directory.
|
|
For example, if you have a filesystem on a floppy, you must mount it
|
|
under some directory, say <tt>/mnt</tt>, in order to access the files
|
|
on it (see Section <A HREF="node178.html#secfloppy">4.6.2</A>). After mounting the filesystem,
|
|
all of the files in the filesystem appear in that directory.
|
|
After unmounting the filesystem, the directory (in this case, <tt>/mnt</tt>)
|
|
will be empty.
|
|
<P>
|
|
The same is true of filesystems on the hard drive. The system automatically
|
|
mounts filesystems on your hard drive for you at bootup time. The
|
|
so-called ``root filesystem'' is mounted on the directory <tt>/</tt>. If
|
|
you have a separate filesystem for <tt>/usr</tt>, for example,
|
|
it is mounted on <tt>/usr</tt>.
|
|
If you only have a root filesystem, all files (including
|
|
those in <tt>/usr</tt>) exist on that filesystem.
|
|
<P>
|
|
<A NAME=4977> </A>
|
|
The command <tt>mount</tt> is used to mount a filesystem. The command
|
|
<P><TT> mount -av
|
|
<P></TT>
|
|
is executed from the file <tt>/etc/rc</tt> (which is the
|
|
system initialization file executed at boot time; see Section <A HREF="node189.html#secrc">4.10.1</A>).
|
|
The <tt>mount -av</tt>
|
|
command obtains information on filesystems and mount points from
|
|
the file <tt>/etc/fstab</tt>. An example <tt>fstab</tt> file appears below.
|
|
<A NAME=4978> </A>
|
|
<A NAME=4979> </A>
|
|
<P><TT> <PRE># device directory type options
|
|
/dev/hda2 / ext2 defaults
|
|
/dev/hda3 /usr ext2 defaults
|
|
/dev/hda4 none swap sw
|
|
/proc /proc proc none
|
|
</PRE> <P></TT>
|
|
<P>
|
|
The first field is the device---the name of the partition to mount. The
|
|
second field is the mount point. The third field is the filesystem
|
|
type---such as <tt>ext2</tt> (for ext2fs) or <tt>minix</tt> (for Minix
|
|
filesystems). Table <A HREF="node185.html#tablefstypes">4.1</A> lists the various filesystem
|
|
types available for Linux.<A NAME=tex2html851 HREF="footnode.html#4884"><IMG ALIGN=BOTTOM ALT="gif" SRC="foot_motif.gif"></A> Not all of these filesystem types may be
|
|
available on your system; your kernel must have support for them
|
|
compiled in. See Section <A HREF="node179.html#secsysadmupgrade">4.7</A> for information
|
|
on building the kernel.
|
|
<P><A NAME=4907> </A><A NAME=tablefstypes> </A><IMG BORDER=0 ALIGN=BOTTOM ALT="" SRC="img263.gif">
|
|
<BR><STRONG>Table 4.1:</STRONG> Linux Filesystem Types<BR>
|
|
<P>
|
|
<P>
|
|
The last field of the <tt>fstab</tt> file contains <tt>mount</tt>
|
|
options---usually, this is set to ``<tt>defaults</tt>''.
|
|
<P>
|
|
<A NAME=4980> </A>
|
|
<A NAME=4981> </A>
|
|
As you can see, swap partitions are included in <tt>/etc/fstab</tt>
|
|
as well. They have a mount directory of <tt>none</tt>, and type <tt>swap</tt>.
|
|
The <tt>swapon -a</tt> command, executed from <tt>/etc/rc</tt> as well,
|
|
is used to enable swapping on all swap devices listed in <tt>/etc/fstab</tt>.
|
|
<P>
|
|
<A NAME=4982> </A>
|
|
The <tt>fstab</tt> file contains one special entry---for the <tt>/proc</tt>
|
|
filesystem. As mentioned in Section <A HREF="node133.html#secprocesses">3.11.1</A>, the <tt>/proc</tt>
|
|
filesystem is used to store information about system processes, available
|
|
memory, and so on. If <tt>/proc</tt> is not mounted, commands such as <tt>ps</tt>
|
|
will not work.
|
|
<P>
|
|
<IMG ALIGN=BOTTOM ALT="(WARN)" SRC="bdt.gif">The <tt>mount</tt> command may only be used by root. This is
|
|
to ensure security on the system; you wouldn't want regular users mounting
|
|
and unmounting filesystems on a whim. There are several software packages
|
|
available which allow regular users to mount and unmount filesystems
|
|
(floppies in particular) without compromising system security.
|
|
<P>
|
|
The <tt>mount -av</tt> command actually mounts all filesystems other
|
|
than the root filesystem (in the table above, <tt>/dev/hda2</tt>). The
|
|
root filesystem is automatically mounted at boot time by the
|
|
kernel.
|
|
<P>
|
|
Instead of using <tt>mount -av</tt>, you can mount a filesystem by
|
|
hand. The command
|
|
<P><TT> # <em>mount -t ext2 /dev/hda3 /usr</em>
|
|
<P></TT>
|
|
is equivalent to mounting the filesystem with the entry
|
|
<tt>/dev/hda3</tt> in the <tt>fstab</tt> example file above.
|
|
<P>
|
|
<A NAME=4983> </A>
|
|
<A NAME=4940> </A>
|
|
In general, you should never have to mount or unmount filesystems by hand.
|
|
The <tt>mount -av</tt> command in <tt>/etc/rc</tt> takes care of mounting
|
|
the filesystems at boot time.
|
|
Filesystems are automatically unmounted by the <tt>shutdown</tt> or
|
|
<tt>halt</tt> commands before bringing the system down.
|
|
<A NAME=4945> </A>
|
|
<P>
|
|
<BR> <HR><A NAME=tex2html4120 HREF="node186.html"><IMG ALIGN=BOTTOM ALT="next" SRC="next_motif.gif"></A> <A NAME=tex2html4118 HREF="node184.html"><IMG ALIGN=BOTTOM ALT="up" SRC="up_motif.gif"></A> <A NAME=tex2html4112 HREF="node184.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="previous_motif.gif"></A> <A NAME=tex2html4122 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="contents_motif.gif"></A> <A NAME=tex2html4123 HREF="node250.html"><IMG ALIGN=BOTTOM ALT="index" SRC="index_motif.gif"></A> <BR>
|
|
<B> Next:</B> <A NAME=tex2html4121 HREF="node186.html">4.8.2 Checking filesystems</A>
|
|
<B>Up:</B> <A NAME=tex2html4119 HREF="node184.html">4.8 Managing Filesystems</A>
|
|
<B> Previous:</B> <A NAME=tex2html4113 HREF="node184.html">4.8 Managing Filesystems</A>
|
|
<BR> <HR> <P>
|
|
<BR> <HR>
|
|
<P><ADDRESS>
|
|
<I>Matt Welsh <BR>
|
|
mdw@sunsite.unc.edu</I>
|
|
</ADDRESS>
|
|
</BODY>
|