Network File Sharing (NFS) is a protocol that allows you to share directories and files with other Linux clients over a network. Shared directories are typically created on a file server, running the NFS server component. Users add files to them, which are then shared with other users who have access to the folder. An NFS file share is mounted on a client machine, making it available just like folders the user created locally. NFS is particularly useful when disk space is limited and you need to exchange public data between client computers.
Below are the high-level steps we will follow to set up our NFS.
1. Install and activate nfs server on NFS Server
2. Create the NFS Share Folder and export it
3. Install nfs client and mount the NFS Share Folder on Client
Below are setup details and the same will be used in this demonstration.
Sr. No. | Hostname | IP | Role |
1 | test-machine01 | 192.168.114.177 | NFS Server |
2 | test-machine02 | 192.168.114.176 | NFS Client |
Step 1. Install and activate NFS Server: Install NFS Server using OS yum command. Once installation is done enable nfs service and add port in firewall using below commands.
Step 2. Create the NFS Share Folder and export it on NFS Serve: We will be using /u01/psql_backup directory as our NFS share. Edit nfs configuration file: /etc/exports and add the below line.
*: This mount has access to any system in the Network
rw: Read Write
sync: Any update in file from the Client-side and it will update in Server also.
Step 3. Install NFS client and mount the NFS Share Folder on NFS Client: Use OS yum command to install nfs package. Once the package is installed, you can use the command showmount to search for available NFS Server. Add NFS Share details in /etc/fstab so each time Server mount NFS drive automatically during server reboot.