How to setup NFS server in Linux Mint (Ubuntu based)?

One of my NFS server running on Fedora was overloaded and I had to set up a new one. This time, I choose Linux Mint.

Setting up NFS server on Linux Mint was a breeze. Since the method we followed may be useful to other developers, I thought of sharing them here.

Logo Linux Mint

Image via Wikipedia

What is Linux Mint?

Linux Mint is a Ubuntu based Linux OS with growing popularity. Since its Ubuntu based, it inherits all the traits of Ubuntu release and add few additional functionality.

I have been using Linux Mint for about three years now starting from Linux Mint 5 till the latest Linux Mint 9. I am a great fan of this OS.

What is NFS?

The Network File System (NFS) protocol was developed by Sun Microsystems in 1984. NFS builds over Open Network Computing Remote Procedure Call, commonly called SUN ONC.

Step 1: Install NFS server and other dependent applications

Open a terminal on the Linux Mint desktop and issue the below command.

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

This will install three packages the are essential for clutter free operation of NFS.

Step 2: Configure the NFS server

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-separated list of allowed clients.

For example: To export the /var/nfs directory so that it can be accessed by any client, please insert the below line in the file – /etc/exports.

/var/nfs * (ro,async,subtree_check)

Note: Allowing any client to access your box can be potentially harmful. Please reconsider your decision before doing so.

To allow access to machines with a particular set of IP addresses, please insert the below line in /etc/exports.

/var/nfs 192.168.1.1/24 (ro,async,subtree_check)

Other options that can specified along with the IP address include:

ro:

The directory is shared read only; the client machine will not be able to write it. This is the default.

rw:

The client machine will have read and write access to the directory.

no_root_squash:

If no_root_squash is specified, then root on the client machine will have the same level of access to the files on the system as root on the server. This can have serious security implications. You should not specify this option without a good reason.

no_subtree_check:

If only part of a volume is exported, a routine called subtree checking verifies that a file that is requested from the client is in the appropriate part of the volume. If the entire volume is exported, disabling this check will speed up transfers.

sync

By default, all but the most recent version (version 1.11) of the exportfs command will use async behavior, telling a client machine that a file write is complete – that is, has been written to stable storage – when NFS has finished handing the write over to the file system. This behavior may cause data corruption if the server reboots, and the sync option prevents this.


References:

Advertisements

5 thoughts on “How to setup NFS server in Linux Mint (Ubuntu based)?

  1. “Note: Allowing any client to access your box can be potentially harmful. Please reconsider your decision before doing so.”

    If I’m not mistaken, you’ve done exactly what you warned against by having a space between the client and the options.

    /var/nfs 192.168.1.1/24 (ro,async,subtree_check)
    should be
    /var/nfs 192.168.1.1/24(ro,async,subtree_check)

    One keystroke makes all the difference in configs.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s