0201-0203.html
来自「linux-unix130.linux.and.unix.ebooks130 l」· HTML 代码 · 共 304 行
HTML
304 行
<HTML>
<HEAD>
<TITLE>Developer.com - Online Reference Library - 0672311739:RED HAT LINUX 2ND EDITION:Filesystems, Disks, and Other Devices</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=0672311739 //-->
<!-- TITLE=RED HAT LINUX 2ND EDITION //-->
<!-- AUTHOR=DAVID PITTS ET AL //-->
<!-- PUBLISHER=MACMILLAN //-->
<!-- IMPRINT=SAMS PUBLISHING //-->
<!-- PUBLICATION DATE=1998 //-->
<!-- CHAPTER=11 //-->
<!-- PAGES=0195-0228 //-->
<!-- UNASSIGNED1 //-->
<!-- UNASSIGNED2 //-->
<P><CENTER>
<a href="0198-0200.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0204-0206.html">Next</A>
</CENTER></P>
<A NAME="PAGENUM-201"><P>Page 201</P></A>
<TABLE WIDTH="360">
<TR><TD>
mount <B>Option</B>
</TD><TD>
<B>Description</B>
</TD></TR>
<TR><TD>
remount
</TD><TD>
Allows the mount command to change the flags for an
already-mounted filesystem without interrupting its use. You
can't unmount a filesystem that is currently in use, and this option
is basically a workaround. The system startup scripts, for
example, use the command mount -n -o remount,ro / to change the
root filesystem from read-only (it starts off this way) to read/write
(its normal state). The -n option indicates to
mount that it shouldn't update /etc/fstab because it can't do this while the
root filesystem is still read-only.
</TD></TR>
<TR><TD>
ro
</TD><TD>
Mounts the filesystem read-only. This is the opposite of
the option rw.
</TD></TR>
<TR><TD>
rw
</TD><TD>
Mounts the filesystem read/write. This is the opposite of
the option ro.
</TD></TR>
<TR><TD>
suid
</TD><TD>
Allows the set user ID and set group ID file mode bits to
take effect. The opposite of this option is
nosuid. The nosuid option is more usual; it is used for the same sorts of reasons that
nodev is used.
</TD></TR>
<TR><TD>
sync
</TD><TD>
All write operations cause the calling program to wait until
the data has been committed to the hardware. This mode of
operation is slower but a little more reliable than its opposite,
asynchronous I/O, which is indicated by the option
async (see above).
</TD></TR>
<TR><TD>
user
</TD><TD>
Allows ordinary users to mount the filesystem. When there is
a user option in /etc/fstab, ordinary users indicate
which filesystem they want to mount or unmount by giving the
device name or mount point; all the other relevant information is
taken from the /etc/fstab file. For security reasons,
user implies the noexec, nosuid, and nodev options.
</TD></TR>
</TABLE>
<P>Options are processed by the mount command in the order they appear on the command
line (or in /etc/fstab). Thus, it is possible to allow users to mount a filesystem and then run
set user ID executables by using the options user,
suid in that order. Using them in reverse order (suid,
user) wouldn't work because the user option would turn the
suid option off again.
</P>
<P>There are many other options available, but these are all specific to particular filesystems.
All the valid options for mount are detailed in its manual page. An example is the
umask flag for the vfat and fat filesystems, which allows you to make all the files on your MS-DOS or
Windows partitions readable (or even writable if you prefer) for all the users on your Linux
system.
</P>
<A NAME="PAGENUM-202"><P>Page 202</P></A>
<H3><A NAME="ch11_ 6">
Setting Up Filesystems
</A></H3>
<P>When the kernel boots, it attempts to mount a root filesystem from the device specified by
the kernel loader, LILO. The root filesystem is initially mounted read-only, and the boot
process proceeds as described in Chapter 4, "System Startup and Shutdown." During the boot
process, the filesystems listed in the filesystem table
/etc/fstab are mounted. This file specifies which devices are to be mounted, what kinds of filesystems they contain, at what point in
the filesystem the mount takes place, and any options governing
how they are to be mounted. The format of this file is described in
fstab.
</P>
<H4><A NAME="ch11_ 7">
The Red Hat File System Manager
</A></H4>
<P>An easy way of setting up filesystem entries in
/etc/fstab is the configuration tool File System Manager in the Red Hat Control Panel (though you can invoke it separately as
fstool). The File System Manager is shown in Figure 11.1.
</P>
<BR>
Figure 11.1.<BR>
The File System<BR>
Manager.<BR>
<a href="09rhu01.html"><img src="images/tn_09rhu01_jpg.jpg"></a><BR>
<P>When you start fstool, it produces a window that contains all the entries in
/etc/fstab. Each entry shows the device name, mount point, filesystem type, size, space used, and space
available. Additionally, each mounted filesystem is marked with an asterisk. The Info button
displays extra information about the highlighted filesystem (the same information as is
indicated in /etc/fstab and in the output of the
df command).
</P>
<P>Filesystems can be mounted or unmounted with the two buttons Mount and Unmount.
Any errors that occur are shown in a dialog box; this can happen if, for example, you try to
mount a CD-ROM when there is no disk in the drive. (Go ahead and try it.) The Format
button works only for hard disk partitions; for these, it runs
mkfs (see the section "Creating New Filesystems," later in this chapter). Other media (for example, floppy disks) are formatted
differently (see the section "Floppy Disks," later in this chapter).
</P>
<P>The Check button works only for ext2 and minix filesystems. If you get the error
fsck: command not found, this just means that the directory
/sbin is not on your path, and you should be able to fix this by running
su - root. (You might also need to do export
DISPLAY=:0.0, if that is necessary.) Checking a filesystem can take a while, and the result is shown in a
dialog
</P>
<A NAME="PAGENUM-203"><P>Page 203</P></A>
<P>
box afterward. It is very unusual for errors to be shown for hard disk filesystems here
because these are checked at boot time and don't get corrupted during the normal operation of Linux.
</P>
<P>The NFS menu is used to add and remove NFS network mounts, which are explained in
Chapter 13. You can exit the File System Manager by selecting the Quit option from the FSM
menu.
</P>
<H4><A NAME="ch11_ 8">
Editing /etc/fstab Manually
</A></H4>
<P>The filesystem table /etc/fstab is just a text file; it is designed to have a specific format that
is readable by humans and not just computers. It is separated into columns by tabs or spaces
(it doesn't matter which you use). You can edit it with your favorite text editor—it doesn't
matter which. You must take care, however, if you modify it by hand, because removing or
corrupting an entry will make the system unable to mount that filesystem next time it boots. For this
reason, I make a point of saving previous versions of this file using the Revision Control
System (a very useful program—see the manual page for
rcs).
</P>
<P>My /etc/fstab looks like this:
</P>
<!-- CODE //-->
<PRE>
#
# /etc/fstab
#
# You should be using fstool (control-panel) to edit this!
#
#<device> <mountpoint> <filesystemtype> <options> <dump> <fsckorder>
/dev/hda1 / ext2 defaults 1 1
/dev/hdb5 /home ext2 defaults,rw 1 2
/dev/hda3 /usr ext2 defaults 1 2
/dev/hdb1 /usr/src ext2 defaults 1 3
/dev/hdc /mnt/cdrom iso9660 user,noauto,ro 0 0
/dev/sbpcd0 /mnt/pcd iso9660 user,noauto,ro 0 0
/dev/fd1 /mnt/floppy vfat user,noauto 0 0
/proc /proc proc defaults
/dev/hda2 none swap sw
</PRE>
<!-- END CODE //-->
<P>The first four entries are the ext2 filesystems comprising my Linux system. When Linux
is booted, the root filesystem is mounted first; all the other local (that is, nonnetwork)
filesystems are mounted next. Filesystems appear in
/etc/fstab in the order they are mounted; /usr
must appear before /usr/src, for example, because the mount point for one filesystem exists on
the other. The following three filesystems are all removable filesystems (two CD-ROMs and a
floppy drive). These have the noauto option set so that they are not automatically mounted at
boot time. The removable devices have the user option set so that I can mount and unmount
them without having to use su all the time. The CD-ROMs have the filesystem type
iso9660, which is the standard filesystem for CD-ROMs, and the floppy drive has the filesystem type
vfat, because I often use it for interchanging data with MS-DOS and Windows systems.
</P>
<P><CENTER>
<a href="0198-0200.html">Previous</A> | <a href="../ewtoc.html">Table of Contents</A> | <a href="0204-0206.html">Next</A>
</CENTER></P>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?