Want to mount NFS share on CentOS 6?
I hope you read and carefully followed my post on “How to configure NFS server in CentOS 6“. NFS is a server/client oriented protocol, which means that in order to share files and folders with your NFS clients you first need to configure NFS server! By successfully setting up and configuring your NFS server and exporting all of the NFS shares to your clients you are now ready to mount NFS shares on the client side.
Let’s start our How to mount NFS share on CentOS 6 guide!
1. Install required packages
First we need to install nfs-utils and it’s dependencies (nfs-utils and rpcbind must be installed, but DO NOT need to be started!).
[root@foo1 ~]# yum install nfs-utils -y
2. Create new directory
Next we must create or choose an existing NFS mount point (i am creating a new folder called /nfsmount).
[root@foo2 ~]# mkdir /nfsmount
3. Check for exports
Check for the NFS exports from your NFS server (192.168.1.100 is the IP address of my NFS server) and choose the one you want (and have permissions) to mount.
[root@foo2 ~]# showmount -e 192.168.1.100 Export list for 192.168.1.100: /share 192.168.1.101
4. Mount NFS share
syntax: mount NFSSERVERIP:/nfs/server/folder /nfs/client/folder
[root@foo2 ~]# mount 192.168.1.100:/share /nfsmount/ [root@foo2 ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/vg_foo-LogVol01 13G 819M 12G 7% / tmpfs 376M 0 376M 0% /dev/shm /dev/sda1 485M 49M 411M 11% /boot 192.168.1.100:/share 13G 777M 12G 7% /nfsmount
We see the NFS mount was successfull and NFS share is mounted. You can now add or remove data from the new mount point.
5. Add /etc/fstab entry
If you want your NFS mount point to auto mount on boot you need to add an entry to /etc/fstab.
syntax: NFSSERVERIP:/nfs/server/folder /nfs/client/folder nfs defaults 0 0
[root@foo2 ~]# echo "192.168.1.100:/share /nfsmount nfs defaults 0 0" >> /etc/fstab
Of course you can tweak NFS mount options as desired. Read more about this HERE.