Black God

How to configure NFS Server and mount it in Ubuntu

This is a little note on how to configure NFS (Network File System) server and mount it in Ubuntu. The server is Debian Squeeze and Client is Ubuntu 10.04. Here is how to get it done.

Server configuration

Step-1: Installing NFS packages.

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

Step-2: Configuring file system to export

Through NFS, you can export a file system or a directory to clients. The /etc/exports file defines the stuff to be exported for other system. The syntax is like,

<path of file system>        <client machine-1>(options)                 <client machine-2>(options) …..

In the below example, I am exporting the /home/nas/torrents directory in server to client machine with IP address of 192.168.0.100 in Read-only mode.

/home/nas/torrents  192.168.0.100(ro,insecure)

Step-3: Updating the NFS server with new exported file system configuration

This can be done either through below command,

# exportfs -a

or by restarting the NFS service as shown below in Debian.

# /etc/init.d/nfs-common restart
Note: In case you have authentication problem, please check with /etc/hosts.allow file for access. You can try no_root_squash option also in entry in /etc/exports file.

Client configuration

Step-1: Install the NFS package from command line as shown below.

$ sudo apt-get install nfs-common

Step-2: Client machine can access NFS exports by having an entry in /etc/fstab file as shown below. In this case the server IP address is 192.168.0.103.

192.168.0.103:/home/nas/torrents    /mnt/torrents    nfs    defaults    0    0

Another ways to access through command line is as shown below.

# mount -t nfs 192.168.0.103:/home/nas/torrents /mnt/torrents

2 comments for “How to configure NFS Server and mount it in Ubuntu

  1. pamchi
    December 1, 2011 at 3:31 am

    En donde se indica en que puerto va a estar el NFS en el servidor? como podes setear las reglas del firewall?

Leave a Reply

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