I have executed following commands (on Windows, using Git Bash) in the directory D:\vagrant\precise32\02-lamp\
$ vagrant box add precise32 http://files.vagrantup.com/precise32.box
$ vagrant init precise32
$ vagrant up
Note. I haven't changed original Vagrantfile.
I thought the directory D:\vagrant\precise32\02-lamp\
would be the place of the VDI-like file but it is not. The working directory serves as the shared folder.
I found the location of the Vagrant box
C:\Users\USER\.vagrant.d\boxes\precise32\0\virtualbox
According to Where is Vagrant saving changes to the VM I found in the VirtualBox GUI the location of the Virtual hard drive file. Which is
C:\Users\USER\VirtualBox VMs\02-lamp_default_1458429875795_57100\
I would like to put this file not in the system drive C:\
but in the data drive which is D:\
.
How to set such vagrant configuration?
For VirtualBox, you can change the location of what is known as the Default Machine Folder through the GUI's Preferences dialog box.
This guide, while a couple of years old, works fine and I followed it last week for how to move an existing vagrant/VirtualBox drive to a new location.
EDIT
I have quoted the steps from the above link/guide, for posterity:
Move ~/.vagrant.d
to the external drive. I renamed it vagrant_home
so
I'd be able to see it without ls -a.
Set VAGRANT_HOME
to
/path/to/drive/vagrant_home
in ~/.bash_profile
.
Open the VirtualBox
app, open Preferences, and set its Default Machine Folder to
/path/to/drive/VirtualBox VMs
.
Close VirtualBox.
Move your
VirtualBox VMs
folder to the drive. Reopen VirtualBox. You'll see
your VMs are listed as "inaccessible". Remove them from the list.
For
each VM in your VirtualBox VMs
folder on the external drive, browse
to its folder in Finder and double-click the .vbox
file to restore it
to the VirtualBox Manager. (Is there an easier method than this?)
Finally, move any existing Vagrant directories you've made with
vagrant init
(these are the directories with a Vagrantfile
in each) to
the external drive. Since these directories only store metadata you
could leave them on your main drive, but it's nice to keep everything
together so you could fairly easily plug the whole drive into another
machine and start your VMs from there.
For each VM in your VirtualBox VMs folder on the external drive, browse to its folder in Finder and double-click the .vbox file to restore it to the VirtualBox Manager. (Is there an easier method than this?)
There is an easier way...
Go into the VirtualBox Manager GUI click Machine > Add and locate the .vbox you'd like to add back.