How to move the Vagrant environment?

0

"vagrant init: ...a Vagrant environment by creating an initial Vagrantfile..."

I moved that folder from E:/ to C:/ in windows, and I'm having this silly error when trying to do a vagrant snapshot restore XXX

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

Command: ["startvm", "7aff8d5d-7193-4f6d-966b-4076543c0e90", "--type", "headless"]

Stderr: VBoxManage.exe: error: RawFile#0 failed to create the raw output file E:/Proyectos/do-sf2-dev/ubuntu-xenial-16.04-cloudimg-console.log (VERR_PATH_NOT_FOUND)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

From I understand, VirtualBox keeps referencing the E:/ drive.

I tried manually editing any references from E:/ to C:/ I can find under that folder, and also in the VirtualBox GUI for the concerning machine but no luck.

windows
vagrant
virtualbox
vagrantfile
asked on Stack Overflow Dec 3, 2018 by Decimoseptimo

1 Answer

1

This answer is late but will hopefully help the next person to encounter this issue. The error is because the machine is configured to output to a location that doesn't exist anymore. When moving a Vagrant environment to another drive you'll need to update some Vagrant metadata in addition to moving the VM files. You can use vagrant up --debug to see exactly what the error is referring to.

If you move the .vagrant.d directory you'll need to set the environment variable VAGRANT_HOME to its new location. On windows you need to restart for this to take effect. If that doesn't work add one of the following to your vagrantfile:

  • v.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
    • This disables serial output to the missing log file (ubuntu-xenial-16.04-cloudimg-console.log)

or

  • v.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-xenial-16.04-cloudimg-console.log") ]
    • This updates the path of the log file to point to the current directory.

For most vagrant setups this should be enough , however, I also needed to re-create the path to the erring log file before vagrant up would work successfully. After that I ran vagrant provision and was able to delete the old file path without issues.

These posts were also helpful (References):

answered on Stack Overflow Mar 21, 2019 by anOkCoder

User contributions licensed under CC BY-SA 3.0