Comments on Setting Up an NFS Server and Client on CentOS 7.2
This guide explains how to set up an NFS server and an NFS client on CentOS 7. NFS stands for Network File System; through NFS, a client can access (read, write) a remote share on an NFS server as if it was on the local hard disk.
12 Comment(s)
Comments
I would suggest that you add this parameter to your options section in fstab, '_netdev'. Otherwise at boot, particularly on systems utilizing systemd, you will run into a situation that the system is trying mount the filesystem prior to a network device being up.
192.168.1.100:/home /mnt/nfs/home nfs rw,sync,hard,intr,_netdev 0 0 192.168.1.100:/var/nfs /mnt/nfs/var/nfs nfs rw,sync,hard,intr,_netdev 0 0
when i check systemd for nfs, i saw nfs.service and nfs-server.service. What is the difference between these two services? The nfs.service keeps staying disabled and cannot be enabled. Will this affect the nfs working properly?
Just start the nfs-server services as shown in the tutorial. The other services does not need to be started.
Use mount -t nfs -o nfsvers=3 192.168.1.100:/var/nfs /mnt/nfs/var/nfs or nfsvers=4 depending on your server and client versions if you get an error such as:
mount.nfs: an incorrect mount option was specified
You can also grep -i serverip /etc/mtab >> /etc/fstab so you dont have to keep creating fstab entries once you mount it. It will grab the defaults used when mounting determined by exportfs from the server
I needed to add
firewall-cmd --permanent --zone=public --add-service=mountd
firewall-cmd --permanent --zone=public --add-service=rpc-bind
to the firewall config section
Great! That was easy with those instructios. Thank You!!
Simple and Clear + comments by others for further troubleshooting.
Thanks!!
I have to specify the subnetmask in /etc/exports, otherwise It produces "portmap query failed: RPC: Remote system error - No route to host"
/data 192.168.1.1/255.255.255.0(rw,sync,no_root_squash)
Very helpful article, but running into problems for certain case. Could you advise?
Have two dirs that I would like to mount (at different times):
/dl
/dl/data
with /etc/exports looking like...
/dl clientdns(rw,fsid=0,root_squash,sync) /dl/data clientdns(ro,root_squash,sync)I find that I can mount /dl fine onto clientdns server, though showmount does seem to error with
"clnt_create: RPC: Port mapper failure - Unable to receive: errno 113 (No route to host)"
But when unmounting and trying to mount /dl/data I get
mount.nfs: trying text-based options 'vers=4.1,addr=172.18.5.73,clientaddr=172.18.5.72' mount.nfs: mount(2): Permission deniedBest article to configure NFS, was smooth and easy did it within 10 min, Thanks.
If the NFS client has firewall too, does it require to open any port? The #2 seems to be intended for NFS server.