What is NFS and why do you need it?
Network File System (NFS) is a network file system protocol originally developed by Sun Microsystems in 1984, allowing a user on a client computer to access files over a network in a manner similar to how local storage is accessed.
For example if you have 2 servers, you can setup 1 server for work and another one setup as a backup server, or just use its disk space, there are a lot of combinations.
First you need to check if NFS is already installed:
chkconfig --list nfs
If installed, you’ll see:
nfs 0:off 1:off 2:off 3:off 4:off 5:off 6:off
Adding NFS to boot and starting:
modprobe nfs
chkconfig nfs on
chkconfig portmap on
service portmap restart
service nfs start
If NFS wasn’t installed, just:
yum -y install nfs-utils
To allow connection from some server to your server with NFS you need to edit /etc/exports (example):
/home 209.85.149.103(rw,no_root_squash)
Here we allow server with IP 209.85.149.103 mount our home directory with rw (read write) rights.
Attention!!!
Be careful with spaces in file /etc/exports, for example, if you write:
/home 209.85.149.103 (rw)
then 209.85.149.103 will get access to /home directory with ro (read only) rights.
To activate all changes in /etc/exports:
exportfs -r
To check the list of all exported file systems:
exportfs
you should see something like:
/home 209.85.149.103
Now we need to mount file system on server 209.85.149.103, first let’s make a directory, where file system will be mounted:
mkdir /mnt/nfs
And finally mounting:
mount -t nfs 209.85.149.103:/home /mnt/nfs
structure (<hostname>:<resource> <mount dir>)
Thats all guys =)