NFS can be used as an alternative to a VMFS datastore for storing virtual machines. When using an NFS share as storage for virtual machines, there are a few things to be aware of.
- You should use a dedicated VMKernel interface for connecting to the NFS server. This can be a port group on an existing switch or on a new switch.
- Ensure that the NFS client is enabled on the hosts, and that the necessary firewall ports are open both on your host and on the NFS server.
- The NFS server should be configured so that it is exporting mount points that are accessible to the hosts via a trusted network.
- ESXi hosts must have root access to the NFS share. On non-windows NFS servers this is typically done using the no_root_squash option in the /etc/exports file. For Windows NFS shares it is a tick box option when setting permissions for the share.
- For resilience the vSwitch used, and the NFS server, should have multiple uplinks.
If you are setting up NFS in a lab environment, I’ve done a couple of articles about configuring Windows as an NFS server. These can be found here and here.
When troubleshooting issues mounting a NFS datastore, you should first confirm there is connectivity to the NFS server. Verify the hosts networking is configured correctly, and that there is a VMkernel interface from which the NFS storage can be accessed. Connectivity can be tested using vmkping:
~ # vmkping -I vmk0 192.168.88.139 PING 192.168.88.139 (192.168.88.139): 56 data bytes 64 bytes from 192.168.88.139: icmp_seq=0 ttl=128 time=0.637 ms 64 bytes from 192.168.88.139: icmp_seq=1 ttl=128 time=0.461 ms 64 bytes from 192.168.88.139: icmp_seq=2 ttl=128 time=0.450 ms
Using the ‘-I’ parameter in the vmkping command allows you to specify an interface on the host from which the ping will be sent. In this example, a response has been received successfully. If that wasn’t the case then the hosts network configuration should be checked, along with the external networking and NFS server(s). If there is network connectivity, but the datastore won’t mount, then it is likely there is a permissions issue that will need to be investigated alongside the storage administrator.
Along with troubleshooting using the vSphere client you can also use esxcli to list and add NFS datastores. To list the NFS datastores configured for use by a host you can run:
~ # esxcli storage nfs list Volume Name Host Share Accessible Mounted Hardware Acceleration ----------- -------------- --------- ---------- ------- --------------------- NFS1 192.168.88.139 NFSshare1 true true Not Supported
The output above shows that this host has one NFS datastore which is currently mounted and accessible. If there was a problem reaching a NFS datastore you can expect to see the following:
~ # esxcli storage nfs list Volume Name Host Share Accessible Mounted Hardware Acceleration ----------- -------------- --------- ---------- ------- --------------------- NFS1 192.168.88.139 NFSshare1 false true Not Supported
Listing NFS Datastore Parameters
You can list the parameters of an attached NFS datastore by using the ‘param’ namespace:
~ # esxcli storage nfs param get -n all Volume Name MaxQueueDepth MaxReadTransferSize MaxWriteTransferSize ----------- ------------- ------------------- -------------------- NFS1 4294967295 32768 32768
Adding and Removing NFS Datastores using ESXCLI
As an alternative to using the ‘Add Storage’ wizard in the vSphere client, you can also add and remove NFS datastores using esxcli. As when removing a VMFS datastore, an NFS datastore should be unmounted before you remove it. To unmount you can run the following:
~ # esxcli storage filesystem unmount -l NFS1
To check it is now unmounted run:
~ # esxcli storage nfs list Volume Name Host Share Accessible Mounted Hardware Acceleration ----------- -------------- --------- ---------- ------- --------------------- NFS1 192.168.88.139 NFSshare1 false false Unknown
The output confirms that the NFS datastore called ‘NFS1’ is no longer mounted. It can now be removed by running:
~ # esxcli storage nfs remove -v NFS1
On this host, the ‘esxcli storage nfs list’ command will no longer return any results. A NFS datastore can be added to a host using the ‘esxcli storage nfs add’ command:
Usage: esxcli storage nfs add [cmd options] Description: add Add a new NAS volume to the ESX Host and mount it with the given volume name. Cmd options: -H|--host= The hostname or IP address of the NAS volume to add and mount on the system. (required) -r|--readonly If set this flag will set the mount point to be read-only. -s|--share= The share name on the remote system to use for this NAS mount point. (required) -v|--volume-name= The volume name to use for the NAS mount. This must be a unique volume name and cannot conflict with existing NAS, VMFS or other volume names. (required)
For example:
~ # esxcli storage nfs add -H 192.168.88.139 -s NFSshare1 -v NFS1
It can be confirmed that the NFS datastore has been attached to the host and is mounted by running:
~ # esxcli storage nfs list Volume Name Host Share Accessible Mounted Hardware Acceleration ----------- -------------- --------- ---------- ------- --------------------- NFS1 192.168.88.139 NFSshare1 true true Not Supported
Useful Links and Resources
https://www.vmware.com/files/pdf/techpaper/VMW-WP-vSPHR-NAS-USLET-101-WEB.pdf