Little Girl's Mostly Linux Blog

NFSHowTo

NFS HowTo

This page was last updated on May 04, 2019.

Table of Contents

Introduction

  • Impatient? Don’t want to read a bunch of stuff? Get right to it!
  • The purpose of this document is to help you set up NFS to connect two Kubuntu or Ubuntu machines together with each machine being able to access the other.
  • These instructions were tested on one desktop computer running Ubuntu 16.04.1 LTS Xenial Xerus with the MATE desktop and another computer running Linux Mint MATE 17.1 Rebecca. The computers have a wired ethernet connection and are behind a hardware router.
  • The NFS Use Case page uses the steps on this page as an example.

Acknowledgements

This document would not have been possible without a lot of help from some of the members of the alt.os.linux.ubuntu newsgroup.

How to use this document

  • Make sure you meet the requirements in the Requirements section of this document.
  • Follow the steps in the Create the share section.
  • Refer to the Maintain the share section of this document to maintain your NFS setup if you decide to tinker with the configuration files.
  • Refer to the Troubleshooting section if you’ve followed the instructions on this page and you need to figure out why it’s not working.
  • Refer to the Further information section for links to some pages on the internet that provide more detailed information than is available here.
  • Refer to the Questions and answers section for the answers to questions that commonly come up.
  • Refer to the Examples section to compare your files with those shown here.
  • Refer to the Advanced section if you’re an expert.

Requirements

Create the share

Step 01 – Write down your information

  • You have two computers you’d like to connect together locally using NFS.
  • For each of your computers, write down:
    1. the LAN IP address
    2. the path to the folder on your computer that you’d like to share with the other computer
    3. the path to the folder on your computer that you’d like to click to visit the other computer
  • In these instructions, Sally represents computer #1 and Dave represents computer #2.
  • Follow Sally’s steps for one of your computers and Dave’s steps for the other computer.
  • With computer #1, substitute its information for Sally’s and follow Sally’s steps.
  • With computer #2, substitute its information for Dave’s and follow Dave’s steps.
  • When both computers have completed all the steps, both will be able to use the shares.
SALLY’S COMPUTER INFORMATION
192.168.1.100 Sally’s LAN IP address.
/home/sally Sally wants to share this folder with Dave.
/home/sally/shared Sally wants to click this folder to visit Dave’s computer.
DAVE’S COMPUTER INFORMATION
192.168.1.200 Dave’s LAN IP address.
/home/dave Dave wants to share this folder with Sally.
/home/dave/shared Dave wants to click this folder to visit Sally’s computer.

Step 02 – Create the mount point

A mount point is a directory on your computer that you can use as a “doorway” to somewhere else. When you open this directory on your computer, the shared files and folders from the other computer will be inside it waiting for you.

SALLY, create the mount point by typing this command in a terminal window:

mkdir /home/sally/shared
DAVE, create the mount point by typing this command in a terminal window:

mkdir /home/dave/shared

Step 03 – Install some software

These are the packages needed to follow the instructions in this guide:

  • The nfs-kernel-server package is the NFS server itself.
  • The nfs-common package will also be automatically installed and includes packages used by NFS for the client and/or the server.
  • The rpcbind package will also be automatically installed and is a server that converts RPC program numbers into universal addresses.
SALLY, install some software by typing this command in a terminal window:

sudo apt-get install nfs-kernel-server

Press the Y key on your keyboard to confirm the installation.

DAVE, install some software by typing this command in a terminal window:

sudo apt-get install nfs-kernel-server

Press the Y key on your keyboard to confirm the installation.

Step 04 – Edit the hosts.deny file

Access will be denied to any daemon or client listed in this file. A blanket denial of all makes it so that only those you specify in the hosts.allow file (see Step 08) will be granted access.

SALLY, edit the hosts.deny file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/hosts.deny
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/hosts.deny
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/hosts.deny

Add this line to the file:

rpcbind mountd nfsd statd lockd rquotad : ALL

Save the file and exit the editor.

DAVE, edit the hosts.deny file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/hosts.deny
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/hosts.deny
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/hosts.deny

Add this line to the file:

rpcbind mountd nfsd statd lockd rquotad : ALL

Save the file and exit the editor.

Step 05 – Edit the hosts.allow file

Access will be granted to any daemon or client listed in the file. An entry needs to contain the daemon or client followed by a colon followed by a space followed by the IP of the computer you want to grant access to. Additional IPs can be added by putting a space between each one and the one before it. The daemons and clients shown in the examples below are used by NFS.

