NFS Notes
Miscellaneous
- Ensure that the NFS volume is exported using NFS over TCP
- Make sure that the NAS server exports a particular share as either NFS 3
- On each ESXi host, configure a VMkernel Network port for NFS traffic.
- Use only ASCII characters, or unpredictable failures might occur.
VMware NFS Locking
- NFS 3 locking on ESXi does not use the Network Lock Manager (NLM) protocol.
- VMware provides its own locking protocol.
- NFS 3 locks are implemented by creating lock files on the NFS server.
- Lock files are named .lck-file_id.
VMware Best Practices for NAS Storage
- If you are trying to mount a volume from a Linux NFS Server the server’s /etc/exports should look something like: *(rw,no_root_squash,sync)
- Best Practices for running VMware vSphereTM on Network Attached Storage
VM Config
It is assumed that the server has already been built and the underlying storage has already been setup.
If you would like to use LVM for your storage, please check out this article:
Rocky - Linux LVM Concepts and Examples for a NFS Server
Install
Install Software
Add Firewall Rules
Restart Services
Folder Permissions
The folders should have already been created during LVM setup. Make sure the machine is already joined to the domain. Create share for NFS file server - using Active Directory groups.
Crontab - Script to set Permissions
Note to future self, apply the changes above in the "Set Folder Permissions - Manually" section. The crontab job documented below is to help ensure that futre files are getting the appropriate permmisions.
Create a script to change the permissions.
Make the script exectuable.
Verify that everything looks right.
Crontab - Create Job
To add new crontab jobs, use the command below. This will use the default editor. In most cases, the default editor is vi/vim. You cannot use vi/vim on its own. You have to use the crontab command.
By using "sudo" in the command, this will add the jobs to the root accounts cronjob. As a result, using "sudo" in the actual commands is not necessary. After the text editor is open, paste the following line.
The following command will execute a script that will reapply the appropriate permissions every hour at XX:00. If you want to change the script to run at XX:30, but still every hour, simply use 30 * * * *. This is based on setting a time, not frequency.
crontab -e
0 * * * * /usr/local/bin/permissionsSet.sh
Verify the crontab job is scheduled for root.
If you need to make any changes, use the following cmd.
NFS Exports Setup
Create and configure shares. Use the IP address of the NFS client. To open it up to any host, use *. There should not be a space after the IP address nor the (switches).
Proceeding Commands
Export switches - commands to publish new shares. You do not need to restart NFS to publish new shares.
You do not need to restart NFS to publish new shares.
- exportfs -v : Displays a list of shares files and export options on a server
- exportfs -a : Exports all directories listed in /etc/exports
- exportfs -u : Unexport one or more directories
- exportfs -r : Reexport all directories after modifying /etc/exports
Restart NFS Server service; you do not need to restart NFS to publish new shares
Optional: Additional configuration files
- /etc/exports - main config file; controls which file systems are exported to remote hosts and specifies options
- /etc/fstab - controls which file systems are mounted during system startup (including NFS directories)
- /etc/sysconfig/nfs - controls which ports RPC services run on
- /etc/hosts.allow - TCP wrapper; controlles the access to the NFS server
- /etc/hosts.deny - TCP wrapper; controlles the access to the NFS server
NFS Client Setup
For more information on setting up Linux or Windows hosts to access NFS exports, refer to the following: Join a Linux machine to Windows Active Directory