NFS Server in Ubuntu 16.04.4 LTS

For this setup, we have two machines as follows:

Host : 192.168.1.150
Client : 192.168.1.200


Step 1 — Downloading and Installing the Components

On Host Machine
#sudo apt-get update
#sudo apt-get install nfs-kernel-server

On Client Machine
#sudo apt-get update
#sudo apt-get install nfs-common


Step 2 — Creating the Share Directories on the Host


Example 1: Exporting a General Purpose Mount

On Host Machine
#sudo mkdir /var/nfs/general -p
#ls -la /var/nfs/general

#sudo chown nobody:nogroup /var/nfs/general


Example 2: Exporting the Home Directory


Step 3 — Configuring the NFS Exports on the Host Server

On Host Machine
#sudo nano /etc/exports

directory_to_share    client(share_option1,...,share_optionN)

/var/nfs/general 192.168.1.200(rw,sync,no_subtree_check)
/home        192.168.1.200(rw,sync,no_root_squash,no_subtree_check)


#sudo systemctl restart nfs-kernel-server


Step 4 — Creating the Mount Points on the Client

#sudo mkdir -p /nfs/general
#sudo mkdir -p /nfs/home


Step 5 — Mounting the Directories on the Client

#sudo mount 192.168.1.150:/var/nfs/general /nfs/general
#sudo mount 192.168.1.150:/home /nfs/home


Step 6 — Mounting the Remote NFS Directories at Boot

#sudo nano /etc/fstab
192.168.1.150:/var/nfs/general    /nfs/general   nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0
192.168/.1.150:/home        /nfs/home      nfs auto,nofail,noatime,nolock,intr,tcp,actimeo=1800 0 0


Step 7 — Unmounting an NFS Remote Share

#cd ~
#sudo umount /nfs/home
#sudo umount /nfs/general



Troubleshoot:
root@mail:/nfs/general# sudo umount /nfs/general
umount.nfs4: /nfs/general: device is busy
root@mail:/nfs/general#

root@mail:/nfs/general# lsof /nfs/general
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
bash     1201 root  cwd    DIR   0,43     4096 1049624 /nfs/general (192.168.1.150:/var/nfs/general)
lsof    27214 root  cwd    DIR   0,43     4096 1049624 /nfs/general (192.168.1.150:/var/nfs/general)
lsof    27215 root  cwd    DIR   0,43     4096 1049624 /nfs/general (192.168.1.150:/var/nfs/general)
root@mail:/nfs/general# kill -9 1201 27214 27215




Ref: 
https://www.digitalocean.com/community/tutorials/how-to-set-up-an-nfs-mount-on-ubuntu-16-04

Comments

Popular posts from this blog

Cambium cnPilot E400/E410/E500 Configuration Tutorial

Disabling Zimbra's AntiSpam, Amavis and AntiVirus filtering

Error "Unable to retrive Zimbra GPG key for package validation"