NFS file systems are used to share the files/folders between Linux to Linux systems. Port 111 (TCP and UDP) and 2049 (TCP and UDP) for the NFS server.
Installing and configuring NFS on Linux server and client.
To set up an NFS share mount we will require a minimum two systems one as a server and another as a client. The following are the packages required.
#yum install nfs-utils nfs-utils-lib
#yum install portmap (not required with NFSv4)
After Installing the packaged successfully, run the following command to start the NFS services.
#chkconfig --level 35 nfs on
#chkconfig --level 35 portmap on
The following are the important files for NFS configuration.
- /etc/exports : Its the main configuration file of NFS, all exported files and directories are defined in this file at the NFS Server end.
- /etc/fstab : To mount an NFS directory on your system across the reboots, we need to make an entry in /etc/fstab.
- /etc/sysconfig/nfs : Configuration file of NFS to control on which port rpc and other services are listening.
Creating a directory that need to be shared over the network
Add a entry to the /ect/fstab for the directory to be shared over the network.
# vi /etc/exports
Restart the NFS service to make the folder available over the network.
Mounting the NFS share at the client system
In order to view the available share folder from the NFS server run the below command
#showmount -e 192.168.1.1
Export list for 192.168.1.1:
Run the follwing command to mount the NFS share
#mount -t nfs 192.168.1.1:/nfsshare /nfsshare
Run the df -h command to view the NFS folder mount in the client system.
#df -h | grep nfsshare
192.168.1.1:/nfsshare on /mnt type nfs (rw,addr=192.168.1.1)
In order to mount the NFS share during the system startup add the following entry in /etc/fstab of the client system.
192.168.1.1:/nfsshare /mnt nfs defaults 0 0
Try creating file/folder in the NFS shared volume.