Saturday, 28 January 2012

Install and configure NFS


check if NFS is functioning, use the rpcinfo command.
1. rpcinfo -p

2. yum install nfs-utils nfs-utils-lib nfs4-acl-tools portmap



3. /etc/init.d/rpcbind start
4. /etc/init.d/nfs start


5. open /etc/exports


Here are the most common export techniques and options:
/home/nfs/ 10.1.1.100(rw,sync) #export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, and synchronized mode
/home/nfs/ 10.1.1.0/24(ro,sync) #export /home/nfs directory for network 10.1.1.0 netmask 255.255.255.0 with read only permissions and synchronized mode
/home/nfs/ 10.1.1.100(rw,sync) 10.1.1.10(ro,sync)    #export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode, and also export /home/nfs directory for hosts with IP 10.1.1.10 with read only permissions and synchronized mode
/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) #export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will be treated as a root and will be able to change any file and directory.
/home/nfs/ *(ro,sync) #export /home/nfs directory for any host with a read only permission and synchronized mode
/home/nfs/ *.linuxconfig.org(ro,sync) #export /home/nfs directory for any host within linuxconfig.org domain with a read only permission and synchronized mode
/home/nfs/ foobar(rw,sync) #export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode

6. /etc/init.d/nfs restart
7. Run command exportfs:
# exportfs -rav

8. Mount remote file system on client
To check the set of clients who are  mounting  from  remote  host
# showmount -e IP-ADDRESS

Create a mount point:
# mkdir /home/nfs_local


9. If you are sure that the NFS client and mount point are ready, you can run the mount command to mount exported NFS remote file system:
# mount 10.1.1.200:/home/nfs /home/nfs_local

In case that you need to specify a type of the filesystem you can do this by:
# mount -t nfs 10.1.1.200:/home/nfs /home/nfs_local
You may get error message
mount: mount to NFS server failed: timed out (retrying).
This may mean that your server supports higher versions of nfs and therefore you need to pass one extra argument to your nfs client. In this example we use nfs version 3:
# mount -t nfs -o nfsvers=3 10.1.1.200:/home/nfs /home/nfs_local

To avoid hanging while ftp transfer
# mount -t nfs -o nolock 10.1.1.200:/home/nfs /home/nfs_local

10. Configure automount
If you want to automount the NFS file system every time a user boots a PC, just edit /etc/fstab

 echo "10.1.1.200:/home/nfs /home/nfs_local/ nfs rw,nolock 0 0" >> /etc/fstab

NFS daemon should be listening on both standard ports 2049 and portmap on port 111.



No comments:

Post a Comment