Blog
How to create an NFS share on Linux

Copyright © TechPad.co.uk
If you're sharing files with other Linux or Unix machines NFS is the software of choice. Here's a simple guide to configuring an NFS share on your server and mounting it from your client machine.
NFS uses a server and a client, so you'll need to configure both the machine with the directory you want to share and the client machine on which you want to mount the share.
Step 1: Install NFS on your server
First you'll need to install the nfs-kernel-server package on your server, the nfs-common package and portmap. On Debian Linux this is a simple one liner. When prompted, don't use the loopback option for portmap.
apt-get install nfs-kernel-server nfs-common portmap
Step 2: Create an NFS export on your server
Now you've got NFS and portmap installed you'll need to configure NFS so that it shares or exports the desired directories. As root, you'll need to edit the file /etc/exports and add a line with your share definition. I want to share the directory /storage with all machines on my LAN with an IP starting from 192.168.0.1 to 192.168.0.100. I want all machines to have read and write access.
/storage 192.168.*(rw,no_root_squash,async,no_subtree_check)
Step 3: Restart the NFS server
In order for the changes to take effect you'll need to restart the NFS server. You can do that with the following command, issued as root:
/etc/init.d/nfs-kernel-server restart
Step 4: Install the NFS client on your other machine
In order to use NFS on the client machine you'll need to install it. This is as easy as apt-get install portmap nfs-common.
Step 5: Create the NFS share mount point
As with most things on Linux, in order to mount anything on your machine you simply create a directory and then tell the machine to use that as your mount point. Create a directory in the location at which you want to mount your NFS share, I went for /media/NFS.
To mount this, you'll need to edit the /etc/fstab file and add an entry similar to this:
mediavault.local:/stroage /media/NFS nfs rsize=8192,wsize=8192,timeo=14,intr
Once you've saved that, as root, issue the following command and you should find that your NFS share is now available on the client machine.
Step 6: Troubleshooting
If you receive an error message such as "mount.nfs: mount to NFS server '192.168.0.99:/storage' failed: RPC Error: Program not registered" you'll need to ensure that your share definition on the server uses something like 192.168.*, not a more specific IP address.
Published: TechPad.co.uk Monday 2 November 2009, 8:44 pm
Views: 231 times
Filed under: Linux Debian servers NFS networking
Login to leave your comments
Please login










Recent comments
iplayer-dl is a Ruby application, which will run most easily on Linux or Mac (hence the Mac scree...
TechPad: 18:18 PM Aug 22nd, 2010
I don't understand how to use this. I have vista and firefox. Do I need to copy the iplayer int...
mufc1977: 15:15 PM Aug 21st, 2010
No worries, glad you got the buttons back in their rightful place!
TechPad: 13:13 PM Aug 12th, 2010
Disregard my previous comment: The FIRST time I tried it, it definitely didn't work. After addi...
freshrich: 1:01 AM Aug 10th, 2010
Great tutorial, but it doesn't work with Ubuntu Lucid. The only way I could get it to work was b...
freshrich: 1:01 AM Aug 10th, 2010