Deployment guide

nfs file server

Overview

This image runs an NFS (Network File System) file server built on the operating system's own kernel NFS server, the standard file sharing service used across Linux. It is configured and hardened at build time, so you can share a directory with your trusted clients within minutes of launch, without editing the export table or the NFS daemon configuration by hand.

The server exports a dedicated, independently resizable Azure data disk mounted at /srv/nfs, separate from the operating system disk. The data disk is part of the image, so every VM you deploy is provisioned with it automatically and your shared data never competes with the OS for space.

The image is secure by default. The shipped export is restricted to the loopback address (127.0.0.1), so no machine on the network can mount the share until you open it to a client network you trust. The server runs NFSv4 only (NFSv2 and NFSv3 are disabled), which removes the rpcbind and statd services and leaves a single well-known port, TCP 2049. Every export uses root_squash, so a remote root user is mapped to an unprivileged account and cannot own or overwrite files as root.

A single management tool, nfs-share, adds and removes client networks. It refuses any world-open export. On the first boot of every VM, a one-shot service prepares the export directory and its ownership, derives a per-VM NFSv4 identity mapping domain, and writes the server's address and the exact commands to open the share to a root-only information file.

What you get:

  • OS-native kernel NFS server (Ubuntu 24.04 noble main), configured NFSv4 only (TCP 2049)
  • Dedicated 50 GiB data disk at /srv/nfs (ext4), separate from the OS disk and captured in the image
  • Secure-by-default export that is loopback-only until you open it, with root_squash, sync and no_subtree_check
  • nfs-share management tool in /usr/local/sbin (status, list, allow, deny) with world-open guardrails
  • Per-VM first-boot initialisation that writes server details to /root/nfs-server-info.txt
  • All packages from the Ubuntu archive (kernel and nfs-utils), with no third-party repository
  • 24/7 SecureAnyCloud support

Prerequisites

Before you deploy this image, make sure you have:

  • An active Microsoft Azure subscription where you can create virtual machines
  • An SSH key pair for administrator access to the VM
  • A virtual network and subnet in the target region. NFS clients mount the server over the private network, so place your clients in the same VNet or a peered one
  • A network security group (NSG) that allows inbound TCP 2049 from the client subnets that will mount the share, and inbound TCP 22 from your administrator network
  • The Azure CLI installed locally if you plan to deploy from the command line
  • One or more Linux client machines with nfs-common (or the equivalent NFS client package) installed to mount the share

Standard_B2s (2 vCPU, 4 GiB RAM) is a balanced default. Size the VM to the number of clients and the throughput you expect. NFSv4 uses only TCP 2049, so that is the single service port to allow on the NSG.

1

Deploy from the Azure Marketplace

Sign in to the Azure portal, select Create a resource, and search the Marketplace for NFS File Server by SecureAnyCloud. Select the listing, then select Create.

On the Basics tab, choose your subscription, resource group, region and VM size (Standard_B2s or larger). Under Administrator account, select SSH public key, set the username, and paste your public key. Under Inbound port rules, allow SSH (22) for administration. You add the NFS rule (TCP 2049), scoped to your client subnets, after deployment.

On the Disks tab, review the dedicated data disk. It is included in the image and holds your shared data. Select Review + create, then Create. First-boot initialisation completes within a few seconds of the VM reaching the Running state.

2

Deploy from the Azure CLI

Create a VM from the SecureAnyCloud NFS File Server image in an existing VNet and subnet. Replace the values in angle brackets with your own. The dedicated /srv/nfs data disk is part of the image and is attached automatically.

# Accept the Marketplace terms once per subscription (required before the first CLI deploy)
az vm image terms accept --urn sac1647283583153:nfs-file-server-ubuntu-24-04:default:latest
az vm create \
  --resource-group <your-rg> \
  --name nfs-file-server \
  --image sac1647283583153:nfs-file-server-ubuntu-24-04:default:latest \
  --size Standard_B2s \
  --admin-username azureuser \
  --ssh-key-values ~/.ssh/id_ed25519.pub \
  --vnet-name <your-vnet> --subnet <your-subnet> \
  --public-ip-sku Standard
# Allow NFS (TCP 2049) from your client subnet only — never from the internet.
az vm open-port --resource-group <your-rg> --name nfs-file-server --port 2049 --priority 1010
3

Connect as the Administrator over SSH

Connect to the VM over SSH as the administrator user you set at deploy time (azureuser by default on Ubuntu). The administrator account accepts SSH keys only.

ssh azureuser@<vm-public-ip>
4

Confirm the Server is Running

The NFS server starts automatically on boot. Confirm that the service is active, that it serves NFSv4 only, that the dedicated data disk is mounted, and inspect the live export table.

systemctl is-active nfs-server.service cat /proc/fs/nfsd/versions findmnt -no SOURCE,SIZE,FSTYPE,TARGET /srv/nfs
sudo exportfs -v

The versions line shows -3 +4, which means NFSv3 is disabled and NFSv4 is enabled. The export table lists /srv/nfs/share restricted to 127.0.0.1, which is the secure default.

5

The Secure by Default Export Model

