-->

Previous | Table of Contents | Next

Page 201

mount Option Description
remount 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.
ro Mounts the filesystem read-only. This is the opposite of the option rw.
rw Mounts the filesystem read/write. This is the opposite of the option ro.
suid 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.
sync 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).
user 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.

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.

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.

Page 202

Setting Up Filesystems

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.

The Red Hat File System Manager

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.


Figure 11.1.
The File System
Manager.

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).

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).

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

Page 203

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.

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.

Editing /etc/fstab Manually

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).

My /etc/fstab looks like this:


#

# /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

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.

Previous | Table of Contents | Next