SALLY, edit the hosts.allow file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/hosts.allow
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/hosts.allow
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/hosts.allow

Add this line to the file:

rpcbind mountd nfsd statd lockd rquotad: 127.0.0.1 192.168.1.200

Save the file and exit the editor.

DAVE, edit the hosts.allow file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/hosts.allow
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/hosts.allow
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/hosts.allow

Add this line to the file:

rpcbind mountd nfsd statd lockd rquotad: 127.0.0.1 192.168.1.100

Save the file and exit the editor.

Step 06 – Edit the exports file

This file defines what you’re willing to share and who you’re willing to share it with. Each line of the file is a share. An NFS entry needs to contain the location of the directory you want to share followed by the IP of the computer you wish to share it with followed by rules (in parentheses) of what the computer at that IP can and cannot do. To share a folder with more than one computer, place the IPs and the rules for each one on the same line as the directory you want to share, separating them from one another with a space. In the examples below:

  • rw means the other computer can read and write to your shared directory and its subdirectories.
  • sync basically means your computer must be finished processing any changes made to files or directories in your shared directory before it proceeds with any further action on those files or folders.
  • no_subtree_check means NFS doesn’t have to check the location of files every time the other computer accesses them, which makes it possible for you to rename a file the other computer has open.

See the exports man page to make different choices for what the other computer can and cannot do.

SALLY, edit the exports file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/exports
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/exports
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/exports

Add this line to the bottom of the file:

/home/sally 192.168.1.200(rw,sync,no_subtree_check)

Save the file and exit the editor.

DAVE, edit the exports file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/exports
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/exports
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/exports

Add this line to the bottom of the file:

/home/dave 192.168.1.100(rw,sync,no_subtree_check)

Save the file and exit the editor.

Step 07 – Edit the fstab file

This file defines the file systems your computer mounts when you boot the computer. Examples of file systems are entire drives or parts of drives (partitions), CD or DVD drives, or NFS shares. Your fstab file will already have entries in it. An NFS entry needs to contain the other computer’s IP followed by the path to the directory the other computer wants to share with you followed by the directory on your computer that you want to use as a “doorway” to the other computer (your mount point) followed by the type of file system that is being mounted followed by a list of options that define how NFS is allowed to behave in the shared directory. In the examples below:

  • nfs is the type of file system that is being mounted.
  • users allows any user to mount and to unmount the filesystem.
  • rw mounts the filesystem as read/write.
  • hard tells NFS to keep retrying if a request times out.
  • intr does its best to protect your data from corruption by allowing signals to interrupt file operations in the shared directory.
  • noauto means the share can only be mounted explicitly and will not be automatically mounted on boot-up.
  • noexec forbids direct execution of binary files on the mounted file system.
  • 0 0 (the two zeros at the end of the line) are for file system backup and file system checks on certain file system types. Since NFS doesn’t use either of these things, the value of each is zero, which means that the directory shared by the other computer won’t be included in a file system backup or a file system check.

See the nfs, fstab and mounts man pages to make different choices for how NFS should be allowed to behave.

SALLY, edit the fstab file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/fstab
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/fstab
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/fstab

Add this line to the bottom of the file:

192.168.1.200:/home/dave /home/sally/shared nfs users,rw,hard,intr,noauto,noexec 0 0

Save the file and exit the editor.

DAVE, edit the fstab file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/fstab
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/fstab
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/fstab

Add this line to the bottom of the file:

192.168.1.100:/home/sally /home/dave/shared nfs users,rw,hard,intr,noauto,noexec 0 0

Save the file and exit the editor.

Step 08 – Edit the nfs-common file

The nfs-common file controls support files that are common to the NFS client and server. The GSSD setting controls the NFS v4 securityj, but I believe it’s now obsolete (feel free to correct me on this).

SALLY, edit the nfs-common file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/default/nfs-common
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/default/nfs-common
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/default/nfs-common

Find this line in the file:

NEED_GSSD=

Replace it with this line:

NEED_GSSD="no"

Save the file and exit the editor.

DAVE, edit the nfs-common file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/default/nfs-common
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/default/nfs-common
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/default/nfs-common

Find this line in the file:

NEED_GSSD=

Replace it with this line:

NEED_GSSD="no"

Save the file and exit the editor.

