What happens to the .box file after the following command is executed?
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
I can't find the lucid32.box
file on the file system after download has completed.
As mentioned in the docs, boxes are stored at:
~/.vagrant.d/boxes
C:/Users/USERNAME/.vagrant.d/boxes
To change the Path, you can set a new Path to an Enviroment-Variable named: VAGRANT_HOME
export VAGRANT_HOME=my/new/path/goes/here/
Thats maybe nice if you want to have those vagrant-Images on another HDD.
More Information here in the Documentations: http://docs.vagrantup.com/v2/other/environmental-variables.html
The actual .box
file is deleted by Vagrant once the download and box installation is complete. As mentioned in other answers, whilst downloading, the .box file is stored as:
~/.vagrant.d/tmp/boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
where the file name is 'box' followed by a 40 byte hexadecimal hash. A temporary file on my system for example, is:
~/.vagrant.d/tmp/boxc74a85fe4af3197a744851517c6af4d4959db77f
As far as I can tell, this file is never saved with a *.box
extension, which explains why the searches above failed to locate it. There are two ways to retrieve the actual box file:
Download the .box file from vagrantcloud.com
vagrantcloud.com
. So https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box./providers/virtualbox.box
to the end of that URL. So https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1 becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.boxconfig.vm.box_url
to the URL. ORGet the .box directly from Vagrant
This requires you to modify the ruby source to prevent Vagrant from deleting the box after successful download.
/Applications/Vagrant/embedded/gems/gems/vagrant-1.5.2/lib/vagrant/action/builtin/box_add.rb
box_add
function, there is a block that reads:
ensure # Make sure we delete the temporary file after we add it, # unless we were interrupted, in which case we keep it around # so we can resume the download later. if !@download_interrupted @logger.debug("Deleting temporary box: #{box_url}") begin box_url.delete if box_url rescue Errno::ENOENT # Not a big deal, the temp file may not actually exist end end
vagrant add box <boxname>
.~/.vagrant.d/tmp/
directory as a boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
file. mv boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX trusty64.box
.For me, this has been useful to retrieve the .box file so it can be hosted on local, fast infrastructure as opposed to downloading from HashiCorp's Atlas box catalog or another box provider.
This really should be part of the default Vagrant functionality as it has a very definitive use case.
@Luke Peterson: There's a simpler way to get .box file.
Just go to https://atlas.hashicorp.com/boxes/search, search for the box you'd like to download. Notice the URL of the box, e.g:
https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
Then you can download this box using URL like this:
https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box
I tried and successfully download all the boxes I need. Hope that help.
On Windows 10 with Vagrant 2.2.2, setting the environment variable VAGRANT_HOME
will ensure that boxes are downloaded to a subfolder of the folder specified for VAGRANT_HOME
.
In my case I set VAGRANT_HOME
to e:\vagrant_home
, and the boxes get stored under e:\vagrant_home\boxes
.
This works for me.
That's where the boxes are stored. The virtual machines are being created in the folder configured in Virtual Box. To set the VirtualBox VM storage folder, go to: VirtualBox GUI --> File --> Preferences --> General --> Default Machine Folder
.
sudo find / -name lucid32.box
. – irrational Johnlucid32.box
using this exact command... – Calvin Cheng*.box
maybe? (BTW, wouldn't the extension be.vbox
?) – irrational John*.vbox
andnot *.box
. Mystery solved. :-) Would you like to key in an answer so I could accept it? Thx! – Calvin Cheng