Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Everywhere I look I read that a vagrant box is just a base "template" which vagrant builds off of. And that once you run "vagrant up" it actually creates a copy of the vagrant box so it should be safe to delete the box file once you run vagrant up and you'll still be able to use that virtual machine.

However this doesn't seem to work in practice. I have a base box called ~/.vagrant.d/boxes/precise32 and I created a vagrant file with that box name in the file and ran vagrant up. Now when I rename the file to ~/.vagrant.d/boxes/precise32.old and try to run "vagrant up" again I get an error:

* The box 'precise32' could not be found.

So it appears that the base box is not a template but in fact the live disk image that needs to be kept around. So why does all the documentation say otherwise, e.g. http://docs-v1.vagrantup.com/v1/docs/getting-started/boxes.html

"Each project uses the box as a base only, so once the project VM is created, modifications can be made without affecting other projects which may use the same box."
share|improve this question

2 Answers 2

Once a box is removed, no new virtual machines based on that box can be created, since it is completely deleted off the filesystem, but existing virtual machines which have already been spun up will continue to function properly.

Running vagrant up again is creating a new machine from the box (template). Deleting the box would cause vagrant up to fail.

If your environment is already running since you did an up in a previous step, just run vagrant reload, which will quickly restart your VM, skipping the import step.

You should be able to run vagrant reload.

share|improve this answer

Vagrant creates new VirtualBox Machines with the fist run of

vagrant up

by importing a Box file, which is basically a packed version of a VBox Machine. Vagrant extracts this archive in the "boxes" folder under the Vagrant directory in your Home.

Vagrant uses the extracted information to build the VM Base and overlays this with an additional layer for the actual VM filesystem to form the usable VM.

You can replicate this behaviour by creating VMs with shared Storages, where the first VM acts as the Base "Template". Create a Snapshot after the configuration is done and setup the other VMs to use this Snapshot for storage. Every new VM created with this scheme inherits the base system and settings, but changes are stored seperate as an overlay to the initial Snapshot.

To conclude for now, you can delete the original Box files after the import, but not the extracted information, because they act as the original Snapshot.

For more information on the file format look here: http://docs.vagrantup.com/v2/boxes/format.html

And for creating Boxes see the VeeWee project.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.