Vagrant: Vagrant up renames virtual machine directory

Created on 9 Jun 2013  ยท  11Comments  ยท  Source: hashicorp/vagrant

In Windows (8 64-bit), using 'vagrant up' sometimes causes the VirtualBox VM to get renamed, including the directory the VM resides in. This is different from the normal behavior of VirtualBox GUI and VBoxManage.

Steps to reproduce:
vagrant init
vagrant up
vagrant halt

Open Windows file explorer and identify the folder for this vagrant box (the VirtualBox VM). From VirtualBox GUI, you can right-click the instance and select 'Show in Explorer').

Using the following, identify the correct vm_id for the current vagrant box:
"\Program Files\Oracle\VirtualBox\VBoxManage.exe" list vms

Use VBoxManage to control the vagrant box:
\Program Files\Oracle\VirtualBox\VBoxManage.exe" startvm <vm_id>
\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm <vm_id> poweroff

At this point, the VM _has not changed names_, nor has the VM folder name changed.

vagrant up
This will either issue an error (for instance, if File Explorer has the folder open):
_There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["modifyvm", "d471d855-b779-4f9f-8efd-3d6e5a829fa5", "--name", ""]
Stderr: VBoxManage.exe: error: Could not rename the directory 'C:\Users\user\VirtualBox VMs' to 'C:\Users\user\VirtualBox VMs' to save the settings file (VERR
_ACCESS_DENIED)_

Or, this will _rename_ the VM and host folder.

It may be that anything else that is using that folder (Windows file explorer, for example), will inhibit renaming. But it's noteworthy that VBoxManage does not rename the VM instance.

Most helpful comment

I noticed on each up, Vagrant is "Setting the name of the VM..."

This is setting name to nil:

https://github.com/mitchellh/vagrant/blob/a53d569656a75776bac3081e50d22f5c9e018941/plugins/providers/virtualbox/action/set_name.rb#L13

Explicitly setting the the name in the Vagrantfile solves it:

  config.vm.provider :virtualbox do |vb|
      vb.name = "something"
  end

All 11 comments

A few comments, in case these steps don't reproduce it for you. I've encountered this before when trying to _move an existing Vagrant box to a new computer_ (there's no notes in the Vagrant documentation about that, but it's a fairly common scenario -- changing laptops, re-imaging OS, etc.).

Also, my current host machine has two partitions, one for the Windows OS and one for data files. I have installed _some_ program files on the data partition (that of itself is not a problem, the programs run fine). But it might be significant that _Vagrant is installed on the data partition_ whereas VirtualBox is installed on the OS partition, and the VM is created on the OS partition. I'm not sure the particular arrangement matters, but perhaps it's possible that Vagrant isn't accounting for different partitions (drive letters), and so isn't calling VBoxManage with the correct path.

Hi, I have solved it by running the repair option of my vagrant.msi installer, after doing a full reboot too.

I noticed on each up, Vagrant is "Setting the name of the VM..."

This is setting name to nil:

https://github.com/mitchellh/vagrant/blob/a53d569656a75776bac3081e50d22f5c9e018941/plugins/providers/virtualbox/action/set_name.rb#L13

Explicitly setting the the name in the Vagrantfile solves it:

  config.vm.provider :virtualbox do |vb|
      vb.name = "something"
  end

@xofer's comment makes sense to me. That is potentially the correct fix, not just a work-around. Can it be set to whatever it currently is, then, before launching each time? I haven't dug into the code myself, but can try at some point.

More steps to reproduce:

  1. Download Microsoft VPC for IE testing (not direct download link: http://www.modern.ie/en-us/virtualization-tools#downloads).
  2. import VPC into VirtualBox, boot first time.
  3. Use Ubuntu live CD to _re-partition the VPC hard drive_. Shrink single partition (say, 20gb) and add a second ntfs partition. Reboot virtual machine.
  4. install Vagrant and VirtualBox inside the virtual machine
  5. Open Command prompt, _switch to new partition_ (d: or e:, depending on existing CD drive I guess)
  6. run vagrant init precise32 http://files.vagrantup.com/precise32.box. Open widows File Explorer, find the virtual machine directory (_on c: drive_: something like C:\Documents and Settings\IEUser\VirtualBox VMs\_default_1234567890). Navigate _out of the VM directory_ (just up to C:\Documents and Settings\IEUser\VirtualBox VMs\, probably)
  7. vagrant halt
  8. vagrant up. Look at the VM directory.

In my case, this produces, for steps 6 and 8 respectively, the folders: _default_1375651092 and _default_1375651676.

That is, _vagrant changed the VM directory name_ just with a 'up, halt, up' sequence.

Fixed. The default name will only be set on first up. Of course, if you change the vm.name setting in VirtualBox settings in the Vagrantfile, it will be set on the next reload.

I got this problem (using 1.3.3) after moving vagrant files within my project. I opened up virtualbox and noticed it made a new instance with a random name. deleted both the old (before moving the files around) and the new. Now seems to boot fine again.

The error:

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'precise32'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2222 (adapter 1)
[default] -- 80 => 8080 (adapter 1)
[default] -- 9090 => 9090 (adapter 1)
[default] Running 'pre-boot' VM customizations...
A customization command failed:

["modifyvm", "81a6eca6-4fff-4f54-ace8-b86edd56b349", "--name", "Infinitas"]

The following error was experienced:

VBoxManage: error: Could not rename the directory '/home/dogmatic69/VirtualBox VMs/vagrant_default_1380708640' to '/home/dogmatic69/VirtualBox VMs/Infinitas' to save the settings file (VERR_ALREADY_EXISTS)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "SaveSettings()" at line 2527 of file VBoxManageModifyVM.cpp


Please fix this customization and try again.

5 years passed and still problem exists

@naumoff I do not see this behavior exhibited in the current version of Vagrant. If you are currently experiencing this problem with the latest version of Vagrant, please create a new issue and provide the details requested.

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

Related issues

RobertSwirsky picture RobertSwirsky  ยท  3Comments

lebogan picture lebogan  ยท  3Comments

jazzfog picture jazzfog  ยท  3Comments

janw-me picture janw-me  ยท  3Comments

StefanScherer picture StefanScherer  ยท  3Comments