Step 09 – Edit the nfs-kernel-server file

The GSSD line in the nfs-kernel-server file controls the NFS v4 security. It should not be set as active because you are not activating NFSV4 security at this time and I believe it’s now obsolete (feel free to correct me on this).

SALLY, edit the nfs-kernel-server file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/default/nfs-kernel-server
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/default/nfs-kernel-server
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/default/nfs-kernel-server

Find the NEED_SVCGSSD line in the file.

Replace it with this:

NEED_SVCGSSD="no"

Save the file and exit the editor.

DAVE, edit the nfs-kernel server file with one of these commands:

  • If you use Kubuntu, type this command in a terminal window:
  • kdesudo kate /etc/default/nfs-kernel-server
  • If you use Ubuntu, type this command in a terminal window:
  • gksudo gedit /etc/default/nfs-kernel-server
  • If you use Linux Mint MATE, type this command in a terminal window:
  • gksudo pluma /etc/default/nfs-kernel-server

Find the NEED_SVCGSSD line in the file.

Replace it with this:

NEED_SVCGSSD="no"

Save the file and exit the editor.

Step 10 – Export your share

This command lets your computer know about any changes you’ve made in your /etc/exports file.

SALLY, export your share by typing this command in a terminal window:

sudo exportfs -ar
DAVE, export your share by typing this command in a terminal window:

sudo exportfs -ar

Step 11 – Restart nfs-kernel-server

This command restarts the NFS server. This makes sure the server is aware of any changes you’ve made to the configuration files mentioned above.

SALLY, restart nfs-kernel-server by typing this command in a terminal window:

sudo service nfs-kernel-server restart
DAVE, restart nfs-kernel-server by typing this command in a terminal window:

sudo service nfs-kernel-server restart

Work with the share

Connect to the share

To manually connect to the share, you need to mount the directory on your computer that you are using as a “doorway” to the shared files from the other computer.

SALLY, If Dave booted his computer after you booted yours, you’ll need to manually connect to his share. To do so, type this command in a terminal window:

sudo mount /home/sally/shared
DAVE, if Sally booted her computer after you booted yours, you’ll need to manually connect to her share. To do so, type this command in a terminal window:

sudo mount /home/dave/shared

Use the share

The share is treated just like any other part of your computer, other than any restrictions set by you or the other computer when setting it up. You, and the programs on your computer, can access the files and folders in the share normally.

SALLY, open your file manager and you’ll find the shared folder you created inside your /home/sally folder. Clicking on this shared folder will put you on Dave’s computer. You can also open files on Dave’s computer by browsing to them from within various programs you run on your computer. If you prefer to access Dave’s computer using the command line, use /home/sally/shared to get to it.
DAVE, open your file manager and you’ll find the shared folder you created inside your /home/dave folder. Clicking on this shared folder will put you on Sally’s computer. You can also open files on Sally’s computer by browsing to them from within various programs you run on your computer. If you prefer to access Sally’s computer using the command line, use /home/dave/shared to get to it.

Disconnect from the share

To disconnect from the share, you need to unmount the directory on your computer that you are using as a “doorway” to the shared files from the other computer.

SALLY, if you wish to disconnect the shared folder from Dave’s computer, in a terminal window type:

sudo umount /home/sally/shared
DAVE, if you wish to disconnect the shared folder from Sally’s computer, in a terminal window type:

sudo umount /home/dave/shared

Maintain the share

SALLY and DAVE, if you tinker with your configuration files by making changes in them, you’ll need to either restart NFS or restart the network. Sometimes both will be necessary. Here’s how:

Restart NFS

  • Type these commands in a terminal window one by one:
    • sudo exportfs -ar
    • sudo service nfs-kernel-server restart

Restart the network

  • Type this command in a terminal window:
  • sudo service network-manager restart

Appendix

Examples

These examples show only the relevant information that pertains to NFS. Some files on your computer (like the /etc/fstab file, for instance) may contain more than what is shown here.

/etc/network/interfaces

SALLY’S /etc/network/interfaces file:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1
DAVE’S /etc/network/interfaces file:

auto lo
iface lo inet loopback
address 127.0.0.1
netmask 255.0.0.0

auto eth0
iface eth0 inet static
address 192.168.1.200
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 192.168.1.1

/etc/hosts.deny

SALLY’S /etc/hosts.deny file:

# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

