The first two steps we need to do before we export our fs is making sure that the rpcbind service and the nfs service are on and running. We’ll open a session in our exporting server and enter the following commands:
[root@devops ~]#chkconfig rpcbind on [root@devops ~]#chkconfig nfs on [root@devops ~]#service rpcbind start [root@devops ~]#service nfs start
Now, we’ll edit out /etc/exports file and enter the path of the fs we want to export, the option that we want for our fs and the destination server. Only the server that we’ll mention in the file will be able to mount our fs and see its content. So after opening our file with vi /etc /exports we’ll enter our information:
/source/filesystem/path server1(ro) server2(rw)
As you can see I entered the path of the filesystem that I want to export and then the lists of servers that will be allowed to mount the fs. In the parentheses I added the options of which I want the fs to be – read only or read and write it this case. server1 will only be able to view the content of the fs and server 2 will be able to use the fs as its own.
The last step we need to take is making sure that our operating system knows that we updated our /etc/exports file. With the exportfs -r command. Every time you make changes to this file you have to enter this command in order for them to apply. So after we saved our file with the new information we’ll enter the following command:
[root@devops ~]#exportfs -r
Now, all that’s left to do is try to mount our nfs fs in the destination server.
*notice that before you mount the fs you have to make sure that the rpcbind and nfs services are up and running on your destination server as well. You can use the chkconfig and service commands like we showed above.
The mount command in the destination server is almost the same as the regular command except we need to mention the source server of the fs. So after we checked our services in the destination server:
[root@server1 ~]#mount devops:/source/filesystem/path /destination/path
And there you have it, a shared fs using NFS.