vagrant up failed on Hyper-v. Powershell error 0x80070005

Created on 21 Aug 2017  ยท  11Comments  ยท  Source: hashicorp/vagrant

Vagrant version

Vagrant 1.9.7

Host operating system

Windows 10 Enterprise

Guest operating system

Centos 7.3.1611

Vagrantfile

Vagrant.configure("2") do |config|
    config.vm.box = "my-box"
end

Debug output

https://gist.github.com/reputet/c311c2eba869d8f0681e1269ede2f75d

Expected behavior

After executing vagrant up --provision hyperv virtual machine should be started.

Actual behavior

An error appears that references to the Powershell in the depth.

$ vagrant up --provider hyperv
Bringing machine 'default' up with 'hyperv' provider...
==> default: Verifying Hyper-V is enabled...
==> default: Importing a Hyper-V instance
    default: Cloning virtual hard drive...
    default: Creating and registering the VM...
An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Import-VM : 'centos-7-1-1.x86_64_1_1' failed to realize. (Virtual machine ID A1BBF2FD-1634-4C42-877A-F8923B0A3278)
Failed to access configuration store: General access denied error (0x80070005).
At C:\HashiCorp\Vagrant\embedded\gems\gems\vagrant-1.9.7\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:154 char:1
+ Import-VM -CompatibilityReport $vmConfig
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : PermissionDenied: (:) [Import-VM], VirtualizationException
    + FullyQualifiedErrorId : AccessDenied,Microsoft.HyperV.PowerShell.Commands.ImportVM

See additional information in the debug file above.

Steps to reproduce

  1. Initializing of VM
vagrant init centos/7
vagrant up --provider hyperv
vagrant halt
  1. Export box without changing using this manual:
    https://www.vagrantup.com/docs/hyperv/boxes.html#packaging-the-box
    There was added metadata.json with content below:
{
  "provider": "virtualbox"
}
  1. Adding box to vagrant:
    vagrant box add my-box --name my-box

  2. Changing Vagrantfile:

Vagrant.configure("2") do |config|
    config.vm.box = "my-box"
end
  1. Starting vm:
    vagrant up --provider hyperv

References

providehyperv

Most helpful comment

same problem as @schippie after update my vagrant to 2.0.1 on windows 10 and trying to use homestead

All 11 comments

I had this issue and the problem was that I was trying to run vagrant in a samba share directory on Windows. This worked with VirtualBox, but not with hyperv for some reason. My guess is that hyperv doesn't have access to those folders...

I am also encountering this issue.
Windows Host, running hyperv, vagrant version 1.9.3 & 2.0.0
The only work around I have found is to replace the vmcx configuration with xml.
This appears to be a bug in the import_vm_vmcx.ps1 script
This means that hyperv is completely broken, because there is no longer a way to export xml configurations from hyperv

Host
-Windows 10 64bit
Guest Operating system
-Ubuntu 16.04.3

There is clearly a problem with the VirtualMachinePath parameter that is being passed via the import_vm_vmcx.ps1 script.
These seems to be related to cygwin paths and windows permissions.
I did test the command with a regular windows path and it succeeded.
Can someone please investigate?

````
PS H:> $vmConfg = Compare-VM -Copy -GenerateNewID -Path 'C:\Users\jason.grammenos\.vagrant.d\boxes\ubuntu1604\0\hyperv\Virtual Machines\AD494459-E412-4E21-9F9F-6B01D43BD10E.vmcx' -VhdDestinationPath 'C:cygwin64homejason.grammen
oswebteam_devweb_devhyper-v.vagrantmachineswebhook1hypervVirtual Hard Disks' -VirtualMachinePath 'C:cygwin64ho
mejason.grammenoswebteam_devweb_devhyper-v.vagrantmachineswebhook1hyperv'
PS H:> Import-VM -CompatibilityReport $vmConfg
Import-VM : 'basebox1604' failed to realize. (Virtual machine ID 3C633476-FA2B-4360-99A6-04BB1440911C)
Failed to access configuration store: General access denied error (0x80070005).
At line:1 char:1

  • Import-VM -CompatibilityReport $vmConfg
  • ~~~~~~~~~~~

    • CategoryInfo : PermissionDenied: (:) [Import-VM], VirtualizationException

    • FullyQualifiedErrorId : AccessDenied,Microsoft.HyperV.PowerShell.Commands.ImportVM

PS H:> $vmConfg = Compare-VM -Copy -GenerateNewID -Path 'C:\Users\jason.grammenos\.vagrant.d\boxes\ubuntu1604\0\
hyperv\Virtual Machines\AD494459-E412-4E21-9F9F-6B01D43BD10E.vmcx' -VhdDestinationPath 'C:cygwin64homejason.grammen
oswebteam_devweb_devhyper-v.vagrantmachineswebhook1hypervVirtual Hard Disks'
PS H:> Import-VM -CompatibilityReport $vmConfg

