Set up NFS Server on CentOS 6

Part 8 of setting up a Linux home lab environment with VirtualBox. Check this blog post for more info.

NFS server is used to make its data generally available to clients.


Software used in this article:

  1. CentOS 6.7
  2. nfs-utils 1.2.3


# yum install nfs-utils nfs-utils-lib
# chkconfig nfs on 
# /etc/init.d/rpcbind start
# /etc/init.d/nfs start


Our NFS server has a FQDN of spacewalk.hl.local and resides on LAN.

Create a Logical Volume for NFS Shares

Check volume groups:

# vgs
  VG         #PV #LV #SN Attr   VSize   VFree
  vg_centos6   1   5   0 wz--n- 124.21g 77.34g

Create a 5GB logical volume named lv_nfs in theĀ vg_centos6 group, format as ext4 and mount on /mnt/nfs.

# lvcreate --name lv_nfs --size 5G vg_centos6
# mkfs.ext4 -m 0 /dev/mapper/vg_centos6-lv_nfs
# mkdir -p /mnt/nfs
# mount /dev/mapper/vg_centos6-lv_nfs /mnt/nfs
# mkdir -p /mnt/nfs/public
# chown nfsnobody:nfsnobody /mnt/nfs/public

Configure NFS exports:

# cat /etc/exports

Parameters that are used in our case:

  1. rw: allows both read and write requests on the NFS volume,
  2. sync: replies to requests only after the changes have been committed to stable storage,
  3. no_subtree_check: disables subtree checking,
  4. root_squash: maps requests from (root) uid/gid 0 to the nfsnobody uid/gid,
  5. all_squash: maps all uids and gids to the nfsnobody uid/gid.

Export the share:

# exportfs -rav


# showmount -e
Export list for spacewalk.hl.local:


Allow NFS and rpcbind (portmapper) access from LAN:

# iptables -A INPUT -s -p tcp -m multiport --dport 111,2049 -j ACCEPT
# iptables -A INPUT -s -p udp -m multiport --dport 111,2049 -j ACCEPT

NFS Client Configuration

Install NFS utilities and mount an NFS share.

# yum install nfs-utils nfs-utils-lib
# mkdir /mnt/public
# mount.nfs spacewalk.hl.local:/mnt/nfs/public /mnt/public

Leave a Reply

Your email address will not be published. Required fields are marked *