Skip to content
CodeFlowerHorn
Menu

CloudStack Setup · Guide 03

How to Set Up NFS Storage for Apache CloudStack

Configure an Ubuntu NFS server with dedicated primary and secondary storage exports for your Apache CloudStack environment.

CodeFlowerHornApache CloudStack 4.19
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.
01

Install NFS

Install the NFS server packages

Start by updating the package index and installing the Ubuntu NFS server package.

NFS Serverbash
sudo apt update
sudo apt install -y nfs-kernel-server

You do not need to configure the CloudStack Management Server software on this machine when it is being used as a dedicated storage server.

02

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.

NFS Serverbash
ip link
ip route

Create or edit your Netplan configuration. The following example assigns192.168.1.100/24to enp0s3.

Netplan configurationyaml
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.1
!

Do 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.

NFS Serverbash
sudo netplan try
sudo netplan apply
ip addr show enp0s3
ip route
03

Storage paths

Create the primary and secondary directories

Create one directory for primary storage and another for secondary storage underneath a common/exportpath.

NFS Serverbash
sudo mkdir -p /export/primary
sudo mkdir -p /export/secondary
ls -ld /export /export/primary /export/secondary

Primary

/export/primary

Used for instance volumes and active workload storage.

Secondary

/export/secondary

Used for templates, ISO images, snapshots, and related data.

04

Exports

Configure the NFS exports

Open the NFS exports file.

NFS Serverbash
sudo nano /etc/exports

For 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*.

/etc/exportstext
/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.

NFS Serverbash
sudo exportfs -rav
sudo exportfs -v

About 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.

05

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.

/etc/default/nfs-kernel-servertext
RPCMOUNTDOPTS="-p 892 --manage-gids"

Then configure the status daemon in/etc/default/nfs-common.

/etc/default/nfs-commontext
STATDOPTS="--port 662 --outgoing-port 2020"
NEED_STATD=yes

Using 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.

06

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.

NFS Serverbash
sudo systemctl restart nfs-kernel-server
sudo systemctl enable nfs-kernel-server
sudo systemctl status nfs-kernel-server --no-pager

Confirm that the exports are still available after the restart.

NFS Serverbash
sudo exportfs -v
showmount -e localhost
07

Validation

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.

KVM Hostbash
sudo apt update
sudo apt install -y nfs-common

showmount -e 192.168.1.100

Replace 192.168.1.100with the IP address of your NFS server, then mount the primary share temporarily.

KVM Hostbash
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-test

Repeat 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.