Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is Vagrant saving changes to the VM?

Tags:

vagrant

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?

like image 388
Tree Avatar asked Nov 22 '11 11:11

Tree


People also ask

Where does vagrant store its files?

By default, Vagrant stores its boxes after downloading in the directory defined by VAGRANT_HOME environment variable. As a result, On Mac OS X and Linux: ~/. vagrant.

How do I save changes to vagrant box?

Luckily this is really easy too. Just fire up your Vagrant box, SSH onto it, make your changes, then exit the SSH session. From your Vagrant root folder: Package up your vagrant instance.

How do I access vagrant files?

When you do 'vagrant ssh' you are not in the '/vagrant' directory but in /home/vagrant directory. Now run 'ls /vagrant'. You will see the VagrantFile in the directory. This is the same VagrantFile that is on your actual host machine.


1 Answers

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. 
like image 121
pyfunc Avatar answered Oct 03 '22 23:10

pyfunc