When it comes to file sharing on Linux, you have two main choices. NFS is the one that is intrinsic to Unix environments, that have been carried down into Linux by convention. It has been around for a long time and is quite stable and reliable. Since the development of Samba, you also have SMB as an option both for Windows and Linux clients. I have used Samba quite a lot because I still have one Windows client in my network, but I am interested in experimenting with NFS because I have seen some issues on my Linux desktops with Samba and I want to know if NFS is more reliable.
So I will try to sum up the process of installing NFS and making it work on a Debian 9 system. As with Samba, mainpc will be both a client and a server for NFS, sharing the maps share.
There is a guide on the Debian wiki which I accessed here:
I also referenced this guide on the HowToForge website:
Here is another site I also read:
So the first step is to install the NFS server (kernel mode version)
apt install nfs-kernel-server
Note that you may see errors about the nfs-server services. This seems to be a common issue with systemd. I checked with systemctl and found that nfs-server.service had the status code active (exited). This seems to be indicating there were no issues with this as a service. However, the (exited) bit means the service is not running at present because it is not fully configured, mainly there are no exports (another name for shares) set up. When you have fully configured it, then restarting the service is necessary to get the exports available for clients to connect to.
The next step is to install the rpcbind package (this replaces portmap which may be referred to in older documentation). In my case this was already installed as part of the install of the server package.
I didn’t initially config rpcbind to anything even though the instructions for portmap specify some configuration settings for it.
I also installed the client on another computer and created a mount point for mounting the maps share to. This re-used /mnt/share/mainpc/maps because this is the common network access path for software, even though this one has been used for Samba, I need to keep it as a common path for file access from Qgis. Therefore I edited the fstab to remove the Samba mount using this same location. To install the nfs client you just need this command:
apt install nfs-client
Next is to set up the exports on the server, by using nano to edit the exports file. To allow my local subnet to access the maps share on the NFS server I need this line in the file:
/home/xxx/yyy 192.168.1.0/24(rw,sync)
Note there is not a space between the IP address specification and the options in brackets.
After entering that I need to run a command called exportfs to refresh the exports.
exportfs -a
On the client the entry in /etc/fstab looks like
192.168.x.y:home/xxx/yyy /mnt/share/mainpc/maps nfs defaults 0 0
In this case I did a manual mount first, then on finding it has worked, I used mount-a to test further. This also worked.
The main restriction I have noted at the moment is in creating directories and files at the root of the share. There may well be some sort of configuration option I need to set up to allow this because there hasn’t been a problem up until now with this option. However, it’s not a deal breaker. At the moment there is no problem at all caused by this issue.
The main issue has been with virtualbox VM clients that are using different IP address ranges by default and have to be configured to use the same IP address range so the server will allow client connections from the virtual machines. I could either address this by allowing extra address ranges in the server, or, as I chose to do, configuring the virtual machines to use a bridged adapter instead of a NAT adapter, so that it gets an address from the DHCP server in my network and is in the right address range.
This was going to be a multipart series but it hasn’t turned that way, because NFS just works, and there have been no issues. Obviously there is no password by default, but that isn’t an issue on my network.