If your home or office is powered by Linux computers, you may want to have a system for sharing files. Our small office has been using file sharing software called NFS (Network File System) for quite some time now, and we are pretty happy with it. Here is a brief how-to guide for setting up NFS file sharing for Linux computers.
NFS was developed by Sun Microsystems for the Solaris product range that was built on Unix. NFS has been around for a long time, and it is considered a solid file sharing software for Linux and Unix operating systems. As time has passed, however, NFS Windows software hasn’t kept up with. NFS is designed to provide disk sharing on a LAN (Local Area Network). It is not a cloud service that can be accessed from anywhere with any device.
If you are familiar with the native file sharing functionality in Windows or in Mac, NFS is similar with them. Other disk sharing choices for Linux are Samba and sshfs (command line file access that uses ssh).
NFS is a client-server system. You designate one or more computers as the server, and the others are clients. The server shares a specified disk to clients that can read from and write to (depending on the configuration) the shared disk. The server and clients must be connected to the same LAN.
In our small office, Linux computers run Debian or a distribution built on Debian, like Ubuntu, and that is the environment where the following instructions have been tested.
Install the NFS server software
The computer that shares its disk requires the server module of NFS. In systems that have apt packaging, the command to install is:
apt-get install nfs-kernel-server
After the software has been installed, you have to tell NFS which disk you want to share. The configuration file’s name is: /etc/exports
The file features examples how to specify the disk to be shared. You can use the hostname of the server computer or its IP address in the LAN to specify the shared disk. For instance (edit names to match your system):
Run the command below to tell the NFS server about the new disk share:
You can verify that NFS server understood what you wanted to say:
Install the NFS client
Computers that access the shared disk need a client software that is installed like this:
apt-get install nfs-common
Once the client has been installed, you can mount the shared disk specified on the server as a local disk for the client (here, /media/username/nfsshare is the local name the client accesses). You may have to create the mountpoint directory first (in this case: mkdir /media/username/nfsshare), and then run:
mount -v -t nfs blackberry:/media/username/SSD1TB/docs /media/username/nfsshare/
If it doesn’t work but throws error messages like:
mount.nfs: mount(2): Permission denied
mount.nfs: access denied by server while mounting
Try and specify the NFS version for the mount command:
mount -v -t nfs -o nfsvers=3 blackberry:/media/username/SSD1TB/backup /media/username/nfsshare/
If your NFS client was able access a shared NFS disk but the connection hangs up (in the worst case, your computer freezes), it may mean that the connection has broken down or the server has been shut down. Try to force disconnect from the NFS server:
umount -f /media/username/nfsshare
umount -l /media/username/nfsshare
You can display the mounted disks on the client:
On the server, check the status of the NFS server:
systemctl status nfs-server
And restart NFS server if needed:
systemctl restart nfs-server
Also on the server, verify what is shared:
showmount -e hostname (or ip address instead of the hostname)
This article has more tips for troubleshooting.
NFS on Windows
NFS client applications such as FreeNFS and NFSClient are available for Windows PCs, but getting them to run on recent versions of Windows seems to be tricky. We only tried them briefly and didn’t succeed, but if someone has managed to get them to work, please share your tips.