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

Option

Purpose

async

Use asynchronous file I/O.

atime

Update the inode access time for every access.

auto

Mount when -a option is used.

defaults

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

dev

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

exec

Permit execution of files from the filesystem.

netdev

Indicates a filesystem that depends on the network.

noatime

Don't update inode access time.

noauto

Don't mount with the -a option.

nodev

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

noexec

Don't allow execution of files from the filesystem.

nosuid

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

nouser

Only root can mount the filesystem.

remount

Remount a mounted filesystem with new options.

ro

Mount the filesystem read-only.

rw

Mount the filesystem read/write.

suid

Allow programs to run setuid or setgid.

sync

Use synchronous filesystem I/O.

user

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