Centos 6.5 NFS Server Suitable for Cloudstack

Centos​In the past I have had the odd bit of difficulty with getting Cloudstack to work with a freshly built NFS server as either primary or secondary storage.  Nothing that could not be solved but I am not a Linux 'expert' so I thought I would create a very quick article so that others with similar experiences to mine may extract some benefit.


  • A VM with the following configuration
    • 1 vCPU
    • 2GB or more RAM
    • 50GB or more of disk space
  • A freshly built minimal Centos 6.5 build


  • Apply all system patches via a yum update
yum update -y
  • Install and start NTP (assumption connection and name resolution allow server to find named NTP servers on the Internet)
yum update ntp -y
service ntpd start
chkconfig ntpd on
  • Edit /etc/sysconfig/network and set the hostname

HOSTNAME = name.example.com

  • Edit /etc/hosts and add a line for the server hostname and fqdn
​  name  name.example.com
  • set hostname in current terminal session
hostname name.example.com
  • Restart network service
Service network restart

Install Software

  • Install NFS and the utilities
yum install -y nfs nfs-utils

​Configure NFS

  • Edit /etc/sysconfig/nfs.  I have highlighted the lines you need to un-comment
# Define which protocol versions mountd
# will advertise. The values are "no" or "yes"
# with yes being the default
# Path to remote quota server. See rquotad(8)
# Port rquotad should listen on.
# Optinal options passed to rquotad
# Optional arguments passed to in-kernel lockd
# TCP port rpc.lockd should listen on.
# UDP port rpc.lockd should listen on.
# Optional arguments passed to rpc.nfsd. See rpc.nfsd(8)
# Turn off v2 and v3 protocol support
# Turn off v4 protocol support
# Number of nfs server processes to be started.
# The default is 8.
# Stop the nfsd module from being pre-loaded
# Set V4 grace period in seconds
# Optional arguments passed to rpc.mountd. See rpc.mountd(8)
# Port rpc.mountd should listen on.
# Optional arguments passed to rpc.statd. See rpc.statd(8)
# Port rpc.statd should listen on.
# Outgoing port statd should used. The default is port
# is random
# Specify callout program
# Optional arguments passed to rpc.idmapd. See rpc.idmapd(8)
# Set to turn on Secure NFS mounts.
# Optional arguments passed to rpc.gssd. See rpc.gssd(8)
# Optional arguments passed to rpc.svcgssd. See rpc.svcgssd(8)
# To enable RDMA support on the server by setting this to
# the port the server should listen on


start the required services in the correct order

  • Configure firewall
# non-standard additions

-A INPUT -m state --state NEW -m tcp -p tcp --dport 2049 -j ACCEPT

#port mapper
-A INPUT -m state --state NEW -m tcp -p tcp --dport 111 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 111 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 32803 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 32769 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 892 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 892 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 875 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 875 -j ACCEPT

-A INPUT -m state --state NEW -m tcp -p tcp --dport 662 -j ACCEPT
-A INPUT -m state --state NEW -m udp -p udp --dport 662 -j ACCEPT
  • Create a directory structure
mkdir -p /data/primary_storage
  • Create an export entry in /etc/exports
/data/primary_storage  *(rw,async,no_root_squash,no_subtree_check)
  • Export the file system
export -a

Start And Configure Services

  • Start the services in this order
service rpcbind start
service nfslock start
service nfs start
  • Configure the services to start on server boot
chkconfig rpcbind on
chkconfig nfslock on
chkconfig nfs on

Confirm File System is Exported

showmount -e

Output should closely resemble this:

Export list for nfs.cloud.local:
/data/primary_storage *


​Remote Test

The file system is now exported.  Let's just confirm it is accessible.

From another Centos 6.5 minimal build perform the following steps:

  • Install nfs utilities
yum install -y nfs-utils
  • Create a mount point on the local file system
mkdir /mnt/remote_space
  • Mount the remote file system
mount /mnt/remote_space
  • Confirm success
/dev/mapper/vg_osclient01-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)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev) on /mnt/remote_space type nfs (rw,vers=4,addr=,clientaddr=
  • Confirm RW access
touch /mnt/remote_space/testing123
drwxr-xr-x. 2 root root 4096 Jun 11 17:31 .
drwxr-xr-x. 3 root root 4096 Jun 11 17:27 ..
-rw-r--r--. 1 root root    0 Jun 11 17:31 testing123


That's it.  The file server can now be added to Cloudstack via the UI for use as either primary or secondary storage

Add to Apache Cloudstack 4.3 Storage Resources

  • Login to Cloudstack via UI, in my case
  • Click on LHS menu item 'Infrastructure'
  • Click on 'Primary Storage'
  • Click Add 'Primary Storage'
  • Fill in UI form and Click OK

Cloudstack - Infrastructure DisplayCloudstack - Primary Storage ListCloudstack - Add Storage UI Modal FormCloudstack - Successfully Completed Addition of Storage

The new storage should appear in the primary storage listing in front of you.  Clicking on the name allows you to see more detail about the storage resource as well as its current state.