1#updating the system and install nfs daemon
2sudo apt-get update
3sudo apt install nfs-kernel-server
4
5#view the relative info about NFS
6sudo cat /proc/fs/nfsd/versions
7cat /etc/default/nfs-kernel-server
8cat /etc/default/nfs-common
9
10#create and bind the NFS directory in host hard disk
11sudo mkdir -p /srv/nfs4/data1
12sudo mkdir -p /srv/nfs4/data2
13sudo mount --bind /data2/nfs /srv/nfs4/data1
14sudo mount --bind /data3/nfs /srv/nfs4/data2
15
16#let binds permanent effect
17sudo vi /etc/fstab
18/data1/nfs /srv/nfs4/data2 none bind 0 0
19/data2/nfs /srv/nfs4/data3 none bind 0 0
20
21sudo vi /etc/exports
22# add following content to the file
23/srv/nfs4 192.168.1.0/24(rw,sync,no_subtree_check,crossmnt,fsid=0)
24/srv/nfs4/data1 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)
25/srv/nfs4/data2 192.168.1.0/24(rw,sync,no_subtree_check,no_root_squash)
26
27#exports the nfs tables
28sudo exportfs -ra
29sudo exportfs -v