sprotheroe / vagrant-disksize

Vagrant plugin to resize disks in VirtualBox
MIT License
479 stars 52 forks source link

Windows WSL error: VBoxManage.exe: error: Could not create the directory 'C:\WINDOWS\system32\C:\VMs\ubuntu-xenial-16.04-cloudimg-20180413' (VERR_INVALID_NAME) #20

Open JLofgren opened 6 years ago

JLofgren commented 6 years ago

Summary

Plugin fails with a path error when used in WSL.

Environment

Vagrant 2.0.1 VirtualBox 5.2.8 Windows 10 WSL with Ubuntu 16.04

Steps to reproduce

-Install Windows WSL with Ubuntu 16.04. Install vagrant therein. Setup is described here. -vagrant init ubuntu/xenial -use the disksize plugin in the VagrantFile

config.disksize.size = '20GB'

-vagrant up

Expected Behavior

Will successfully set the size of the disk.

Actual Behavior

==> default: Running 'pre-boot' VM customizations...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["clonemedium", "C:\\VMs\\ubuntu-xenial-16.04-cloudimg-20180413\\ubuntu-xenial-16.04-cloudimg.vmdk", "./C:\\VMs\\ubuntu-xenial-16.04-cloudimg-20180413\\ubuntu-xenial-16.04-cloudimg.vdi", "--format", "VDI"]

Stderr: 0%...
Progress state: VBOX_E_IPRT_ERROR
VBoxManage.exe: error: Failed to clone medium
VBoxManage.exe: error: Could not create the directory 'C:\WINDOWS\system32\C:\VMs\ubuntu-xenial-16.04-cloudimg-20180413' (VERR_INVALID_NAME)
VBoxManage.exe: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component VirtualBoxWrap, interface IVirtualBox
VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCloneMedium(struct HandlerArg *)" at line 990 of file VBoxManageDisk.cpp
BuhtigithuB commented 6 years ago

I had this clone error while trying to manually convert vdi box to vmdk box, but I was supplying --variant ESX parameter... Which in the command display above passed from vagrant assuming there is nothing else occuring behind the scene is not the case...

In my case and base on what is discussed here :

https://apple.stackexchange.com/questions/271561/which-vboxmanage-clonehd-variant-corresponds-to-the-gui-selection-dynamically

I remove the --variant switch from the command and it clone successefully afterward...

Maybe not related, but it migth help finding the issue...

BuhtigithuB commented 6 years ago

Here I think it was mention : https://www.virtualbox.org/ticket/9673

Sorry

JLofgren commented 6 years ago

@BuhtigithuB Thanks, but pretty sure that is unrelated. The error I got is clearly a path issue: C:\WINDOWS\system32\C:\VMs\ubuntu-xenial-16.04-cloudimg-20180413 is clearly not a valid path. It looks to me like the plugin is making some assumptions about the environment that it is working in, and those assumptions don't align with the WSL.

lotherk commented 5 years ago

@JLofgren I've managed to make it work. It is a dirty fix and doesn't clean up the old disk. https://github.com/sprotheroe/vagrant-disksize/compare/master...lotherk:fix_wsl_dst_file I currently don't have time to improve it but may be a starting point for someone else to write an actual fix.

henning-erlandsen commented 5 years ago

Hi! Bumped into this issue as well. Made this fix that worked for me locally https://github.com/sprotheroe/vagrant-disksize/pull/27

cdausmus commented 3 years ago

Any chance we can get a new release cut with this included?

AsharLohmar commented 3 years ago

I'm not good with Ruby, even less with pull-requests, but here's my alternative solution:

# actions.rb
        def generate_resizable_disk(disk)
          src = "" + disk[:file]
          src_extn = File.extname(src)
          dst = src.delete_suffix!(src_extn) + '.vdi'
          disk.merge({ uuid: "(undefined)", file: dst })
        end