If you want to create a new datastore backed by an NFSv4 share, this can be done either from the ESXi embedded web client or using esxcli.
In this article, I will explain how to test a remote NFSv4 volume from an Ubuntu Linux server as validation. Then move on to mounting it as a datastore on the ESXi host.
Test NFSv4 mount from Linux host
Before I do this from ESXi, I like to validate it works from a remote Linux host first as validation. Here are steps for proving a connection the NFSv4 mount.
# os package required for nfs client $ sudo apt install nfs-common -y # show volume names from remote NFS server $ nfs_server=192.168.1.10 $ showmount -e $nfs_server /volume1/my-nfs 192.168.1.0/24,192.168.2.0/24 # mount remote nfs to local directory $ remote_mount=/volume1/my-nfs $ local_dir=/nfs $ sudo mkdir -p $local_dir $ sudo mount -t nfs4 ${nfs_server}:${remote_mount} $local_dir # prove that write to NFS works $ echo my test | sudo tee -a $local_dir/mytest.txt # prove listing of NFS works $ ls -latr $local_dir # remove NFS file $ sudo rm $local_dir/mytest.txt # test done, unmount $ sudo umount $local_dir
NOTE: there are typically rules on the NFS server side specifying which source IP ranges can connect as a client. Be sure that this Linux host as well as the ESXi host are in that range or you will be refused a connection.
Enable NFS firewall rules
There are firewall rules on the ESXi host, so in order to be able to reach the NFSv4 server on standard NFS port 2049, you will need to enable the firewall settings.
This can be done directly on the esxi host using the esxcli tool.
# ssh into esxi host ssh root@esxi1.home.lab # enable firewall rules for NFS esxcli network firewall ruleset set --ruleset-id nfs41Client --enabled=true esxcli network firewall ruleset set --ruleset-id nfsClient --enabled=true
Mount as datastore from ESXi
To mount datastore using esxcli
# setup variables nfs_server=192.168.1.10 remote_mount=/volume1/my-nfs # check netcat to remote NFS server nc -vz $nfs_server 2049 # add datastore using esxcli esxcli storage nfs41 add -H $nfs_server -s $remote_mount -v mynfs-datastore # show NFSv4 datastores esxcli storage nfs41 list # check vmkernel logs for error tail /var/log/vmkernel.log
And you should also see the new “mynfs-datastore” from the ESXi embedded web client.
To mount datastore using ESXi embedded web client
From (https://esxi1.home.lab,user=root), select “Storage” > “New datstore” then “Mount NFS datastore”, then “Next”.
Fill in the same information provided in the previous step, per the the screenshot below. If you don’t need credentials to connect, you can leave it blank.
Press, “Next”, then “Finish” and within 30 seconds when the task is done you should see the additional datastore.
REFERENCES
techoverflow, fstab for synology nfs
linuxhint, synology nfs as linux mount
linuxhint, synology nfs as esx datastore
vmware, esxcli command to mount nfs filestore
vmware, nfsClient and nfs41Client firewall behavior
NOTES
persist mount after reboot on Linux
# persist mount after reboot echo "${nfs_server}:${remote_mount} $local_dir nfs4 async,soft,auto 0 0" | sudo tee -a /etc/fstab