NFS is a great way to share and get access to files across a network. The NFS system gives the option to mount a NFS from an external system and a local mount point on your locale system.
To get this working, you need two systems – a server and a client.
Installing the NFS Server
I have en Debian server running, where I would like easy access to some of the folders from my workstation. To do this, I will install the nfs-kernel-server and the portmap packages like this:
# aptitute install nfs-kernel-server portmap
The NFS server and the portmap service is now installed and up and running.
Which folders to share
To defined which folder we want to share and to which client, we have to take a look at the /etc/exports file. So open /etc/exports in you favorite editor and insert a line like this:
This tells the NFS service, that I want to share my home folder /home/js to the client at IP 192.168.1.2 with read-write (rw) access.
To reload the defined exports I have to run the exportfs command like this:
# exportfs -a
That’s it – we done here
Access the NFS share from an Ubuntu Client
I am using Ubuntu 10.4 as my primary workstation, so I would like to access my home folder on my server. To do this, I have to install the nfs-common package, so I will select my System menu, goto Administration and click on Synaptic Package Manager. Here I will find the nfs-common package and install it as shown here:
All that’s left is to mount the share. I will just enter the share to my fstab file and it will then be ready to mount (and automatically mounted on the startup). Again – use your favorite editor to add a line to the /etc/fstab:
192.168.1.1:/home/js /media/serverhome nfs rw 0 0
This will let the system mount the /home/js share located on the server with the IP 192.168.1.1, into the local folder /media/serverhome with read-write (rw) access.
When this is done, we must create the folder /media/serverhome on the locale machine and then, either reboot the system or manually mount the share like this:
# mount /media/serverhome
And we are done.