Este conteúdo não está disponível no idioma selecionado.
8.2. Configuring NFS Client
The
mount
command mounts NFS shares on the client side. Its format is as follows:
# mount -t nfs -o options server:/remote/export /local/directory
This command uses the following variables:
- options
- A comma-delimited list of mount options; for more information on valid NFS mount options, see Section 8.4, “Common NFS Mount Options”.
- server
- The hostname, IP address, or fully qualified domain name of the server exporting the file system you wish to mount
- /remote/export
- The file system or directory being exported from the server, that is, the directory you wish to mount
- /local/directory
- The client location where /remote/export is mounted
The NFS protocol version used in Red Hat Enterprise Linux 7 is identified by the
mount
options nfsvers
or vers
. By default, mount
uses NFSv4 with mount -t nfs
. If the server does not support NFSv4, the client automatically steps down to a version supported by the server. If the nfsvers
/vers
option is used to pass a particular version not supported by the server, the mount fails. The file system type nfs4 is also available for legacy reasons; this is equivalent to running mount -t nfs -o nfsvers=4 host:/remote/export /local/directory
.
For more information, see
man mount
.
If an NFS share was mounted manually, the share will not be automatically mounted upon reboot. Red Hat Enterprise Linux offers two methods for mounting remote file systems automatically at boot time: the
/etc/fstab
file and the autofs
service. For more information, see Section 8.2.1, “Mounting NFS File Systems Using /etc/fstab
” and Section 8.3, “autofs
”.
8.2.1. Mounting NFS File Systems Using /etc/fstab
An alternate way to mount an NFS share from another machine is to add a line to the
/etc/fstab
file. The line must state the hostname of the NFS server, the directory on the server being exported, and the directory on the local machine where the NFS share is to be mounted. You must be root to modify the /etc/fstab
file.
Example 8.1. Syntax Example
The general syntax for the line in
/etc/fstab
is as follows:
server:/usr/local/pub /pub nfs defaults 0 0
The mount point
/pub
must exist on the client machine before this command can be executed. After adding this line to /etc/fstab
on the client system, use the command mount /pub
, and the mount point /pub
is mounted from the server.
A valid
/etc/fstab
entry to mount an NFS export should contain the following information:
server:/remote/export /local/directory nfs options 0 0
The variables server, /remote/export, /local/directory, and options are the same ones used when manually mounting an NFS share. For more information, see Section 8.2, “Configuring NFS Client”.
Note
The mount point /local/directory must exist on the client before
/etc/fstab
is read. Otherwise, the mount fails.
After editing
/etc/fstab
, regenerate mount units so that your system registers the new configuration:
#
systemctl daemon-reload
Additional Resources
- For more information about
/etc/fstab
, refer toman fstab
.