If you've ever tried to share folders on a Linux machine over a network, you've most likely attempted to get NFS working. And on many occasions you might have found yourself nearly pulling out your hair in frustration. Well, you'll be glad to know that getting NFS working on modern Ubuntu systems is actually quite simple. You just have to have a couple of pieces installed and access to the /etc/exports file.
In this article I am going to demonstrate how simple it is to share a folder, using NFS, between a Ubuntu machine and a Debian machine. When all is said and done, you'll be surprised at how simple it is.
What is NFS?
NFS stands for (take a guess...) Network File System. NFS is a protocol developed by Sun Microsystems in 1984 to allow computers to share files and folders over a network. NFS is an open standard, defined in RFCs, and allows any to implement the protocol.
Although many prefer to employ Samba for network folder sharing, NFS still has a lot of good uses and some even prefer it over the more flexible Samba.
Both client and server will need the package nfs-common. On the server machine you will need to install the package nfs-kernel-server. To install these packages follow these steps:
That's it. Now it's time for a little configuration.
For example's sake, the two machines we are using are addressed as such:
On the client we will create a directory which the NFS server share will mounted to. We'll create the folder ~/UBUNTU_NFS with the command mkdir ~/UBUNTU_NFS. Now let's move over to the server.
The first thing to be done on the server machine is to create folder that will be shared out. Let's call that folder ~/SHARE and we'll create it with the command mkdir ~/SHARE.
Now we have to create an entry in the /etc/exports folder. This entry will tell NFS what to share and who to share with. The entry will look like:
Where USERNAME is the actual name of the user. NOTE: You could share a folder in /opt if you like.
Now nfs-kernel-server has to be restarted with the command:
Hop back on to the client machine and issue the command:
sudo mount 192.168.1.100:/home/USER/SHARE /home/USER/UBUNTU_NFS
Where USER is the actual user name.
You should get no errors. Now let's test this out. Hop on back to the server and create a file within ~/SHARE. After you create that file, check the ~/UBUNTU_NFS directory on the client to make sure the file shows up. Try to delete that file. Now create a file in the ~/UBUNTU_NFS directory on the client. You should have no problems creating a file.
Say you want this share to always be mounted upon boot of the client machine. This, of course would require the server machine to be on. To do this add an entry on the client machine's /etc/fstab that looks like:
192.168.1.100:/home/jlwallen/ELIVE /home/jlwallen/UBUNTU nfs rsize=1024,wsize=1024,noauto 0 0
NOTE: The above fstab entry is all one line.
Now that NFS share will mount even when the machine is rebooted.
As you can see, NFS has become much easier than it was in the old days. Now, armed with NFS and Samba, you can be sharing files and folders with anyone and everyone.Advertisement
Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.
We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.
If you like our content, and would like to help, please consider making a contribution:
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.