Network File System in Debian.

Installing NFS in Debian

Making your computer an NFS server or client is very easy. The Debian NFS client needs:

# apt-get install nfs-common portmap

while a Debian NFS server needs:

# apt-get install nfs-kernel-server nfs-common portmap

NFS Server Configuration.

NFS exports from a server are controlled by the file /etc/exports. Each line begins with the absolute path of a directory to be exported, followed by a space-seperated list of allowed clients.

/etc/exports
/home 192.168.1.2(rw,no_root_squash) www.domain.com(ro)
/usr 192.168.1.2/24(ro,insecure)

A client can be specified either by name or IP address. Wildcards (*) are allowed in names, as are netmasks (e.g. /24) following IP addresses, but should usually be avoided for security reasons.

A client specification may be followed by a set of options, in parenthesis. It is important not to leave any space between the last client specification character and the opening parenthesis, since spaces are intrepreted as client seperators.

For each options specified in /etc/exports file can be check export man pages.
If you make changes to /etc/exports on a running NFS server, you can make these changes effective by issuing the command:

# exportfs -a

NFS Client Configuration

NFS volumes can be mounted by root directly from the command line. For example:

# mount files.domain.com:/home /mnt/nfs

mounts the /home directory from the machine files.domain.com as the directory /mnt/nfs on the client. Of course, for this to work, the directory /mnt/nfs must exist on the client and the server must have been configured to allow the client to access the volume.

It is more usual for clients to mount NFS volumes automatically at boot-time. NFS volumes can be specified like any others in /etc/fstab.

/etc/fstab
192.168.1.3:/home /home nfs rw,rsize=4096,wsize=4096,hard,intr,async,nodev,nosuid 0 0
192.168.1.3:/usr /usr nfs ro,rsize=8192,hard,intr,nfsvers=3,tcp,noatime,nodev,async 0 0

There are two kinds of mount options to consider: those specific to NFS and those which apply to all mounts. Consider first those specific to NFS.

For each options menctioned in /etc/fstab file check the man pages of fstab.

Leave a Reply

Your email address will not be published. Required fields are marked *

*