Hyper-V VMs cannot find the path after storage migration

Encountered error code was '0x3' ('The system cannot find the path specified.') after a VM storage migration

VMs cannot find the path specified

I encountered an interesting issue today after completing a VM storage migration of approximately one hundred Hyper-V VMs.  Most of them began reporting: VMs cannot find the path

All one hundred Hyper-V VMs were highly available VMs and needed to be moved from one set of CSV LUNs to a different set of CSV LUNs.

This isn’t anything I hadn’t done a dozen times before as storage migrations are relatively straightforward.  You can initiate the storage migration via the Failover Cluster GUI or script something similar to this:

$vms = #get a list of your vms here however you wish
#loop through and move your VMs to the desired location
foreach($vm in $vms){
    Move-VMStorage $vm -DestinationStoragePath C:\ClusterStorage\Volume1\VMs
}

Once the migration was completed however, only four of the VMs would start with the rest indicating the following cluster error:

Cluster resource 'Virtual Machine Configuration aVMName' of type 'Virtual Machine Configuration' in clustered role 'aVMName' failed. The error code was '0x3' ('The system cannot find the path specified.').
Based on the failure policies for the resource and role, the cluster service may try to bring the resource online on this node or move the group to another node of the cluster and then restart it.  Check the resource and group state using Failover Cluster Manager or the Get-ClusterResource Windows PowerShell cmdlet.

The VMs experiencing an issue were still showing in Failover Cluster Manager but were not visible in Hyper-V Manager any longer.

Slightly worried I quickly verified that the virtual machine files were at the target destination and they were:
Hyper-V Virtual Machine Locations

The GUID folders were empty as expected as the VMs were off.  The XML files were located in the parent target directory as well:

Hyper-V Virtual Machine Locations - XML and GUID folder structureThe VMs that were running had good bin and vsv files:

Hyper-V VM bin and vsv file locations

I also verified all vhdx files had successfully migrated to their target destinations.

Perplexed, I attempted to perform an Import Virtual Machine against one of the GUID .xml files.  It worked.  The VM popped right up in Hyper-V Manager.  I couldn’t add it back as an HA VM because it already existed in the cluster.  So, I removed it from cluster, and then just made the VM HA again.  It started right up.

No explanation for what caused this perplexing issue but I had a solution – but having to re-import and make 100 VMs HA manually was not shaping up to make a fun day.

So, I decided to whip up a quick script.

I started by removing all the HA VMs from the Failover Cluster Manager.  They were all just reporting: VMs cannot find the path

I pulled all the GUIDs in from the storage locations and loaded those GUIDs into an array.

Then I:

  1. Looped through each GUID in the array – and imported it back into Hyper-V
  2. Added the VM back into the cluster
  3. Started the VM

Fix time manual: hours?

Actual fix time: 20 minutes!

#*********************************************
#declare an array containing all the XML GUIDs
$anArray = @()
$anArray = 
"2A413B6D-0190-4E9D-9D34-F232680XXXXX",
"3A802B38-6B3A-488D-8D22-8CB08C1XXXXX",
"3D000830-5D54-4A06-87C8-0CA6CB3XXXXX",
"4DB0DFC2-DF1D-418E-9DB5-AA654CFXXXXX",
"5D259BCA-27AC-47FF-A7C9-596FCF6XXXXX",
"8BA88E85-A00C-4827-8686-2AD4529XXXXX",
"9D11193B-CA70-4455-BCF0-A5A3E0FXXXXX",
"57C81655-E8A2-4CEC-BCC6-F3F7855XXXXX",
"86BA51F9-3D04-47BD-BD59-2A1E4AFXXXXX",
"95F51FFE-8932-4C2D-A910-D81B48DXXXXX",
"476B33A0-2BF5-4D85-9766-EA688E4XXXXX",
"42726EFB-F2ED-45D6-8680-7D60150XXXXX",
"95552FAC-B2DE-4D4C-B1DF-1DF057FXXXXX",
"9612085D-057D-479C-85AA-18A607EXXXXX",
"B68F5716-9C23-46A7-8185-1D81695XXXXX",
"BE2D2CD9-E807-4E36-9C22-7EA0D0DXXXXX",
"C2DE2D11-7E5E-42E0-9443-75CD4B1XXXXX",
"D9E791BC-94C0-4CC4-B528-766C657XXXXX",
"E7EDCF81-E761-4FE9-A0DD-D0CD976XXXXX",
"E695A3D4-0154-4110-8352-3B4590FXXXXX",
"EF933645-E6C3-49E5-B4CD-013182AXXXXX",
"F616092E-C0C8-4F3E-BB31-06521D8XXXXX"
#*********************************************

#loop through each guid in the array
foreach($guid in $anArray){
    #import and register the VM again as a local VM
    $id = import-vm -path "C:\ClusterStorage\Volume2\VMs\Virtual Machines\$guid.xml"
    #return the VM to a HA VM in the cluster
    Add-ClusterVirtualMachineRole -VMName $id.name
    #star the VM back up
    Start-VM $id.name
}

2 Comments

Leave a Reply

Your email address will not be published.


*