In Part 1 I showed how to set up your home network with static IP addresses. In Part 2 I'm going to show how to share folders across the network. There's a lot of information on the net for setting up Samba (which works with Windows SMB) to share files. That's fine if you need to share files and folders with Windows computers, but in a pure Linux environment NFS (Network File System) works just as well or better. Some reports on the web claim it to be 3-4 times faster than Samba for file transfers. In today's post, I'll show how to install and configure NFS in order to share folders across your home Linux network.
I'll show how to configure the server first. We'll need to make sure all of the required packages are installed. From the terminal:
Next, make sure that portmap is not bound to loopback.
Now we'll configure a folder to share. There are two ways (that I know of) to do this; through the file manager, or by editing /etc/exports. I'll show the first way. Open Nautilus, (the Ubuntu file manager), and right click on the folder you want to share, (for this example, /home/username/Music), and select Share from the menu. Enter your password if prompted, and then the Share Folder dialog should come up. Modify the Share through: drop-down from Do not share to Unix networks (NFS).
Now we just need to add access to the other computers on our network. From the block diagram in Part 1, our network addresses are of the form 192.168.2.10, 192.168.2.11, etc.
Under the Allowed Hosts section, click on Add. In the new dialog, leave the Allowed Hosts: drop-down on Specify hostname. Now, in the Host name: field enter
and click OK. This will allow clients in the address range of 192.168.2.1 - 192.168.2.255 to connect to the shared folder. Now click OK in the Shared Folder dialog. In order for the NFS kernel server to read these new share settings we'll need to restart it.
and then export the share.
Note: If you are running a software firewall, you'll need to make sure you open ports 111 and 2049 for the NFS service.
Now we need to set up the other computers on our network to connect to the shared folder as clients. Log in to one of the other computers and install the nfs-common and portmap packages.
Again, make sure that portmap is not bound to loopback.
Now create a directory for your local mount point of the shared folder.
Just to be sure, restart portmap and nfs-common.
sudo /etc/init.d/nfs-common restart
Finally, mount the remote shared folder to the new directory you just created.
You should now be able to browse the media folder and see the contents of your remote Music folder. Repeat the process for the remaining computers on your network.
In Part 3 I will cover how to automatically mount the shared folders when you boot the computer.