When using NFS for your datastores on your SAN (eg. NetApp) and you resize your datastore on the fly it always takes a while before the ESX/vSphere servers refresh the datastore so you can see the new size of the volume.
This can be annoying when you want to create a VM on one of these volumes and ESX still thinks the volume is too small because it hasn’t refreshed it’s datastores yet. Normally I would pick one ESX server where I want to put the VM on for starters and refresh the NFS volume which I want to use:
Ofcourse I wanted to make it easier for myself so I wrote a little PowerShell script to refresh the datastores on all ESX Servers in our Cluster. I think it’s also possible to make a oneliner out of this and I will try to create one and if I succeed I’ll post it again
$vcHost = "virtual.center.host"
$vcClusterName = "Your ClusterName"
$vcUser = "username"
$vcPass = "password"
$vcServer = Connect-VIServer -Server:$vcHost -User:$vcUser -Password:$vcPass -WarningAction:SilentlyContinue
$vmHosts = Get-Datacenter | Get-Cluster -Name:$vcClusterName | Get-VMHost | Sort
ForEach ($vmHost in $vmHosts) {
If (Get-VMHostStorage -VMHost:$vmHost -Refresh -ErrorAction:SilentlyContinue -WarningAction:SilentlyContinue) {
Write-Host $vmHost.Name," host storage information refreshed"
} else {
Write-Host $vmHost.Name," host storage refresh failed!"
}
}
Disconnect-VIServer -Server:$vcServer -Confirm:$false
After the script has been running the datastores on all your ESX-servers in the cluster will be refreshed so all resizes of your NFS volumes on your SAN will be visible and “active”.