diff options
Diffstat (limited to 'sag-0.6.1-www/Invisible/sag-0.6/node46.html')
-rw-r--r-- | sag-0.6.1-www/Invisible/sag-0.6/node46.html | 221 |
1 files changed, 221 insertions, 0 deletions
diff --git a/sag-0.6.1-www/Invisible/sag-0.6/node46.html b/sag-0.6.1-www/Invisible/sag-0.6/node46.html new file mode 100644 index 0000000..04e96e1 --- /dev/null +++ b/sag-0.6.1-www/Invisible/sag-0.6/node46.html @@ -0,0 +1,221 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> +<!--Converted with LaTeX2HTML 96.1-h (September 30, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds --> +<HTML> +<HEAD> +<TITLE>Mounting and unmounting</TITLE> +<META NAME="description" CONTENT="Mounting and unmounting"> +<META NAME="keywords" CONTENT="sag"> +<META NAME="resource-type" CONTENT="document"> +<META NAME="distribution" CONTENT="global"> +<LINK REL=STYLESHEET HREF="sag.css"> +</HEAD> +<BODY LANG="EN" > + <A NAME="tex2html897" HREF="node47.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html895" HREF="node41.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html889" HREF="node45.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html899" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html900" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR> +<B> Next:</B> <A NAME="tex2html898" HREF="node47.html">Checking filesystem integrity with </A> +<B>Up:</B> <A NAME="tex2html896" HREF="node41.html">Filesystems</A> +<B> Previous:</B> <A NAME="tex2html890" HREF="node45.html">Creating a filesystem</A> +<BR> <P> +<H2><A NAME="SECTION00585000000000000000">Mounting and unmounting</A></H2> +<A NAME="subsecmount"> </A> +<P> + Before one can use a filesystem, it has to be <b>mounted</b>. + The operating system then does various bookkeeping things to + make sure that everything works. Since all files in UNIX are + in a single directory tree, the mount operation will make it + look like the contents of the new filesystem are the contents of + an existing subdirectory in some already mounted filesystem. +<P> + For example, figure <A HREF="node46.html#fighdmountroot">4.3</A> shows three + separate filesystems, each with their own root directory. + When the last two filesystems are mounted below <tt>/home</tt><A NAME="1582"> </A> + and <tt>/usr</tt><A NAME="1584"> </A>, respectively, on the first filesystem, we + can get a single directory tree, as in + figure <A HREF="node46.html#fighdmountall">4.4</A>. +<P> + <P><A NAME="1230"> </A><A NAME="fighdmountroot"> </A><IMG WIDTH=680 HEIGHT=99 ALIGN=BOTTOM ALT="figure1226" SRC="img7.gif"><BR> +<STRONG>Figure 4.3:</STRONG> Three separate filesystems.<BR> +<P> +<P> + <P><A NAME="1430"> </A><A NAME="fighdmountall"> </A><IMG WIDTH=371 HEIGHT=185 ALIGN=BOTTOM ALT="figure1233" SRC="img8.gif"><BR> +<STRONG>Figure 4.4:</STRONG> <tt>/home</tt><A NAME="1586"> </A> and <tt>/usr</tt><A NAME="1588"> </A> have been mounted.<BR> +<P> +<P> + The mounts could be done as in the following example: + <BLOCKQUOTE> <TT> +<code>$ </code> <I>mount /dev/hda2 /home</I> <BR> +<code>$ </code> <I>mount /dev/hda3 /usr</I> <BR> +<code>$ </code> + </TT></BLOCKQUOTE> + The <tt>mount</tt><A NAME="1590"> </A> command takes two arguments. The first one is + the device file corresponding to the disk or partition containing + the filesystem. The second one is the directory below which it + will be mounted. After these commands the contents of + the two filesystems look just like the contents of the <tt>/home</tt><A NAME="1592"> </A> + and <tt>/usr</tt><A NAME="1594"> </A> directories, respectively. One would then say that + ``<tt>/dev/hda2</tt><A NAME="1596"> </A> <b>is mounted on</b> <tt>/home</tt><A NAME="1599"> </A>'', and similarly + for <tt>/usr</tt><A NAME="1601"> </A>. To look at either filesystem, one would look + at the contents of the directory on which it has been mounted, + just as if it were any other directory. Note the + difference between the device file, <tt>/dev/hda2</tt><A NAME="1603"> </A>, and the + mounted-on directory, <tt>/home</tt><A NAME="1605"> </A>. The device file gives access + to the raw contents of the disk, the mounted-on directory + gives access to the files on the disk. The mounted-on directory + is called the <b>mount point</b>. +<P> + Linux supports many filesystem types. <tt>mount</tt><A NAME="1608"> </A> tries to + guess the type of the filesystem. You can also use the + <TT>-t <I>fstype</TT></I> option to specify the type directly; + this is sometimes necessary, since the heuristics <tt>mount</tt><A NAME="1610"> </A> + uses do not always work. For example, to mount an MS-DOS + floppy, you could use the following command: + <BLOCKQUOTE> <TT> +<code>$ </code> <I>mount -t msdos /dev/fd0 /floppy</I> <BR> +<code>$ </code> + </TT></BLOCKQUOTE> + The mounted-on directory need not be empty, although it must + exist. Any files in it, + however, will be inaccessible by name while the filesystem + is mounted. (Any files that have already been opened will + still be accessible. Files that have hard links from + other directories can be accessed using those names.) + There is no harm done with this, and it can even be useful. + For instance, some people like to have <tt>/tmp</tt><A NAME="1612"> </A> and <tt>/var/tmp</tt><A NAME="1614"> </A> + synonymous, and make <tt>/tmp</tt><A NAME="1616"> </A> be a symbolic link to <tt>/var/tmp</tt><A NAME="1618"> </A>. + When the system is booted, before the <tt>/usr</tt><A NAME="1620"> </A> filesystem is + mounted, a <tt>/var/tmp</tt><A NAME="1622"> </A> directory residing on the root filesystem + is used instead. When <tt>/usr</tt><A NAME="1624"> </A> is mounted, it will make the + <tt>/var/tmp</tt><A NAME="1626"> </A> directory on the root filesystem inaccessible. + If <tt>/var/tmp</tt><A NAME="1628"> </A> didn't exist on the root filesystem, it would + be impossible to use temporary files before mounting <tt>/var</tt><A NAME="1630"> </A>. +<P> + If you don't intend to write anything to the filesystem, use + the <TT>-r</TT> switch for <tt>mount</tt><A NAME="1632"> </A> to do a <b>readonly + mount</b>. This will make the kernel stop any attempts at + writing to the filesystem, and will also stop the kernel from + updating file access times in the inodes. Read-only mounts + are necessary for unwritable media, e.g., CD-ROM's. +<P> + The alert reader has already noticed a slight + logistical problem. How is the first filesystem (called the <b>root + filesystem</b>, because it contains the root directory) mounted, + since it obviously can't be mounted on another filesystem? + Well, the answer is that it is done by magic.<A NAME="tex2html22" HREF="footnode.html#1275"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A> The root filesystem is magically mounted at boot time, + and one can rely on it to always be mounted--if the root + filesystem can't be mounted, the system does not boot. The + name of the filesystem that is magically mounted as root is + either compiled into the kernel, or set using LILO or <tt>rdev</tt><A NAME="1636"> </A>. +<P> + The root filesystem is usually first mounted readonly. The + startup scripts will then run <tt>fsck</tt><A NAME="1638"> </A> to verify its + validity, and if there are no problems, they will <b>re-mount</b> + it so that writes will also be allowed. <tt>fsck</tt><A NAME="1641"> </A> must not + be run on a mounted filesystem, since any changes to the + filesystem while <tt>fsck</tt><A NAME="1643"> </A> is running <EM>will</EM> cause + trouble. Since the root filesystem + is mounted readonly while it is being checked, <tt>fsck</tt><A NAME="1645"> </A> + can fix any problems without worry, since the remount operation + will flush any metadata that the filesystem keeps in memory. +<P> + On many systems there are other filesystems that should also + be mounted automatically at boot time. These are specified + in the <tt>/etc/fstab</tt><A NAME="1647"> </A> file; see the <em>fstab</em><A NAME="1649"> </A> man page for + details on the + format. The details of exactly when the extra filesystems + are mounted depend on many factors, and can be configured + by each administrator if need be. When the chapter on booting + is finished, you may read all about it there. +<P> + When a filesystem no longer needs to be mounted, it can be + unmounted with <tt>umount</tt><A NAME="1651"> </A><A NAME="tex2html23" HREF="footnode.html#1431"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A>. <tt>umount</tt><A NAME="1655"> </A> takes one argument: + either the device file or the mount point. + For example, to unmount the directories of + the previous example, one could use the commands + <BLOCKQUOTE> <TT> +<code>$ </code> <I>umount /dev/hda2 </I> <BR> +<code>$ </code> <I>umount /usr</I> <BR> +<code>$ </code> + </TT></BLOCKQUOTE> + See the man page for further instructions on how to use the + command. It is imperative that you always unmount a mounted + floppy. <EM>Don't just pop the floppy out of the drive!</EM> + Because of disk caching, the data is not necessarily written + to the floppy until you unmount it, so removing the floppy + from the drive too early might cause the contents to become + garbled. If you only read from the floppy, this is not very + likely, but if you write, even accidentally, the result may be + catastrophic. +<P> + Mounting and unmounting requires super user privileges, i.e., + only <tt>root</tt><A NAME="1657"> </A> can do it. The reason for this is that if any + user can mount a floppy on any directory, then it is rather easy + to create a floppy with, say, a Trojan horse disguised as + <tt>/bin/sh</tt><A NAME="1659"> </A>, or any other often used program. However, it is + often necessary to allow users to use floppies, and there are + several ways to do this: + <UL> +<LI> Give the users the <tt>root</tt><A NAME="1661"> </A> password. This is obviously + bad security, but is the easiest solution. It works + well if there is no need for security anyway, which is + the case on many non-networked, personal systems. +<LI> Use a program such as <tt>sudo</tt><A NAME="1663"> </A> to allow users to + use mount. This is still bad security, but doesn't + directly give super user privileges to + everyone.<A NAME="tex2html21" HREF="footnode.html#1299"><IMG ALIGN=BOTTOM ALT="gif" SRC="./foot_motif.gif"></A> +<LI> Make the users use <tt>mtools</tt><A NAME="1665"> </A>, a package for manipulating + MS-DOS filesystems, without mounting them. This works + well if MS-DOS floppies are all that is needed, + but is rather awkward otherwise. +<LI> List the floppy devices and their allowable mount points + together with the suitable options in <tt>/etc/fstab</tt><A NAME="1667"> </A>. + </UL> + The last alternative can be implemented by adding a line like + the following to the <tt>/etc/fstab</tt><A NAME="1669"> </A> file: + <BLOCKQUOTE> <TT> +/dev/fd0 /floppy msdos user,noauto 0 0 + </TT></BLOCKQUOTE> + The columns are: device file to mount, directory to mount on, + filesystem type, options, backup frequency (used by <tt>dump</tt><A NAME="1671"> </A>), + and <tt>fsck</tt><A NAME="1673"> </A> pass number (to specify the order in which + filesystems should be checked upon boot; 0 means no check). +<P> + The <tt>noauto</tt> option stops this mount to be done + automatically when the system is started (i.e., it stops + <tt>mount -a</tt><A NAME="1675"> </A> from mounting it). The <tt>user</tt> option + allows any user to mount the filesystem, and, because of security + reasons, disallows execution of programs (normal or setuid) + and interpretation of device files from the mounted filesystem. + After this, any user can mount a floppy with an <tt>msdos</tt> + filesystem with the following command: + <BLOCKQUOTE> <TT> +<code>$ </code> <I>mount /floppy</I> <BR> +<code>$ </code> + </TT></BLOCKQUOTE> + The floppy can (and needs to, of course) be unmounted with + the corresponding <tt>umount</tt><A NAME="1677"> </A> command. +<P> + If you want to provide access to several types of floppies, + you need to give several mount points. The settings can be + different for each mount point. For example, to give access + to both MS-DOS and ext2 floppies, you could have the following + to lines in <tt>/etc/fstab</tt><A NAME="1679"> </A>: + <BLOCKQUOTE> + <PRE>/dev/fd0 /dosfloppy msdos user,noauto 0 0 +/dev/fd0 /ext2floppy ext2 user,noauto 0 0</PRE> + </BLOCKQUOTE> + For MS-DOS filesystems (not just floppies), you probably want to + restrict access to it by using the <tt>uid</tt>, <tt>gid</tt>, + and <tt>umask</tt><A NAME="1681"> </A> filesystem options, described in detail on the + <em>mount</em><A NAME="1683"> </A> manual page. If you aren't careful, mounting + an MS-DOS filesystem gives everyone at least read access to the + files in it, which is not a good idea. +<P> +<HR><A NAME="tex2html897" HREF="node47.html"><IMG WIDTH=37 HEIGHT=24 ALIGN=BOTTOM ALT="next" SRC="./next_motif.gif"></A> <A NAME="tex2html895" HREF="node41.html"><IMG WIDTH=26 HEIGHT=24 ALIGN=BOTTOM ALT="up" SRC="./up_motif.gif"></A> <A NAME="tex2html889" HREF="node45.html"><IMG WIDTH=63 HEIGHT=24 ALIGN=BOTTOM ALT="previous" SRC="./previous_motif.gif"></A> <A NAME="tex2html899" HREF="node1.html"><IMG WIDTH=65 HEIGHT=24 ALIGN=BOTTOM ALT="contents" SRC="./contents_motif.gif"></A> <A NAME="tex2html900" HREF="node114.html"><IMG WIDTH=43 HEIGHT=24 ALIGN=BOTTOM ALT="index" SRC="./index_motif.gif"></A> <BR> +<B> Next:</B> <A NAME="tex2html898" HREF="node47.html">Checking filesystem integrity with </A> +<B>Up:</B> <A NAME="tex2html896" HREF="node41.html">Filesystems</A> +<B> Previous:</B> <A NAME="tex2html890" HREF="node45.html">Creating a filesystem</A> +<P><ADDRESS> +<I>Lars Wirzenius <BR> +Sat Nov 15 02:32:11 EET 1997</I> +</ADDRESS> +</BODY> +</HTML> |