[How-To] Installing and Configuring NFS

The NFS (Network File System) protocol allows a system to share directories and files with others over a network (Unix and Linux envirenments).

Server Side:

1. Install NFS on Ubuntu Server

$ sudo apt-get install portmap nfs-kernel-server

2. Create the directories you wish to export (share)

$ sudo mkdir /SharedFolder1
$ sudo mkdir /SharedFolder2
$ sudo chmod 777 SharedFolder1
$ sudo chmod 775 SharedFolder2

3. Configure local settings such as POSIX permissions, owners and groups

REMEMBER: The most RESTRICTIVE combination of LOCAL and NFS permissions is what acrually applies.

4. Add the directories you wish to export (share) to the /etc/exports file

$ sudo cat /etc/exports
  • rw: This option allows the client server to both read and write within the shared directory.
  • sync: Sync confirms requests to the shared directory only once the changes have been committed.
  • no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger filesystem, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
  • no_root_squash: This phrase allows root to connect to the designated directory.

5. Export the file system

$ sudo exportfs -a

6. Restart the NFS daemon

$ sudo /etc/init.d/nfs-kernel-server restart

Clients Side:

1. Install the client tools for mounting NFS file systems

$ sudo apt-get install portmap nfs-common

2. Create mount point

$ sudo mkdir -p /mnt/SharedFolder1
$ sudo mkdir -p /mnt/SharedFolder2

3. Show the mount from the NFS Server

$ showmount -e
Export list for

4. Mount network shares with NFS

$ sudo mount -t nfs
$ sudo mount -t nfs

5. Use fstab to ensure that the mount is always active (Optional)

$ cat /etc/fstab    /mnt/SharedFolder1    nfs    auto,noatime,nolock,bg    0    0    /mnt/SharedFolder2    nfs    auto,noatime,nolock,bg    0    0

6. Use autofs for automatically mounting directories on an as-needed (Optional)

$ sudo apt-get install autofs
$ cat /etc/auto.master
/mnt/    /etc/auto.nfs

$ cat /etc/auto.nfs
SharedFolder1    -fstype=nfs
SharedFolder2    -fstype=nfs

The mount will be:

  • /mnt/SharedFolder1
  • /mnt/SharedFolder2

7. Remove the NFS mount

$ sudo umount /mnt/SharedFolder1
$ sudo umount /mnt/SharedFolder2

Enjoy !


Tagged: , , , , , ,

3 thoughts on “[How-To] Installing and Configuring NFS

  1. Christian Svensson December 13, 2013 at 10:12 am Reply

    Nice writeup!

    I think you have a typo in ‘Server-side’ step 4. You have SharedFolder1 twice there.

    • Boubakr December 13, 2013 at 10:53 am Reply

      Thank you Christian,
      Well corrected.

  2. […] 1. Install and Configure NIS 2. Install and Configure NFS […]

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

%d bloggers like this: