NFS Directory Mount/Share 
Tested on centos 6.4; the process is slightly different in Fedora 20 because it uses a different approach (starting with fedora 15) to start services:

systemctl start service_name.service

[root@nfsserver ~]# yum install nfs-utils nfs-utils-lib
[root@nfsserver ~]# yum install portmap (not required with NFSv4)

//server ip:192.168.0.100
//client ip:192.168.0.101

//start service on both machines
[root@nfsserver ~]# /etc/init.d/portmap start
[root@nfsserver ~]# /etc/init.d/nfs start
[root@nfsserver ~]# chkconfig --level 35 portmap on
[root@nfsserver ~]# chkconfig --level 35 nfs on


//setting up server
[root@nfsserver ~]# mkdir /nfsshare

[root@nfsserver ~]# vi /etc/exports

/nfsshare 192.168.0.101(rw,async,no_root_squash)


//setting up the client
[root@nfsclient ~]# showmount -e 192.168.0.100

Export list for 192.168.0.100:
/nfsshare 192.168.0.101

//temporary mount:
[root@nfsclient ~]# mount -t nfs 192.168.0.100:/nfsshare /mnt/nfsshare

//permanent mount (fstab) across reboots
[root@nfsclient ~]# vi /etc/fstab

192.168.0.100:/nfsshare /mnt nfs defaults 0 0

//misc
[root@nfsclient ~]# mount | grep nfs

sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
nfsd on /proc/fs/nfsd type nfsd (rw)
192.168.0.100:/nfsshare on /mnt type nfs (rw,addr=192.168.0.100)

//on server open ports 2049 and 111,32803,32769

/*

may have to do:
vi /etc/sysconfig/nfs

uncomment:
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
MOUNTD_PORT=892

iptables -I INPUT -m state --state NEW -p tcp \
-m multiport --dport 111,892,2049,32803 -s 192.168.0.0/24 -j ACCEPT

iptables -I INPUT -m state --state NEW -p udp \
-m multiport --dport 111,892,2049,32769 -s 192.168.0.0/24 -j ACCEPT


*/

//mount in mac (ip is server's) (...and create a new user in mac to match nfs server uid)
sudo mount -t nfs -o resvport,nolocks,locallocks,intr,soft,wsize=32768,rsize=3276,async 172.16.1.46:/usr/share/nginx .


NFS Options

Some other options we can use in “/etc/exports” file for file sharing is as follows.

ro: With the help of this option we can provide read only access to the shared files i.e client will only be able to read.
rw: This option allows the client server to both read and write access within the shared directory.
sync: Sync confirms requests to the shared directory only once the changes have been committed.
no_subtree_check: This option prevents the subtree checking. When a shared directory is the subdirectory of a larger file system, nfs performs scans of every directory above it, in order to verify its permissions and details. Disabling the subtree check may increase the reliability of NFS, but reduce security.
no_root_squash: This phrase allows root to connect to the designated directory.

as of 01/2014:
http://www.tecmint.com/how-to-setup-nfs ... -in-linux/


[ view entry ] ( 1634 views )   |  print article

<<First <Back | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Next> Last>>



2025 By Angel Cool