Basic NFS

From Crashcourse Wiki

Jump to: navigation, search

Contents

Overview

This recipe explains how to set up the most basic of NFS mounts, plus some simple monitoring and debugging commands. For the purposes of the examples here, we'll use the hostnames "server" and "client" for the NFS server and client systems, respectively.

We'll also do all of this at the command line, and leave the graphical administration tool until the end.

The required software

As far as I can tell, on both the client and server systems, you need only:

# yum install nfs-utils

for basic client and server functionality.

Configuring the NFS server

The basic pre-requisite services

Before you can start NFS, you need to have the following services already running (although, on most systems, they probably are):

# service rpcbind start
# service nfslock start

Opening the firewall for incoming NFS requests

If you're running a firewall, you'll have to make allowances for incoming traffic on the following ports, based on these lines cut from the /etc/services file:

sunrpc          111/tcp         portmapper rpcbind      # RPC 4.0 portmapper TCP
sunrpc          111/udp         portmapper rpcbind      # RPC 4.0 portmapper UDP
...
nfs             2049/tcp        nfsd
nfs             2049/udp        nfsd

Exporting a directory

Pick the directory you want to make available for NFS client mounts, and add the corresponding line to the file /etc/exports, such as:

/tmp       *(ro)

The above will make available for NFS mounting the /tmp directory to the entire world with read-only permissions. Obviously, you'll pick an example that isn't so weird. Not surprisingly, that file can contain multiple entries, one per line. For the full syntax of those entries, "man exports".

Starting NFS

Once you've set up your /etc/exports file the way you want, start NFS with:

# service nfs start
Starting NFS services:                                     [  OK  ]
Starting NFS quotas:                                       [  OK  ]
Starting NFS daemon:                                       [  OK  ]
Starting NFS mountd:                                       [  OK  ]
#

You can also verify what you as the server are sharing with:

# showmount -e                            [What am I exporting?]
Export list for localhost.localdomain:
/tmp *
#

Looks good so far.

Configuring the NFS client

From the client side, you can probe a remote host to see what it's currently exporting via NFS to see what you're allowed to mount:

$ showmount -e server
Export list for server:
/tmp *
$

Excellent. And, finally, you can NFS mount that directory on your local host to, say, /mnt:

# mount server:/tmp /mnt
# mount
...
server:/tmp on /mnt type nfs (rw,addr=192.168.1.200)          <-- there we go
...
# ... access the files now under /mnt, and when you're done ...
# umount /mnt                         [to unmount it later]
#

Additional issues

Updating the server exports

If you want to change what is being exported from the server, simply update the /etc/exports file and run:

# exportfs -rv

which causes NFS to simply re-consult that exports file. You probably want to check the man page for exportfs to see what else is available.

Check what's mounted by who

You can use the showmount command (on either the server itself or from another system) to see what's currently mounted from the server, and by whom:

# showmount -a             [Run on the server.]
All mount points on localhost.localdomain:
*:/tmp
192.168.1.100:/tmp

# showmount -a server      [Run on a different system.]
All mount points on server:
*:/tmp
192.168.1.100:/tmp

In the above, the IP address of 192.168.1.100 represents the NFS client. I would recommend checking out "man showmount".

Monitoring NFS

# yum install nfswatch
# man nfswatch

I'll let you take it from there.

Graphical administration

If you want a GUI frontend for NFS server administration, then:

# yum install system-config-nfs

You can then run system-config-nfs yourself, and it will also be available in the drop-down menus under "System" -> "Administration" -> "Server Settings" -> "NFS". Once again, I'll leave you to figure that out for yourself.

Feedback to rpjday@crashcourse.ca.

Return to Fedora_Cookbook.

Personal tools