rpcbind mountd nfsd statd lockd rquotad: ALL
DAVE’S /etc/hosts.deny file:

# /etc/hosts.deny: list of hosts that are _not_ allowed to access the system.
#                  See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: some.host.name, .some.domain
#             ALL EXCEPT in.fingerd: other.host.name, .other.domain
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
# The PARANOID wildcard matches any host whose name does not match its
# address.
#
# You may wish to enable this to ensure any programs that don't
# validate looked up hostnames still leave understandable logs. In past
# versions of Debian this has been the default.
# ALL: PARANOID

rpcbind mountd nfsd statd lockd rquotad: ALL

/etc/hosts.allow

SALLY’S /etc/hosts.allow file:

# /etc/hosts.allow: list of hosts that are allowed to access the system.
#                   See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: LOCAL @some_netgroup
#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
rpcbind mountd nfsd statd lockd rquotad: 127.0.0.1 192.168.1.200
DAVE’S /etc/hosts.allow file:

# /etc/hosts.allow: list of hosts that are allowed to access the system.
#                   See the manual pages hosts_access(5) and hosts_options(5).
#
# Example:    ALL: LOCAL @some_netgroup
#             ALL: .foobar.edu EXCEPT terminalserver.foobar.edu
#
# If you're going to protect the portmapper use the name "portmap" for the
# daemon name. Remember that you can only use the keyword "ALL" and IP
# addresses (NOT host or domain names) for the portmapper, as well as for
# rpc.mountd (the NFS mount daemon). See portmap(8) and rpc.mountd(8)
# for further information.
#
rpcbind mountd nfsd statd lockd rquotad: 127.0.0.1 192.168.1.100

/etc/exports

SALLY’S /etc/exports file:

# /etc/exports: the access control list for filesystems which may be exported
#		to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/sally 192.168.1.200(rw,sync,no_subtree_check)
DAVE’S /etc/exports file:

# /etc/exports: the access control list for filesystems which may be exported
#		to NFS clients.  See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes       hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4        gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes  gss/krb5i(rw,sync,no_subtree_check)
#
/home/dave 192.168.1.100(rw,sync,no_subtree_check)

/etc/fstab

The bottom line of text in SALLY’S /etc/fstab file:

192.168.1.200:/home/dave /home/sally/shared nfs users,rw,hard,intr,noauto,noexec 0 0
The bottom line of text in DAVE’S /etc/fstab file:

192.168.1.100:/home/sally /home/dave/shared nfs users,rw,hard,intr,noauto,noexec 0 0

/etc/default/nfs-common

SALLY’S /etc/default/nfs-common file:

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS
STATDOPTS=

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD="no"
DAVE’S /etc/default/nfs-common file:

# If you do not set values for the NEED_ options, they will be attempted
# autodetected; this should be sufficient for most people. Valid alternatives
# for the NEED_ options are "yes" and "no".

# Do you want to start the statd daemon? It is not needed for NFSv4.
NEED_STATD=

# Options for rpc.statd.
#   Should rpc.statd listen on a specific port? This is especially useful
#   when you have a port-based firewall. To use a fixed port, set this
#   this variable to a statd argument like: "--port 4000 --outgoing-port 4001".
#   For more information, see rpc.statd(8) or http://wiki.debian.org/SecuringNFS
STATDOPTS=

# Do you want to start the gssd daemon? It is required for Kerberos mounts.
NEED_GSSD="no"

/etc/default/nfs-kernel-server

SALLY’S /etc/default/nfs-kernel-server file:

# Number of servers to start up
# To disable nfsv4 on the server, specify '--no-nfs-version 4' here
RPCNFSDCOUNT=8

# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0

# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
RPCMOUNTDOPTS=--manage-gids

# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD="no"

# Options for rpc.svcgssd.
RPCSVCGSSDOPTS=

# Options for rpc.nfsd.
RPCNFSDOPTS=
DAVE’S /etc/default/nfs-kernel-server file:

# Number of servers to start up
# To disable nfsv4 on the server, specify '--no-nfs-version 4' here
RPCNFSDCOUNT=8

# Runtime priority of server (see nice(1))
RPCNFSDPRIORITY=0

# Options for rpc.mountd.
# If you have a port-based firewall, you might want to set up
# a fixed port here using the --port option. For more information,
# see rpc.mountd(8) or http://wiki.debian.org/SecuringNFS
# To disable NFSv4 on the server, specify '--no-nfs-version 4' here
RPCMOUNTDOPTS=--manage-gids

