Table of contents+
Introduction
NFS storage for CloudStack
Apache CloudStack separates storage into primary and secondary storage. Primary storage holds the disks used by running instances, while secondary storage is used for resources such as templates, ISO images, and snapshots.
For a small lab, a single NFS server can provide both types of storage as separate shares. Larger production environments commonly separate these workloads onto dedicated storage systems.
Exports
/export/primary + /export/secondary
This guide prepares two NFS storage locations so CloudStack can use them independently.
Before you begin
- • Use a statically assigned IP address for the NFS server.
- • Make sure the Management Server and KVM hosts can reach the NFS server over the storage network.
- • Replace all example IP addresses, interface names, gateways, and subnets with values from your environment.
- • If your Management Server already provides NFS and already has a static IP, you can skip the Netplan step.
Install NFS
Install the NFS server packages
Start by updating the package index and installing the Ubuntu NFS server package.
sudo apt update
sudo apt install -y nfs-kernel-serverYou do not need to configure the CloudStack Management Server software on this machine when it is being used as a dedicated storage server.
Networking
Configure a static IP address
CloudStack should always reach the storage server at a stable address. Before editing Netplan, identify the correct network interface and default gateway.
ip link
ip routeCreate or edit your Netplan configuration. The following example assigns192.168.1.100/24to enp0s3.
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
addresses: [192.168.1.100/24]
nameservers:
addresses: [8.8.8.8, 8.8.4.4]
routes:
- to: default
via: 192.168.1.1Do not copy the example network values blindly
Confirm that the IP is unused and that the gateway, subnet, and interface name are correct before applying Netplan.
Test the configuration first. If connectivity remains available, apply it permanently.
sudo netplan try
sudo netplan apply
ip addr show enp0s3
ip routeStorage paths
Create the primary and secondary directories
Create one directory for primary storage and another for secondary storage underneath a common/exportpath.
sudo mkdir -p /export/primary
sudo mkdir -p /export/secondary
ls -ld /export /export/primary /export/secondaryPrimary
/export/primary
Used for instance volumes and active workload storage.
Secondary
/export/secondary
Used for templates, ISO images, snapshots, and related data.
Exports
Configure the NFS exports
Open the NFS exports file.
sudo nano /etc/exportsFor a lab environment, CloudStack documentation commonly exports the parent/exportdirectory. It is safer to limit access to the network used by your CloudStack hosts instead of using*.
/export 192.168.1.0/24(rw,async,no_root_squash,no_subtree_check)
or
/export *(rw,async,no_root_squash,no_subtree_check)Replace 192.168.1.0/24with the network that contains the CloudStack systems that need storage access.
sudo exportfs -rav
sudo exportfs -vAbout the async option
The async option improves performance by allowing the NFS server to acknowledge writes before they are committed to stable storage. For mission-critical production environments, review the durability trade-off and your storage platform before keeping this option.
Service configuration
Configure predictable NFS service ports
If the storage server is protected by a firewall, fixed RPC ports make the NFS services easier to permit between your CloudStack systems. On Ubuntu, configure the mount daemon in/etc/default/nfs-kernel-server.
RPCMOUNTDOPTS="-p 892 --manage-gids"Then configure the status daemon in/etc/default/nfs-common.
STATDOPTS="--port 662 --outgoing-port 2020"
NEED_STATD=yesUsing UFW or another firewall?
Permit NFS and its required RPC services only from your trusted CloudStack management/storage network. Avoid exposing NFS directly to the public Internet.
Services
Restart and enable the NFS server
Restart the NFS service so the new export and RPC configuration is active, then enable it to start automatically after a reboot.
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
sudo systemctl status nfs-kernel-server --no-pagerConfirm that the exports are still available after the restart.
sudo exportfs -v
showmount -e localhostValidation
Test the NFS shares from a KVM host
Do not stop after checking the NFS service locally. Test the share from one of the systems that will actually use it. On an Ubuntu KVM host, install the NFS client utilities if they are not already present.
sudo apt update
sudo apt install -y nfs-common
showmount -e 192.168.1.100Replace 192.168.1.100with the IP address of your NFS server, then mount the primary share temporarily.
sudo mkdir -p /mnt/cloudstack-primary-test
sudo mount -t nfs 192.168.1.100:/export/primary /mnt/cloudstack-primary-test
mount | grep cloudstack-primary-test
sudo touch /mnt/cloudstack-primary-test/cloudstack-nfs-test
sudo rm /mnt/cloudstack-primary-test/cloudstack-nfs-test
sudo umount /mnt/cloudstack-primary-testRepeat the same test with /export/secondary. If the host can list, mount, write to, and unmount both shares, the NFS server is ready for CloudStack.
NFS storage complete
Your NFS storage is ready for CloudStack.
Use the NFS server address together with /export/primary and/export/secondary when you configure storage in your CloudStack zone.