The mount Command

Before using an NFS directory, attach it to the local filesystem with the mount command. The mount command can be as simple or as complex as it needs to be to get the job done.

At its simplest, mount identifies the remote filesystem to access and the local directory through which it will be accessed. The remote filesystem is identified by the server name, paired with all or part of a directory exported by the server. The local directory is just that—the name of an empty directory created to mount the remote NFS directory. The local directory is called the mount point. Putting this all together, you could mount the directories exported by wren with the mount commands shown in Listing 9.5.

Listing 9.5: Sample Mount Commands

# mount wren:/usr/local/bin /usr/local/bin

# mount wren:/usr/local/man /usr/local/man

# mount wren:/usr/local/doc /usr/local/doc

The Listing 9.5 examples assume that empty /usr/local/bin, /usr/local/man, and /usr/local/doc directories existed on the client before the mount commands were issued. It wouldn't make sense to mount a remote directory full of manual pages over an existing directory unless that directory were empty. The purpose for creating central repositories for man pages and documentation is to save storage on client systems and simplify management. You can do that only if the directories on the client are actually empty.

A simple mount command works under most circumstances, but when needed, options can be added to the mount command line with the -o argument. Table 9.1 lists the mount command options that apply to all types of filesystems.

Table 9.1: Linux mount Command Options




Use asynchronous file I/O.


Update the inode access time for every access.


Mount when -a option is used.


Set rw, suid, dev, exec, auto, nouser, and async.


Allow character devices, and block special devices on the filesystem.


Permit execution of files from the filesystem.


Indicates a filesystem that depends on the network.


Don't update inode access time.


Don't mount with the -a option.


Don't allow character devices, and block special devices on the filesystem.


Don't allow execution of files from the filesystem.


Don't allow programs stored on the filesystem to run setuid or setgid.


Only root can mount the filesystem.


Remount a mounted filesystem with new options.


Mount the filesystem read-only.


Mount the filesystem read/write.


Allow programs to run setuid or setgid.


Use synchronous filesystem I/O.


Permit ordinary users to mount the filesystem.

Note Despite the length of this list, you will see even more NFS mount options in the next section.

Assume that you want to mount the /usr/local/bin directory, but for security reasons you don't want to allow any of the programs stored there to run with setuid or setgid permission. You could enter the following mount command:

# mount -o nosuid wren:/usr/local/bin /usr/local/bin

Was this article helpful?

0 0

Post a comment