shared location using NFS in Linux


do u have 2 linux boxes, but want to have 1 shared location to which 2 boxes can access...

Let us say we have machine 1 & machine 2

1)      Go to machine 1
2)      vi /etc/exports
3)       add this line /vol1/shared  *(rw)  # the shared dir contents will be shared now
4)      /etc/init.d/nfs restart (if you edit the file /etc/exports you need to restart nfs service)

Go to machine 2
1)      Mkdir /vol1/shared
2)      Use mount command
$mount machine1:/vol1/shared  /vol1/shared-t nfs -o proto=tcp,vers=3 # in machine1 we exported shared dir
3)      You are done here . if you want to make mount permanent then you should edit /etc/fstab .

Note: make sure the user has same uid and gid in these two machines if you want to have write permissions from 2 boxes to this shared directory .  we should use usermod/groupmod commands to change uid/gid of user in machine 2.

Give $ id user #command in 2 boxes and make sure uid/gid are same , if not use the following commands
Examples
1)Usermod –u user
                2) Groupmod –g user
                3) Usermod –g user (this changes perfuser to belong to group specified by new_gid tat we created in 2nd command