# Do you want to start the svcgssd daemon? It is only required for Kerberos
# exports. Valid alternatives are "yes" and "no"; the default is "no".
NEED_SVCGSSD="no"

# Options for rpc.svcgssd.
RPCSVCGSSDOPTS=

# Options for rpc.nfsd.
RPCNFSDOPTS=

/etc/idmapd.conf

SALLY’S /etc/idmapd.conf file:

[General]

Verbosity = 0
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
# Domain = localdomain

[Mapping]

Nobody-User = nobody
Nobody-Group = nogroup
DAVE’S /etc/idmapd.conf file:

[General]

Verbosity = 0
Pipefs-Directory = /run/rpc_pipefs
# set your own domain here, if id differs from FQDN minus hostname
# Domain = localdomain

[Mapping]

Nobody-User = nobody
Nobody-Group = nogroup

Advanced

Alternate way of installing hosts.allow and hosts.deny
As part of the instructions in this document, tcpd is installed so that the /etc/hosts.allow and /etc/hosts.deny files are created automatically. The tcpd package is not required for these instructions to work. You advanced users can use the touch command to create both of these files instead of installing tcpd.

Why I chose sync instead of async in /etc/exports
In the /etc/exports file I have chosen to use sync instead of async. I realize this causes a performance hit, but I feel that protecting the stability and reducing the likelihood of file corruption is worth it. Feel free to change the command if you prefer the performance increase and are aware of the risks.

Why I used noexec in /etc/fstab
In the /etc/fstab file I have chosen to use noexec to prevent direct execution of binaries on the mounted file system. This is being done for security purposes. If your use of NFS requires execution of binaries, you’ll want to remove the noexec portion of the command.

For those who don’t use a hardware router
For you experts who don’t use a hardware router and have your reasons for making this choice, I’m confident that the process by which you came to that decision makes it so that you’ll know how to work around the router information in this document.

Using these instructions for more than two computers
These instructions can be applied to more than two computers by repeating either Sally’s or Dave’s steps for the newly added computer, adding the information for each additional computer when editing the files, and editing the files on the other computer(s) that have already been set up with NFS to include the new computer(s) on the network. See my NFSUseCase page for an example with three computers.

Further information

Questions and answers

I followed Sally’s steps and can’t connect to my other (Dave’s) computer. Why?
Since each computer must grant access to the other, both computers must follow the steps for the shares to work. If you’ve only set up one computer so far, this could explain the difficulty. If you’ve done that and still can’t connect, go through all the files in the Examples section one by one, viewing the files on each of your computers to make sure the information in each has the correct information for that machine, no typos, etc.

I have a question that hasn’t been asked here. How do I ask it?
If you use the contact address at the top of this document, you will receive a reply via email and your question may be added to this section.

Troubleshooting

Most troubleshooting can be done by:

  • Making sure that you meet the requirements in the Requirements section.
  • Verifying that you have completed the steps to set up NFS.
  • Comparing your computer’s files against those in the Examples section.
  • Checking that your servers are running. In a terminal window type each of these:
    • sudo /etc/init.d/nfs-common status
    • sudo /etc/init.d/nfs-kernel-server status

    If any of them aren’t reported as running, repeat the steps in the Maintain the share section of this document.

  • Making sure that your firewall isn’t preventing your computer from connecting with the other computer (you may have to open ports 111 and 2049 for NFS to work, but see the instructions for your firewall for more information).

There’s always the possibility that something outside the scope of this document is causing trouble for you. For example, I haven’t covered wireless networking. I highly recommend that you check out the Further Information and Questions and answers sections for further troubleshooting.

If you need more help than is available here, see my GettingHelp page.

Obligatory Happy Ending

And they all lived happily ever after. The end.

Back to top

Creative Commons License Content on this page of the https://mostlylinux.wordpress.com blog is Copyright © 2007 – 2017 by Little Girl, licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License, and offered free of charge without warranty of any kind, either expressed or implied.

