Skip to content

Instantly share code, notes, and snippets.

@antoniojxk
Last active April 8, 2017 14:12
Show Gist options
  • Save antoniojxk/2bf091a3ce7bc0fb082360e957b81723 to your computer and use it in GitHub Desktop.
Save antoniojxk/2bf091a3ce7bc0fb082360e957b81723 to your computer and use it in GitHub Desktop.
Installation notes NFS CentOS 6.8

Intall NFS Server and Client on CentOS 6.8

links

steps

server

  • check if nfs-utils and nfs-utils-lib are installed
[root@apaternina apaternina]# rpm -qa "*nfs*"
nfs4-acl-tools-0.3.3-8.el6.x86_64
nfs-utils-lib-1.1.5-11.el6.x86_64
nfs-utils-1.2.3-70.el6_8.2.x
  • if not, then install them
[root@apaternina apaternina]# yum install nfs-utils nfs-utils-lib
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.uniminuto.edu
 * extras: centos.uniminuto.edu
 * updates: centos.uniminuto.edu
Package 1:nfs-utils-1.2.3-70.el6_8.2.x86_64 already installed and latest version
Package nfs-utils-lib-1.1.5-11.el6.x86_64 already installed and latest version
Nothing to do
  • configure startup links
[root@apaternina apaternina]# chkconfig --levels 235 nfs on
  • start service
[root@apaternina apaternina]# service nfs start
  • edit exports file to declare the directories that will be exported
[root@apaternina apaternina]# vi /etc/exports
/home           192.168.15.6(rw,sync,no_root_squash,no_subtree_check)
/var/nfs        192.168.15.6(rw,sync,no_subtree_check)
  • export directories
[root@apaternina apaternina]# exportfs -a
  • make NFS ports fixed
[root@dlp ~]# vi /etc/sysconfig/nfs

# line 20,22: uncomment
LOCKD_TCPPORT=32803
LOCKD_UDPPORT=32769
# line 57: uncomment
MOUNTD_PORT=892
# line 63: uncomment
STATD_PORT=662
  • allow 111, 2049 and fixed ports above
[root@apaternina apaternina]# for port in 111 662 892 2049 32803; do iptables -I INPUT 5 -p tcp -m state --state NEW -m tcp --dport $port -j ACCEPT; done 
[root@apaternina apaternina]# for port in 111 662 892 2049 32769; do iptables -I INPUT 6 -p udp -m state --state NEW -m udp --dport $port -j ACCEPT; done
  • make changes to iptables persistent
[root@apaternina apaternina]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[  OK  ]
  • restart rpc and nfs
[root@dlp ~]# /etc/rc.d/init.d/rpcbind restart 
[root@dlp ~]# /etc/rc.d/init.d/nfs restart

client

  • mount directories in client
mount 192.168.56.100:/home /mnt/nfs/home
mount 192.168.56.100:/var/nfs /mnt/nfs/var/nfs
  • verify that the directories were mounted successfully
[root@apaternina apaternina]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_apaternina-lv_root
                       45G  4.0G   39G  10% /
tmpfs                 940M   80K  940M   1% /dev/shm
/dev/sda1             477M   40M  412M   9% /boot
192.168.56.100:/home   45G  4.5G   39G  11% /mnt/nfs/home
192.168.56.100:/var/nfs
                       45G  4.5G   39G  11% /mnt/nfs/var/nfs
[root@apaternina apaternina]# mount
/dev/mapper/vg_apaternina-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
192.168.56.100:/home on /mnt/nfs/home type nfs (rw,vers=4,addr=192.168.56.100,clientaddr=192.168.56.101)
192.168.56.100:/var/nfs on /mnt/nfs/var/nfs type nfs (rw,vers=4,addr=192.168.56.100,clientaddr=192.168.56.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment