Why Move Away from Local Storage to an NFS Datastore?
Relying on local drives (Local VMFS) on individual physical servers is only convenient when first setting up a lab. The moment a RAM stick fails or a power supply dies, every virtual machine on that host goes down immediately. To enable non-disruptive live migrations with vMotion, activate High Availability (HA) to automatically restart VMs upon host failure, or balance workloads using DRS, centralized shared storage is an absolute requirement.
NFS v3 has served the virtualization world for decades. However, its inherent limitation lies in operating over a single TCP session, lacking native multipathing support.
Its decoupled NLM file-locking mechanism is also prone to bottlenecks when dozens of VMs boot simultaneously. With NFS v4.1, ESXi supports session trunking to aggregate bandwidth across multiple network cards, features in-band file locking integrated directly into the protocol, and supports Kerberos authentication. With just a Linux server equipped with SAS drives or a TrueNAS appliance over a 10GbE network, you can build a resilient storage system without having to purchase a Fibre Channel SAN or deal with complex iSCSI configurations.
In practice, when comparing ESXi to Proxmox VE, VMware’s handshake mechanism is considerably stricter. Proxmox allows flexible NFS mounts following POSIX permissions. Conversely, ESXi accesses storage under the identity of the root user (UID 0). If the storage server is not configured with no_root_squash or proper root mapping, ESXi will instantly reject the mount request or mount the volume in Read-Only mode.
Setting Up an NFS v4.1 Server on Ubuntu Linux and TrueNAS
Here are the steps to prepare your storage. We will use Ubuntu Server 22.04/24.04 LTS as our reference deployment, along with key configuration notes specific to TrueNAS SCALE.
1. Configuring the NFS Server on Ubuntu
Install the required service packages and create the storage directory:
# Install the NFS kernel service
sudo apt update && sudo apt install -y nfs-kernel-server
# Create the mount point directory for ESXi
sudo mkdir -p /mnt/storage/esxi-datastore
# Assign proper ownership for the service
sudo chown -R nobody:nogroup /mnt/storage/esxi-datastore
sudo chmod -R 775 /mnt/storage/esxi-datastore
Avoid running chmod 777 in production environments. Using 775 combined with root mapping on the server side provides all the permissions ESXi needs while maintaining security.
2. Configuring on TrueNAS (Core / SCALE)
Open the TrueNAS web UI, navigate to Shares > Unix (NFS) Shares, and create a new share pointing to your prepared dataset. Pay close attention to three critical settings:
- Maproot User: Select
root. - Maproot Group: Select
root(on SCALE) orwheel(on Core). - NFS Service Settings: Go to System Settings > Services > NFS, enable Enable NFSv4, and check NFSv4.1.
Defining Exports and Connecting from VMware ESXi
1. Configuring the Exports File on Linux
Open the NFS exports configuration file:
sudo nano /etc/exports
Append the following line to the end of the file. Replace 192.168.10.0/24 with your dedicated storage subnet:
/mnt/storage/esxi-datastore 192.168.10.0/24(rw,sync,no_subtree_check,no_root_squash,insecure)
Technical breakdown of each export option:
sync: Forces data changes to be committed to disk before acknowledging requests. This prevents VM data corruption in the event of an unexpected server power loss.no_root_squash: Preserves UID 0 permissions for ESXi requests. Without this flag, ESXi will fail with the error “The NFS server denied the mount request”.insecure: Allows clients to connect from ports higher than 1024. This prevents ESXi connections from being rejected during dynamic RPC port negotiation.no_subtree_check: Disables subtree verification, which reduces CPU overhead and avoids file handle errors when moving or manipulating VMDKs.
Export the shares and restart the service:
sudo exportfs -rav
sudo systemctl restart nfs-kernel-server
2. Isolating the VMkernel Network on VMware ESXi
Do not combine NFS storage traffic on the same virtual switch with your management network or standard VM traffic. Network congestion can lead to dropped storage I/O and cause guest operating systems to freeze.
- Go to Networking > VMkernel NICs > Add VMkernel NIC in the ESXi Host Client.
- Select or create a dedicated Port Group (for example:
Storage-Networkon a vSwitch with a 10GbE uplink). - Assign a static IP in the same subnet as the NFS server (e.g.,
192.168.10.51/24). Enable MTU 9000 (Jumbo Frames) end-to-end across ESXi, the switch, and the NFS server to reduce CPU interrupt overhead when transferring large blocks.
3. Mounting the NFS v4.1 Datastore in ESXi
Using the command line via SSH is often the fastest approach and least prone to UI quirks. Run the esxcli command directly on the host:
esxcli storage nfs41 add \
--host=192.168.10.20 \
--share=/mnt/storage/esxi-datastore \
--volume-name=NFS41_DS01 \
--sec-type=AUTH_SYS
Alternatively, to mount via the vSphere Client (Web UI):
- Navigate to Storage > Datastores > New Datastore.
- Select NFS, click Next, and select NFS 4.1.
- Name the datastore:
NFS41_DS01. - Enter the NFS Server IP:
192.168.10.20. To take advantage of multipathing session trunking, click the+icon to add the second IP address of your storage network interface (e.g.,192.168.10.21). - Folder: Enter the export path
/mnt/storage/esxi-datastore. - Security: Select
AUTH_SYS. Click Finish to complete the setup.
Validation and Troubleshooting Common Errors
Before migrating production virtual machines, verify datastore availability and measure storage throughput.
1. Verifying Connection Status
Check the volume details from the ESXi command line:
# Check NFS 4.1 volume status
esxcli storage nfs41 list
# Verify capacity and read/write access
df -h | grep NFS41
If the output shows Accessible: true and Mounted: true, your datastore is online and ready for use.
2. Benchmarking Real-World Write Speed
Measure sequential write throughput by provisioning a 10GB virtual disk file directly on the datastore:
cd /vmfs/volumes/NFS41_DS01
# Create a test file formatted as Thick Provision Eager Zeroed
time vmkfstools -c 10G -d eagerzeroedthick test_perf.vmdk
# Delete the test file after benchmarking to free up space
vmkfstools -U test_perf.vmdk
Over a 10Gbps link with enterprise SSDs, creating a 10GB file typically takes between 8 and 12 seconds (write speeds ranging from 800 to 1,100 MB/s). If creation takes more than 60 seconds, investigate potential bottlenecks in your physical switch or network adapters.
3. Common NFS Mounting Issues
- Permission Denied (NFS server denied the mount request): This is almost always caused by a missing
no_root_squashoption in/etc/exportsor not configuring the Maproot User asrootin TrueNAS. - Operation timed out: The Linux firewall is blocking the traffic. NFS v4.1 only requires TCP port
2049to be open. In contrast, NFS v3 requires port111(rpcbind) plus randomly assignedmountdports. - Mount Failed with NFS 4.1: ESXi does not automatically fall back to an older version. If you select NFS 4.1 on ESXi while the Linux host only has the NFS v3 daemon running, the connection will immediately fail during the initial RPC handshake.