question

Doria avatar image
0 Votes"
Doria asked Doria commented

Importing Hyper-V VM error #40010 Virtual Hard Disk file not found.

Hi everyone!

How can I resolve the error below? May someone explain to me the error? I don't get it. The path exists!

 PS C:\export> Import-VM -Path 'C:\export\Rancid\Virtual Machines\05262CA9-D444-44FE-ADF8-D364C6E0A1CA.vmcx' -Copy -GenerateNewId
 Import-VM : Unable to import virtual machine due to configuration errors.  Please use Compare-VM to repair the virtual
 machine.
 At line:1 char:1
 + Import-VM -Path 'C:\export\Rancid\Virtual Machines\05262CA9-D444-44FE ...
 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     + CategoryInfo          : InvalidOperation: (:) [Import-VM], VirtualizationException
     + FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.ImportVM
    
 PS C:\export> $report = Compare-VM -Path 'C:\export\Rancid\Virtual Machines\05262CA9-D444-44FE-ADF8-D364C6E0A1CA.vmcx'
 PS C:\export> $report.Incompatibilities[0].Source | fl
    
    
 Path                          : C:\VMs\Rancid.vhdx
 DiskNumber                    :
 MaximumIOPS                   : 0
 MinimumIOPS                   : 0
 QoSPolicyID                   : 00000000-0000-0000-0000-000000000000
 SupportPersistentReservations : False
 WriteHardeningMethod          : Default
 ControllerLocation            : 0
 ControllerNumber              : 0
 ControllerType                : IDE
 Name                          : Hard Drive on IDE controller number 0 at location 0
 PoolName                      : Primordial
 Id                            : Microsoft:05262CA9-D444-44FE-ADF8-D364C6E0A1CA\83F8638B-8DCA-4152-9EDA-2CA8B33039B4\0\0
                                 \D
 VMId                          : 05262ca9-d444-44fe-adf8-d364c6e0a1ca
 VMName                        : Rancid
 VMSnapshotId                  : 00000000-0000-0000-0000-000000000000
 VMSnapshotName                :
 CimSession                    : CimSession: .
 ComputerName                  : ERO-SRV-HOST02
 IsDeleted                     : False
 VMCheckpointId                : 00000000-0000-0000-0000-000000000000
 VMCheckpointName              :
    
    
 PS C:\export> $report.Incompatibilities | Format-Table -AutoSize
    
 Message                           MessageId Source
 -------                           --------- ------
 Virtual Hard Disk file not found.     40010 HardDiskDrive (Name = 'Hard Drive on IDE controller number 0 at location...
    
    
 PS C:\export>
windows-server-powershellwindows-server-hyper-v
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Doria avatar image
0 Votes"
Doria answered Doria commented

I don't understand. I exported the VM to the C:\export folder and at the time of import it fetches the VM HDD from the C:\VMs folder? What do you mean?!! The C:\VMs folder is set to the default folder where I position the new VMs created....

 Set-VMHost -VirtualMachinePath 'C:\VMs'
 Set-VMHost -VirtualHardDiskPath 'C:\VMs'
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Pass the -VhdSourcePath parameter as part of the import and set it to 'C:\export\Rancid\Virtual Hard Disk' and see if that gets Hyper-V to find the right HDD file.

1 Vote 1 ·

Done!

 PS C:\export> Import-VM -Path 'C:\export\Rancid\Virtual Machines\05262CA9-D444-44FE-ADF8-D364C6E0A1CA.vmcx' -Copy -GenerateNewId -VhdSourcePath 'C:\export\Rancid\Virtual Hard Disk'
    
 Name   State CPUUsage(%) MemoryAssigned(M) Uptime   Status             Version
 ----   ----- ----------- ----------------- ------   ------             -------
 Rancid Saved 0           0                 00:00:00 Operating normally 9.0

Thanks colldadtx! :-)

0 Votes 0 ·
cooldadtx avatar image
0 Votes"
cooldadtx answered

Based upon the error it cannot find the HDD file for the VM. Hyper-V, for whatever reason, allows you to store HDD images completely separate from the VM definition itself. Hence within the VM configuration file is a reference to the HDD that is located in a potentially completely different directory.

Open the VM configuration file and find the HDD reference. It contains the full path. If you're moving VMs then you need to adjust this value so it works in the new environment. In theory you could use a relative path but because Hyper-V doesn't assume anything about the path relationships I don't know if it'll like it or not.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Doria avatar image
0 Votes"
Doria answered cooldadtx commented

but the file is there?!! What file can I edit? .vmcx?


123969-image.png



image.png (68.3 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Post what the VM's configuration information for the HDD.

0 Votes 0 ·

Based upon your original post the VM is looking for the HDD in C:\VMs, not C:\export, hence it isn't finding it. Again, I believe VM configurations use absolute paths, not relative, because there is no relationship between VMs and HDDs in Hyper-V.

0 Votes 0 ·