Name State CPUUsage(%) MemoryAssigned(M) Uptime Status Version
---- ----- ----------- ----------------- ------ ------ -------
basebox1604 Off 0 0 00:00:00 Operating normally 8.0

PS H:> $vmConfg = Compare-VM -Copy -GenerateNewID -Path 'C:\Users\jason.grammenos\.vagrant.d\boxes\ubuntu1604\0\
hyperv\Virtual Machines\AD494459-E412-4E21-9F9F-6B01D43BD10E.vmcx' -VirtualMachinePath 'C:cygwin64homejason.grammen
oswebteam_devweb_devhyper-v.vagrantmachineswebhook1hyperv'
PS H:> Import-VM -CompatibilityReport $vmConfg
Import-VM : 'basebox1604' failed to realize. (Virtual machine ID D4B9C0AF-0DCB-4117-AD42-67818558BF8F)
Failed to access configuration store: General access denied error (0x80070005).
At line:1 char:1

  • Import-VM -CompatibilityReport $vmConfg
  • ~~~~~~~~~~~

    • CategoryInfo : PermissionDenied: (:) [Import-VM], VirtualizationException

    • FullyQualifiedErrorId : AccessDenied,Microsoft.HyperV.PowerShell.Commands.ImportVM

      ````

I'm running into the exact same error, trying to create a virtual hard drive on an external hard drive of mine. Within docker environments it is possible (but docker within docker for windows has a setting where I can specify the shared drives, my assumption is that vagrant doesn't share certain drives for it's VM when using HyperV)

An error occurred while executing a PowerShell script. This error
is shown below. Please read the error message and see if this is
a configuration error with your system. If it is not, then please
report a bug.

Script: import_vm_vmcx.ps1
Error:

Compare-VM : Failed to create the virtual hard disk.
The system failed to create 'G:\<<path>>\vagrant\.vagrant\machines\database\hyperv\Virtual Hard Disks\se5u05co.ohs.vhdx'.
At B:\ProgramFiles\Vagrant\embedded\gems\gems\vagrant-2.0.0\plugins\providers\hyperv\scripts\import_vm_vmcx.ps1:33 char:14
+ $vmConfig = (Compare-VM -Copy -GenerateNewID @VmProperties)
+              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Compare-VM], VirtualizationException
    + FullyQualifiedErrorId : OperationFailed,Microsoft.HyperV.PowerShell.Commands.CompareVM

Yeah, I ran into this issue and had to reload my entire ~/.vagrant.d for my user then VMs started working. I moved it to a different directory and re-imported all my boxes.

Nevermind, I'm getting this only on new boxes built with a newer packer maybe?

I'm thinking this is a permission issue as I've rebuilt the boxes using the latest packer on my system that I'm using vagrant on and it's working... I could publish the busted box and the good box if someone wants to see if they can reproduce the error.

same problem as @schippie after update my vagrant to 2.0.1 on windows 10 and trying to use homestead

I had this problem when trying to create (vagrant init / vagrant up) a Hyper-V machine on my external (D:) drive. This seems to be a result of permissions causing trouble. The default permissons of an external drive are essentially wide open. To narrow the permissions to something that is known to work, I used my existing user folder as a template:

# Get the permissions from my User folder (could use $env:USERPROFILE instead of ~ if you're feeling verbose.)
$objAcl = Get-Acl -Path ~

# Create the new directory and set permissions
mkdir D:\test | Set-Acl -AclObject $objAcl

Then I can do vagrant init / vagrant up in that folder and it works.

This is definitely a permission problem.

It works as expected in vagrant 2.0.3 in Windows 10 Pro, when you have at least set "Administrators" as the owner of the folder, its subfolders, and running the shell or commands as (or with rights as) Administrator:

~/projects/vagrant-hyperv-test
$ ls -alt
total 5
drwxr-xr-x+ 1 hebh           xxxxxxx  0 Mar 29 08:21 ..
drwxr-xr-x+ 1 Administrators xxxxxxx  0 Mar 28 20:01 .
-rwxr-xr-x  1 Administrators xxxxxxx 81 Mar 28 20:01 Vagrantfile
drwxr-xr-x+ 1 Administrators xxxxxxx  0 Mar 28 19:44 .vagrant

Hi! I'm going to close this up as #9944 resolves the issue. An access check is now included before a guest is brought up with the Hyper-V provider. When using an alternate location (like a different drive (D:\MyProjects) or cygwin home (C:\cygwin64\home\USERNAME) the failure to access configuration store is encountered. This can be fixed by giving SYSTEM access to the directories and allowing the permission to be inherited:

icacls.exe D:\MyProjects /T /Q /grant "NT AUTHORITY\SYSTEM:(IO)(CI)(F)"

Cheers!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings