Introduction
What is NFS?
NFS stands for Network File System.
NFS allows you to share directories from one computer with another. For example:
Here we have a server with a user called user1 and a laptop with a user called user2.
What we want to do is to see all of user1’s files on the laptop.
With /home/user1’s directory NFS mounted onto the directory /home/user2/zoostorm lets user2 see all user1’s files in the zoostorm directory.
You can modify, delete and add files there.
This is so you don’t not have to use Sneakernet which is sharing files between computers by putting your sneakers on and carrying the files between computers on a floppy disk, CD, DVD or memory stick.
Microsoft stole this idea from UNIX and calls it Simple File Sharing.
This can be very useful for backing up files or partitions from the laptop to the server PC, as servers traditionally have lots more drive space than say, a laptop or netbook.
The Nitty Gritty
On the host server
192.168.1.3 – This is an example i/p address
sudo apt-get update
sudo apt-get install nfs-kernel-server
sudo apt-get update
sudo apt-get install nfs-common
On the client computer
192.168.1.12 – This is an example i/p address
sudo apt-get update
sudo apt-get install nfs-common
Configure the NFS Exports on the Host Server
Open the /etc/exports file in your text editor with root privileges:
sudo vi /etc/exports
We want to create a line for each of the directories that we wish to share.
/home/username *(rw,sync,no_root_squash,no_subtree_check)
You can replace * with one of the hostname formats. Make the hostname declaration as specific as possible so unwanted systems cannot access the NFS mount, i.e. 192.168.1.12
sudo exportfs -a
Create the Mount Points and Mount Remote Shares on the Client Server
In your home directory create a directory for the mount in my case this is called zoostorm
mkdir /home/chris/zoostorm
sudo mount 192.168.1.3:/home/chris /home/chris/zoostorm
At this point, you probably will find out that the mount will time out, what the Ubuntu documentation fails to tell you is that the Ubuntu built in firewall
will block the mounts.
Allowing the NFS ports through the firewall
On both the client and server do the following:
sudo apt-get install ufw
sudo ufw enable
The ports you need to allow through the firewall are 111 and 2049
Just to be on the safe side to find out which port NFS is using:
cat /etc/services | grep -i nfs
you should get:
nfs 2049/tcp # Network File System
nfs 2049/udp # Network File System
so NFS is using port 2049.
We now do the following:
sudo ufw allow 111
sudo ufw allow 2049
Now on the client,
sudo mount 192.168.1.3:/home/chris /home/chris/zoostorm
We have opened the required ports, so this should now work.
You must be logged in to post a comment.