NFS storage can be used to store virtual machine files, disk images, and other files in a VMware infrastructure. In this post, we will see how to unmount an NFS datastore from VMware ESXi and what to do if an error occurs when you try to unmount an NFS share or the NFS storage becomes inactive.
Material:
How to properly mount/unmount NFS storage on VMware?
To unmount the NFS storage on the ESXi host, in the vSphere client console, right-click and select unmount the datastore, A list of the ESXi hosts on which this NFS share is mounted appears in the list.
You must unmount the NFS storage on all ESXi hosts to make it disappear in the vSphere interface.
An ESXi host may unmount NFS storage if:
- There are no running or registered virtual machines on the NFS volume. You need to power off the VMs or move them to another datastore using Storage vMotion;
- There are no snapshots, ISO images, or virtual disks (VMDKs) on the datastore that are mounted in other VMs;
- The datastore is not managed by the Storage DRS and is not part of the datastore cluster;
- vSphere HA does not use heartbeat storage;
- Storage I/O control is disabled for the datastore;
- In the Advanced System Settings of the ESXi host, verify that the NFS datastore is not being used to store log or swap files (check
global.logDir
AndScratchConfig.CurrentScratchLocation
Options under Configure -> Advanced System Settings -> Edit; Read more in this post – ESXi system logs are stored on non-persistent storage);
An error will occur when unmounting NFS storage if one of these conditions is not met:
The "remove datastore" operation failed. The resource 'nfs_datastore' is in use.
Or:
Cannot remove datastore 'nfs_datastore' because system swap is enabled on it.
Deleting Passive NFS Datastore on VMware ESXi Host
If the NFS share was disabled on the NFS server side before unmounting it on ESXi, or if there are still VMs running on the NFS volume, an error occurs when you try to unmount an NFS datastore from the vSphere client interface We do:
Error performing operation: NFS Error: Unable to Unmount filesystem: Busy
Or:
The object ‘vim.Datastore:ds:///vmfs/volumes/NFS_Store1/’ has already been deleted or has not been completely created
$ esxcli network firewall ruleset set --ruleset-id nfs41Client --enabled=true
$ esxcli network firewall ruleset set --ruleset-id nfsClient --enabled=true
If NFS storage is not available, it is disabled (grayed out) in the host’s storage list in the vSphere interface. In my case, an error occurred when I tried to remove a passive NFS volume from the ESXi host configuration:
The resource datastore_nfs02 is in use. Call “HostDatastoreSystem.RemoveDatastore” form object “datastoreSystem-28″ on vCenter Server “xxxx” failed. CannotRemove datastore ‘datastore_name’ because Storage I/O control is enabled on it. Correct it and re-try the operation.
Based on the error, the NFS storage cannot be removed because Storage I/O Control (SIOC) is enabled. Another error occurs when you disable storage I/O control for a datastore:
Datastore is not accessible
Solution:
To properly remove inactive NFS storage from an ESXi host, you must connect to the console of the ESXi host server using SSH (How to Enable SSH on VMware ESXi).
See the list of NFS volumes available on the VMware ESXi host:# esxcli storage nfs list
If necessary, you can view detailed information about NFS storage:
# vim-cmd hostsvc/datastore/info datastore_nfs02
Run command to unmount NFS volume from ESXi host:
# esxcli storage nfs remove –v datastore_nfs02
Comment, If the NFS datastore contains spaces, you must enclose the NFS datastore name in quotation marks.
Comment, This action must be performed on each ESXi host where you want to delete a passive NFS share.
If the NFS datastore is not removed from the vSphere client, click the Refresh button or Rescan Storage in the ESXi Storage section (Configuration -> Storage).
Leave a Comment