Read the first-boot information file and the export summary with the nfs-share tool. The file records the server's private IP and the exact command to open the share to your clients.

sudo cat /root/nfs-server-info.txt
sudo nfs-share status

The image ships with the share exported to 127.0.0.1 only. This is deliberate: no client on the network can mount the share until you explicitly allow its network. The image never ships a wildcard (*) or 0.0.0.0/0 export.

The export uses these options:

  • root_squash maps a remote root user to the unprivileged nobody account.
  • sync commits writes before the server acknowledges them.
  • no_subtree_check keeps exports stable and reliable.
6

Open the Share to Your Client Network

Grant a trusted client network read/write access to the share with nfs-share allow, passing a CIDR range or a single host. Use your own client subnet's CIDR in place of the example value. Add --ro for a read-only export.

sudo nfs-share allow 10.0.0.0/24
sudo nfs-share list

The tool appends the export, reloads the export table and confirms the change. It refuses world-open exports: nfs-share allow '*' and nfs-share allow 0.0.0.0/0 are both rejected, and so is the --no-root-squash option. You cannot accidentally expose the share to the whole internet or give remote root full ownership.

7

Mount the Share from a Linux Client

On a client machine in the allowed network, install the NFS client tools and mount the share using the server's private IP address, which is recorded in /root/nfs-server-info.txt. NFSv4 mounts the exported path directly.

# On the client (Ubuntu/Debian):
sudo apt-get update && sudo apt-get install -y nfs-common
sudo mkdir -p /mnt/nfs
sudo mount -t nfs <server-private-ip>:/srv/nfs/share /mnt/nfs
# Verify and use it:
df -h /mnt/nfs echo "hello from the client" | sudo tee /mnt/nfs/test.txt

To mount the share automatically at boot, add this line to the client's /etc/fstab.

<server-private-ip>:/srv/nfs/share /mnt/nfs nfs defaults,_netdev 0 0
8

Verify the Share Locally

You can confirm the export works end to end on the server itself, without any client. A loopback mount over 127.0.0.1 writes a file, reads it back and unmounts.

sudo mkdir -p /mnt/nfs-check
sudo mount -t nfs 127.0.0.1:/srv/nfs/share /mnt/nfs-check echo "sac NFS shared storage" | sudo tee /mnt/nfs-check/hello.txt cat /mnt/nfs-check/hello.txt
sudo rm -f /mnt/nfs-check/hello.txt
sudo umount /mnt/nfs-check

A successful write and read-back confirms that the server, the export and the dedicated data disk are all working.

9

Managing Exports

Use the nfs-share tool to inspect, add and remove client networks. It is the primary interface to the export allow list.

sudo nfs-share status
sudo nfs-share list

Revoke a client network's access when it no longer needs the share. The export table reloads immediately.

sudo nfs-share deny 10.0.0.0/24

The tool supports these commands:

  • nfs-share status shows the server, the configured clients and the live export table.
  • nfs-share list shows the live NFS export table (exportfs -v).
  • nfs-share allow <CIDR\|host> [--ro] grants a client network read/write access, or read-only access with --ro.
  • nfs-share deny <CIDR\|host> revokes a client network's access.

You can also edit /etc/exports directly and run sudo exportfs -ra to apply changes. The nfs-share guardrails apply only when you use the tool.

10

The Dedicated Data Disk

Shared data lives on a dedicated Azure data disk mounted at /srv/nfs, separate from the OS disk. The exported directory is /srv/nfs/share. Because the disk is captured in the image, every VM you deploy has it automatically.

To grow the share, resize the data disk in the Azure portal or CLI, then extend the filesystem.

# After increasing the data disk size in Azure:
sudo growpart /dev/disk/azure/scsi1/lun0 1 2>/dev/null || true
sudo resize2fs $(findmnt -no SOURCE /srv/nfs)

The export root /srv/nfs/share is owned by the unprivileged nobody:nogroup account. Clients writing through root_squash can therefore read and write, and the mount is never world-writable.

11

Hardening Notes

The image is hardened out of the box:

  • The server runs NFSv4 only, so rpcbind and statd are not present and the only listening port is TCP 2049.
  • The shipped export is loopback-only until you open it.
  • Every export uses root_squash, so remote root has no privileged access.
  • The nfs-share tool refuses world-open exports.

To keep the server locked down, scope the NSG rule for TCP 2049 to the client subnets that need the share, and never expose port 2049 to the internet. Grant the narrowest CIDR ranges you can, prefer --ro exports for read-only consumers, and keep the OS patched (sudo apt update && sudo apt upgrade). For sensitive data over untrusted networks, consider Kerberos (sec=krb5p) or a private, encrypted network path.

Support

This image is backed by 24/7 SecureAnyCloud support. Contact us by email or chat for help with NFS export configuration, client mounting, the dedicated data disk, NFSv4 identity mapping, root_squash and access control, and shared storage architecture on Azure.

All product and company names are trademarks or registered trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.

Deploy on Azure

Launch NFS File Server on Ubuntu 24.04 LTS on Azure, with 24/7 support from SecureAnyCloud.

View this image

Need Help?

Our support team is available 24/7.

sales@secureanycloud.com

Deploy on Azure