Search Engine



RedhatEnterpriseLinux Blog

Configuring the NFS Server on the Command Line

To configure a Red Hat Enterprise Linux system as an NFS server via the command line, make sure the nfs-utils RPM package is installed.
The server configuration file, /etc/exports, uses the following format:
shared_directory allowed_hosts(options)
where shared_directory is the name of the directory to be shared, allowed_hosts is the IP address range of the allowed clients, and options is a list of NFS options for the exported directory. Obviously, the exported directory must exist. You must be root to modify this file.

For example, the following /etc/exports line allows all systems with 192.168.1.* IP
addresses read-write access to the /shared/ directory:

The sync or async option must be specified as an NFS option. If sync is specified, the server waits until the request is written to disk before responding to the client. The sync option is recommended because it follows the NFS protocol.
To grant read-write access for the exported directory, use the rw option. For a full list of NFS server options, refer to the exports man page with the command man exports. Options should be separated by commas.

Starting and Stopping the NFS Server
The root user must execute the commands to start, stop, and reload the NFS server. To start the NFS server, execute the command service nfs start. To stop the server, execute the command service nfs stop. If the server is already started and the /etc/exports configuration file is altered, the NFS server must be informed. Use the command service nfs reload to force the server to reread the configuration file.  To have the service start automatically at boot time, use chkconfig as the root user:
#chkconfig nfs on
To verify that the NFS server is running, issue the command service nfs status.

Assigning Static NFS Ports
Refer to /etc/services for a list of ports already reserved for other services on the system and then select ports over 1024 to assign to the statd, mountd, rquotad, and lockd services. In this example, the following ports will be used:
. TCP and UDP port 38001 for statd
. TCP and UDP port 38002 for statd (outgoing)
. TCP and UDP port 38003 for mountd
. TCP and UDP port 38004 for rquotad
. TCP port 38005 for lockd
. UDP port 38006 for lockd
The NFS initialization scripts check for the configuration file /etc/sysconfig/nfs for
static port assignments. If the file is not found, random ports are used for statd, mountd, rquotad, and lockd. To assign static ports, create the file /etc/sysconfig/nfs. Replace the port numbers with the ones you decided to use after examining /etc/services.


Post a Comment

Powered by Blogger.


Copyright © Redhat Enterprise linux. Original Concept and Design by My Blogger Themes
My name is Abdul Razaq but people call me Raziq. Here is my home page: I live in Quetta, Pakistan and work as an IT-Engineer.