Monday, August 27, 2012

Mount a linux server dir to another linux server directory


Say we have 2 servers named as
server1                 (192.168.1.45)
server2                 (192.168.1170)

we want to mount a directory of 192.168.1.45 on the .170 server

Step1.
install nfs server on server1 (.45)
#yum install nfs-utils nfs4-acl-tools portmap
#chkconfig nfs on

Step2.
Share the directory on server1(.45)
#vim /etc/exports
/image1 192.168.1.170(rw)
save the file {it will give server2 (.170) read write access}
# exportfs -avr

Step3.
Mounting the /image1 directory on the server2
you need to create a directory on server2 where you want to mount the directory from server1
#mkdir /image1

#vim /etc/fstab
192.168.1.45:/image1     /image1 nfs hard,intr 0 0
save and close the  file

#mount -t nfs -a

the above command will mount the server1 shared directory to the server2 directory(/image1).

No comments:

Post a Comment