
Configuring an NFS client to use a shared filesystem
This recipe continues where the previous recipe left off, showing you how to configure NFS on a client system.
Getting ready
This recipe requires a CentOS system with a working network connection. It assumes that an NFS server has been configured as explained in the previous recipe. You'll also need administrative privileges provided by logging in with the root
account.
How to do it...
Follow these steps to configure an NFS client:
- Install the
nfs-utils
andlibnfsidmap
packages:yum install nfs-utils libnfsidmap
- Create the directory which will serve as the mount point for the remote filesystem:
mkdir /mnt/nfs
- Start the
rpcbind
service and register it so that it will start when the server boots:systemctl start rpcbind systemctl enable rpcbind
- Mount the NFS share to the mount point:
mount -t nfs 192.168.56.100:/var/nfsshare /mnt/nfs
How it works...
Like the server side, the client side of NFS relies on RPC. So, we started and enabled the rpcbind service. The mount
command is then used to mount the remote share:
mount -t nfs 192.168.56.100:/var/nfsshare /mnt/nfs
The -t
argument indicates the share's filesystem type, which, of course is, nfs
. The location of the remote share is also provided, the IP address of the server and the directory of the shared data separated by a colon. Finally, the mount target is given.
To manually unmount the share, the umount
command is used with the mount point:
umount /mnt/nfs
We can also configure the system to mount the NFS share automatically at boot time. Open /etc/fstab
using your editor and add the following line:
192.168.0.100:/var/nfsshare /mnt/nfs/var/nfsshare nfs defaults 0 0
The share will be automatically mounted when the system boots. Since mount
can look up information in /etc/fstab
, the invocation to mount the share manually becomes much simpler once it's registered in this manner. You can now mount the share manually by providing just the mount
:
mount /mnt/nfs
See also
Refer to the following resources for more information about configuring an NFS client:
- The
mount
manual page (man 8 mount
) - Setting up an NFS Client (http://www.tldp.org/HOWTO/NFS-HOWTO/client.html)
- RHEL 7 Storage Administration Guide: NFS Client Configuration (https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Storage_Administration_Guide/nfs-clientconfig.html)
- How to setup NFS Server on CentOS 7 (http://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-setup-nfs-server-on-centos-7-rhel-7-fedora-22.html)