1. Install the NFS server and client:
Sudo apt-Get install nfs-kernel-server nfs-common Portmap
(2) sudo dpkg-reconfigure Portmap
Select "no" after running"
3. Configure the Mount directory and permissions
Vim/etc/exports
Below isCodeFragment:
#/Etc/exports: the access control list for filesystems which may be exported
# To NFS clients. See exports (5 ).
#
# Example for nfsv2 and nfsv3:
#/Srv/homes hostname1 (RW, sync) hostname2 (RO, sync)
#
# Example for nfsv4:
#/Srv/nfs4 GSS/krb5i (RW, sync, fsid = 0, crossmnt)
#/Srv/nfs4/homes GSS/krb5i (RW, sync)
#
/Home/ganhm/yangmiaojuan * (RW, sync)
Note:/home/ganhm/yangmiaojuan is the shared directory on my machine.
* Allows all IP addresses to access my shared directory. Of course, you can set a specific IP address in actual applications.
4. Restart the NFS service.
Sudo/etc/init. d/Portmap start
Sudo/etc/init. d/nfs-kernel-server restart NFS
5. Verification
192.168.138.162 is the IP address on my VM. Run the ifconfig command to check your IP address.
Sudo Mount 192.168.138.162:/home/ganhm/yangmiaojuan/mnt verify that your shared directory is mounted to/mnt
Sudo Mount-t nfs 192.168.138.165:/home/ganhm/AAA/mnt verify that the shared directory of others is mounted to your/mnt
Note: 192.168.138.165:/home/ganhm/AAA is someone else's IP address and shared directory
-T indicates the file system type in the command. NFS is used here.
An important question:
When setting the network connection, check whether it is bridging. If it is Nat, there is a high probability that the IP network segment is different (that is, the third segment of the IP address is different). In this way, other people's shared directories may not be accessible. I do not know the specific reason.