One of the topics to master for VCAP-DCA exam (but not only) is to handle some CLI commands which enables NFS management. Those commands can list existing connected NFS storage, Add new storage or delete NAS file system.
Those commands are also useful when you troubleshoot your NFS storage or when your NFS server has crashed and you want to re-add it back again, but it does not refresh the NFS mount. Usually this results in error messages saying that “unmount Filesystem busy”, so in this case you have to go and remove and re-add the datastore through the CLI.
Show all NFS filesystems
So we can start the exercise with this simple command which allows to list all known NAS file systems connected to your ESXi host:
esxcli storage nfs list
as an output you should see something like this (note the Hardware Acceleration column which can show if VAAI is supported on your NAS, or not):
Remove a NFS filesystem
This command does not delete the datastore, so you don't have to worry about data loss. It only unmounts the datastore.
esxcli storage nfs remove -v DATASTORE_NAME
so in our case it would be:
esxcli storage nfs remove -v Nexenta
Watch out for Case Sensitivity and the fact that the datastore you might want to unmount might be used for datastore heartbeating. If that's the case, you might need to change the HA heartbeat preferences by selecting your HA cluster > Edit Settings > HA preferences > Datastore Heartbeating. And choose Select only from my prefered datastores.
You might get the same error if the datastore is used by virtual machine.
Add a NAS filesystem to your ESXi host
Two options – read write or read only. The second one is useful for example if you don't want the content being modified (ISOs).
Switches:
-H … Host (note that this switch is UPPER case)
-s … NFS Share to mount
-v … Volume Name of the datastore
So in our case:
esxcli storage nfs add -H=10.10.3.40 -s /volumes/zfs/nexenta -v Nexenta
Note the -r switch at the end saying that the NFS mount is Read-Only.
You see. There is just few commands and you can do lots of stuff already. Another piece of cake would be to do this (and more) through PowerCLI… but that's a subject of one of my future articles. Stay tuned and enjoy.. -:)
Ravi says
i am using more the 600 ESX box more than 6 VC’s approx .. i need to collect Host have issue with HA & DRS alarm, that also need to collect through powercli ?
Ravi says
1. the issue is different because someone VMware Administrator Cleared the logs from Alarms, for example we have 32 server with in a single cluster5 servers have some problem related with hardware issue, if the alarms has been cleared the status shows as green, but the issue originally there on the specified host, in this scenario how to collect which ESX host have facing hardware issue ? i need to collect this issue through powercli ?
Vladan SEGET says
And what’s the relation about the fact that I’m explaining the management of NFS datastores via the CLI???
It it’s hardware issue, I would install the vendor’s software for the hardware management. Usually it’s more “fine grain”.
Dan says
Hi Vladan, looking for more VCAP5-DCA tips from you. Thanks for posting, those are very helpful.