Few days ago, while I was working on my home lab, I changed one of the NFS mounted shared storage on one of my ESXi 5.0 hosts.
As this action happened only on one host, this different name start making some problems. One of these problem was the case of moving VMs from one host to the other while they mounted an ISO file.
I knew the result but as I tested that before but I just I tried to rename the new named shared storage to what it was before, but it generated some error about the duplicated name.
I had to unmounts those different named shared storage and mount them back, so first step should be unmounts current ISO files from VMs.
I used “RVTools” which is written by “Rob de Veij” for checking if any VM have mounted ISO files and there was more than 10 VMs.
As I’m trying to learn VMware PowerCLI and PowerShell generally, I decided to do it with some writing so I opened “PowerCLI4.1.1-Print-At-Home-Office.pdf”, looked for CD Drive related cmdlet and came across “Get-CDDrive” and “Set-CDDrive”.
I tried multiple times and finally managed to use it as below to disconnecting all ISO files from all VMs at the same time.
Get-VM * | Get-CDDrive | Set-CDDrive -NoMedia -Confirm:$true
- in the above code will select all VMs and this will impact the performance as it will check every single VM, even if they don’t have any ISO mounted; I’ll try to fix this problem.
After disconnecting al ISO files from VMs, I ran the RVTools again and as I expected the list of attached media was empty.
I tried to remove NFS shared folder from first host (ESXi50-1) and it’s finished successfully, I moved to the last one and tried same thing by selecting the datastore (NFS) and using “unmount” option.
After accepting all consequences , I received an error which indicating that this process is terminated because of some usage, related screenshot is posted below.
I ran RVTools again and there was no VM with any ISO image connected. I searched internet for any similar problem and find this thread on “VMware Community”.
Based on “Rich123” recommendation, I used MAP on the vSphere Client for checking the current state and selected only VMs, Hosts and datastores for viewing option, amazing map created as it’s shown in the below image.
Based on MAP view, I had two VMs with active connection to the NFS storage so opened their “Virtual Machine Setting” window, but here things get even more interesting; just check the below images:
Now, here is the question, if there is no ISO file and the VM placed on the iSCSI datastore, what causes the connection?
…
Well, few days back, when I was working on the VMware View 5.0, I made a snapshot from “Parent-XP” for using with VMware View Composer as well as making snapshot from “VMware ThinApp” for making safe and clear rollback point in order to use with “VMware ThinApp Suite”.
When I remembered these events, I removed both snapshots from VM and watched the MAP and “Recent Task” pane for changes.
After successfully removing both snapshots, I checked the possibility of removing NFS and it’s just done so easy.
For adding NFS share to all hosts at the same time with identical name, I used PowerCLI again and it’s related post can be found here.
Summary:
Disconnecting ISO files from VMs might not be enough for unmounting datastore from hosts (NFS in my case) if any snapshot had connection to these ISO files on that specific datastore.
If you get “The resource ‘XYZ’ is in use.” during unmounting datastore, checking the snapshot might be helpful.