NFS services is used to share folders between Linux hosts.
1. Install NFS server:
sudo apt-get install nfs-kernel-server
2. Edit /etc/exports to set up what directories you want shared on your network, mine looks like this:
sudo vim /etc/exports
Note: Change the 192.168.1.0/24 part to match your network if needed.
3. Start the server.
sudo service nfs-kernel-server start
First is to figure out where exactly you would want the directories to appear. I decided to put them inside of /mnt/servername (don’t put them directly in /mnt. It will mess up any mounts that are already there).
1. Install the nfs client and automount utilities:
apt-get install nfs-common autofs
2. Edit /etc/auto.master to define the file for the NFS shares.
sudo vim /etc/auto.master
I commented “+dir:/etc/auto.master.d” and “+auto.master” with “#”‘s for this setup as they just produced non-fatal errors anyway.
3. Add the line at the bottom similar to this:
/mnt/servername /etc/auto.nfs --ghost
/mnt/servername is the “key”, where the directories will appear when mounted. The ghost option creates the directories and makes them visible for easier use. /etc/auto.nfs is the location of the file we will create next. The name can be whatever you want.
4. Edit /etc/auto.nfs
sudo vim /etc/auto.nfs
Make it look something like this, modifying for your environment of course:
This will create 2 directories, /mnt/servername/www and /mnt/servername/data, and map them to the exports defined in the server earlier. I used my server IP address to avoid any DNS issues that might be lurking, but in reality you might want to use the server name instead.
5. Restart the autofs service.
sudo service autofs restart
Original article: https://www.mikeslab.net/?p=23