34 Comments »

  1. I want to thank you for providing such awonderfully clear and detailed instructions! It is so nice to work with this information instead of the usual scrounging through bulletin boards. I’m not knocking them –

    Comment by fitzhugh — July 14, 2009 @ 11:20 am

  2. oops, hit return…,
    just saying bulletin boards are great, nearly always find the answer eventually, but it is so much easier when someone takes the time to collect all the info, especially when that person knows how to present information to their audience as well as you.
    Thanks!

    Comment by fitzhugh — July 14, 2009 @ 11:25 am

    • Thanks for the kind words! This particular page is one of my pet projects since I had such a tough time with it when I first set it up. I couldn’t get it working no matter what I tried, resulting in an all-consuming epic battle that must be overcome. When I finally got it, it was like a personal epiphany, so NFS has become a deeply loved adopted child. (:

      Comment by mostlylinux — July 14, 2009 @ 1:40 pm

  3. Awesome guide. Thanks so much for sharing. Found this from a post over at kubuntuforums.net. I can’t tell you how many times I’ve pulled my hair out over NFS. I’m still amazed no one’s ever (to my knowledge) developed a GUI to just set this stuff more easily. But at least we have this! :)

    Comment by Blue Mint (@TheBlueMint) — December 27, 2011 @ 4:04 pm

    • I feel your pain! We pulled our hair out over NFS while everyone around said, “Just do _____!” only to find out that their solutions didn’t work for us. A GUI would be wonderful. Maybe we should all ask for it from Those In Power and see if someone goes for it. (:

      Comment by mostlylinux — December 27, 2011 @ 4:57 pm

  4. I’m curious about steps 5 though 8. I needed to use “sudo touch” because “touch” by itself, to create files in /etc, failed, as I would have expected. Should you add that to your instructions?

    Also…why is the touch process required? I was able to create the files immedately with steps 7 and 8 — “kdesudo kate” doesn’t require that a file exist before you edit it.

    Comment by Steve Riley — December 28, 2011 @ 3:37 am

    • Good catch on the sudo touch correction! I’ve fixed it on this page and also on the sister NFS Use Case page. (:

      You’re right that the touch process isn’t required and that Kate could do the job without it. I use it here to separate the steps and to ensure the files get saved to the proper location.

      Comment by mostlylinux — December 28, 2011 @ 2:56 pm

  5. very good explanation :)

    Comment by linuxhospital — October 10, 2012 @ 10:30 am

  6. Nice explaination Thank you

    Comment by bipullinux — January 10, 2013 @ 2:17 am

  7. Your NFS guide is the best out there,
    simple and easy content and layout.
    helped me set up a stable connection quickly.
    Thanks very much.

    Comment by keys — January 29, 2013 @ 6:52 pm

    • I’m glad to hear it! We’ll be working through the steps with the latest releases of Kubuntu and possibly Ubuntu, and if the instructions need to be updated, there should be a new version of them soon. (:

      Comment by mostlylinux — June 2, 2013 @ 8:36 am

  8. THANK YOU SOOO MUCH – being trying to share a HD connected to my Raspberry Pi with an Ubuntu Machine over a LAN for about two weeks – followed loads of other tutorials (learned a little!) but yours is the only one which has worked – possibly because it is detailed and complete. I can now have a backup running nicely in the back ground with out worrying about where in the house my laptop is :) Thanks again!

    Comment by Brett — June 3, 2013 @ 1:22 pm

    • Oh, you’re very welcome! I love to hear the success stories, because I remember how frustrating it was when we first tried to do it and just couldn’t get it to work with all the tutorials out there. We still have the flat spots on our foreheads from banging our heads against walls trying to figure out what we were doing wrong. Enjoy your backups and connectivity! (:

      Comment by mostlylinux — June 3, 2013 @ 7:52 pm

  9. Now i just need to get the server to share to my raspberry Pi, its been very fun these last 4 hours…

    Comment by keys — July 4, 2013 @ 7:58 am

    • Hopefully the updated instructions I just put up will make that a bit easier. (:

      Comment by mostlylinux — July 13, 2013 @ 3:07 am

  10. Thanks for creating this easy to follow guide! I have two Kubuntu computers, and for some reason, one of them refuses to “identify” itself using Samba. No computer could ever find it. I’ve heard people say to use NFS, but had no idea how to set it up. My only goal was to simply share a “public” file on each computer to assist in transferring files back and forth. This guide allow me to share both of my home directories, which greatly expands my original idea. Well done!

    Comment by scottykutah — October 25, 2013 @ 4:43 pm

    • Oh, I’m so glad to hear it! There’s a part of me that would remain curious as to why Samba didn’t work, though, and probably mess with it to find out. (:

      Comment by mostlylinux — October 25, 2013 @ 6:55 pm

  11. Great document. I follow it and work awesome.
    I would like to add that a chmod a+w is needed on the shared directory (server side) if you want that your partner can write on that.

    Comment by Sergio — November 12, 2013 @ 10:54 am

    • I’m glad it worked for you! As far as the chmod a+w, we didn’t need to do that in Kubuntu, but since it might be needed by some, I’m glad you mentioned it. (:

      Comment by mostlylinux — November 17, 2013 @ 2:02 pm

  12. […] folder I set is a user folder within the /home diretory in each machine). I used this tutorial, https://mostlylinux.wordpress.com/network/nfshowto/ The problem I have is that I can't make a partition mounted to a folder within the shared folder […]

    Pingback by NFS file sharing is working, but mounted partitions are not visible through network. — March 25, 2014 @ 2:44 pm

    • You might want to read through all the options in the exports man page by typing man exports in a terminal window or here. You can edit the section in parentheses in your /etc/exports file, removing no_subtree_check or adding crossmnt (don’t forget to remove or add the comma in front of them). If neither of those works, maybe one or more of the other options will. Good luck, and let me know how it turns out!

      Comment by mostlylinux — March 25, 2014 @ 4:03 pm

  13. Badawcze teksty, dobra tematyka

    Comment by Edwin — September 30, 2014 @ 9:59 pm

    • Cieszę się, że Ci się spodoba. Dziękujemy za wizytę! (:

      Comment by mostlylinux — September 30, 2014 @ 10:15 pm

  14. Thank You, You’ve enabled me, after weeks of surfing, to connect/share laptops running Mint17 and Ubuntu 14. Other than my typos it works beautifully. I also use a XOOM tablet for downloading, can u advise/direct me how to access it from the laptops before I start surfing again. Thank You again for the excellent work.

    Comment by Mitchell — December 2, 2014 @ 2:36 am

    • You’re welcome! I’m glad to hear you’ve got your Mint and Ubuntu machines connected together smoothly! As to the XOOM tablet, I’m not familiar with it, but a quick Google told me it’s an Android tablet. Here are a few pages that might be able to help, but I don’t have a XOOM tablet, so I can’t test their instructions or advice:

      Last, but not least, you could try the Ask Ubuntu Problems mounting Nexus 7 page. Although it’s for the Nexus 7, Motorola is listed as one of the vendors in step 3 of Answer 2, so you should be able to use those steps with your tablet.

      Hopefully one of these methods will work for you. Good luck! (:

      Comment by mostlylinux — December 2, 2014 @ 9:02 am

      • Thank You for the prompt reply. Will try the links. I have no problems connecting tablet via USB to each laptop, ideally I’m looking to plug into the router or wireless so any laptop can access it or vice versa. Will feedback when it works. Best Regards.

        Comment by Mitchell — December 2, 2014 @ 10:14 am

        • Ah, okay, that’s something I haven’t tried to do, because we keep our tablets completely separate from our networked computers. I’d be interested to hear how you get it going, though. (:

          Comment by mostlylinux — December 3, 2014 @ 11:22 am

  15. Strona świadczy o nietypowych zagadnieniach, namawiam do dyskusji

    Comment by kopertowanie — December 6, 2014 @ 12:45 am

  16. Nader odlotowy post, interesujące teksty polecam wszystkim lekturę

    Comment by ocieplenie pianką  poliuretanową — December 16, 2014 @ 10:29 pm

  17. Great help! I’ve used this guide to connect a new computer with Kubuntu 14.04 client to our office server running OpenSuse. It’s very easy on OpenSuse thanks to graphical interface Yast. I had hesitations to do the same in Kubuntu because of command line procedure which I’m not much familiar with but in a few minutes it was over! Thanks for preparing this document.

    Comment by Aykut Turhan — November 4, 2015 @ 8:22 am

    • You’re very welcome, and I’m so glad to hear it went well! I hadn’t heard of YaST before, so I looked it up. Cool – it even offers NFS set-up. In Linux Mint MATE, which I now use, we have Control Center, but that doesn’t offer any NFS options. It’s good that you tried the command line, because it’s a powerful tool and can be quite fun and satisfying to use. (:

      Comment by mostlylinux — November 4, 2015 @ 10:03 am


RSS feed for comments on this post. TrackBack URI

Comment:

Create a free website or blog at WordPress.com.