103
votes

I am just starting with Vagrant and I am having a little trouble understanding a few details. I have read through the docs but still am missing a basic concept. When I want to start a Vagrant box I run:

vagrant up

This will "build the VM based on the box" I understand that the boxes are stored at ~/.vagrant.d and in fact I have packaged up my own box from a base Ubuntu box. However, when I run vagrant up and start to add files to the vm, where is the virtual hard drive for the vm stored? For example, when I run apt-get install apache2 and the root system is modified, where is this modified?

When I do a du on my current directory I do not see any changes. I also do not see any changes in the ~/.vagrant.d directory. However, I can do vagrant halt, restart my local machine and then run vagrant up again and the changes are persisted somewhere.

vagrant up also reports

[default] VM already created. Booting if its not already running...

Can someone tell me where the VM is created and where the changes are made?

2

2 Answers

114
votes

Vagrant imports the base box which is located at ~/.vagrant.d/boxes/, like you said. This is where the base boxes are kept. It uses it to start a VM from the clean state. When importing a VM, the responsibility of where to store data files and VM state is up to VirtualBox itself. This is a configurable location but typically defaults to ~/VirtualBox\ VMS for Mac OS X and Linux. In Windows the boxes are kept in %userprofile%\.vagrant.d\boxes

It is easy to find the place where they are getting created, regardless of what platform you happen to be using.

1. Start VirtualBox. 
2. Go to the VM that shows as running instance. 
3. Check out the Settings ->Storage. 
4. You can find the path to location where VMs are created and stored in your file system.
4
votes

I always change the directory that Virtualbox uses by default for VMs. Normally it is in your profile folder in Windows.

I change it to something like "D:\VHDs\VBox\" and there I found my vagrant test vm: "test01_1347456065". It was called test01, so I guess vagrant adds the numbers to keep things unique.