-->
Previous Table of Contents Next


In this sample file, you can see several different file systems. First, notice that comments in the file are prefixed by a # character. In this fstab file, two normal Linux file systems are mounted—the disk partitions /dev/hda1 and /dev/hda2. These are listed as being of type ext2 and are mounted under the root directory, /, and /usr respectively.

The entry defaults listed under the options field indicates that this file system should be mounted by using a common set of default options. Specifically, the file system is mounted read/write enabled, it’s to be interpreted as a block special device, all file I/O should be done asynchronously, the execution of binaries is permitted, the file system can be mounted with the mount -a command, the set UID (user ID) and set GID (group ID) bits on files are interpreted on this file system, and ordinary users aren’t allowed to mount this file system. As you can see, it’s a lot easier just to type defaults for the option instead.


See “Creating the Swap Partition,” p. 72 and p. 99

The partition /dev/hda3 is a swap partition that’s used for kernel virtual-memory swap space. Its mount point is specified as none because you don’t want it to appear in the file system tree. It still has to be in the /etc/fstab file, so the system knows where it’s physically located. Swap partitions are also mounted with the option sw.

The /proc file system is a virtual file system that points to the process information space in memory. As you can see, it doesn’t have a corresponding physical partition to mount.


TIP:  For full information on all options available in the /etc/fstab file, refer to the man page for fstab.

MS-DOS file systems can also be mounted automatically. The partition /dev/sda1 is the first partition on the SCSI hard drive sda. It’s mounted as an MS-DOS partition by specifying msdos as the type and by giving /dosc as its mount point. You can place the mount point for the MS-DOS file system anywhere—there’s no requirement that it be under the root directory.

Unmounting File Systems

Now that you know all sorts of stuff about mounting file systems, it’s time to look at how to unmount. You use the umount command to unmount file systems. You would want to unmount a file system for several reasons: so that you can check/repair a file system with fsck, unmount NFS-mounted file systems in case of network problems, or unmount a file system on a floppy drive.


NOTE:  This command is umount, not “unmount.” Make sure that you type it correctly.

There are three basic forms of the umount command:


  umount device | mountpoint

  umount -a

  umount -t fstype

device is the name of the physical device to unmount; mountpoint is the mount point directory name (specify only one or the other). The umount command has only two command-line parameters: -a, which unmounts all file systems, and -t fstype, which acts only on file systems of the type specified.


CAUTION:  
The umount command doesn’t unmount a file system that’s in use. For example, if you have some file system mounted under /mnt and you try

cd /mnt


umount /mnt

you get an error telling you that the file system is busy. You have to change to a different directory in another file system to unmount the file system mounted under /mnt.


Understanding the Network File System

The Network File System (NFS) is a system that allows you to mount file systems from a different computer over a TCP/IP network. NFS allows you to share data among PC, Mac, UNIX, and Linux systems. Under NFS, a file system on a remote computer is mounted locally and looks just like a local file system to users. The illusion of being mounted locally has numerous uses. For example, you can have one machine on your network with a lot of disk space acting as a file server. This computer has all the home directories of all your users on its local disks. By mounting these disks via NFS on all your other computers, your users can access their home directories from any computer.

NFS has three essential components:

  The computers with the file systems that you want to NFS mount must be able to communicate with each other via a TCP/IP network.
  The computer with the file system that you’re interested in as a local file system must make that file system available to be mounted. This computer is known as the server, and the process of making the file system available is known as exporting the file system.
  The computer that wants to mount the exported file system, known as the client, must mount the file system as an NFS file system via the /etc/fstab file at boot time or interactively via the mount command.

The following sections discuss exporting the file system and mounting it locally.

Exporting an NFS File System

For clients to mount an NFS file system, this file system must be made available by the server. Before the file system can be made available, you must ensure that it’s mounted on the server. If the file system is always going to an NFS exported file system, you should make sure that you have it listed in the /etc/fstab file on the server so that it automatically mounts when the server boots.

When you have the file system mounted locally, you can make it available via NFS. This is a two-step process. First, you must make sure that the NFS daemons rpc.mountd and rpc.nfsd are running on your server. These daemons are usually started from the startup /etc/rc.d/init.d/nfs script. Usually, all that’s needed is to make sure that the following lines are in your script:


daemon rpc.mountd

daemon rpc.nfsd


NOTE:  As RPC-based programs, the rpc.mountd and rpc.nfsd daemons aren’t managed by the inetd daemon but are started up at boot time, registering themselves with the portmap daemon. You must be sure to start them only after rpc.portmap is running.

Second, you must enter the NFS file system in a configuration file named /etc/exports. This file contains information about what file systems can be exported, what computers are allowed to access them, and what type and level of access is permitted.


Previous Table of Contents Next