Empty /vagrant folder after I power off the VM - vagrant

I have a Vagrant VM using Virtualbox.
I have many files in my root folder which appear in /vagrant folder inside the VM.
When I power it off and restart it, the /vagrant folder is empty.
Why?

How are you powering the vm off and restarting?
It is vagrant who mounts that directory.
If you are doing that operations from VirtualBox directly it is not going to be mounted.

Related

how to get files from host machine to vagrant VM (MAC OS)

I haven't used vagrant for a while so I am racking my brains out on this one.
I know for a fact that one way to "exchange files" between the host machine and the vagrant VM is to copy any file you need into the host machine's vagrant folder that holds the Vagrantfile - the SAME folder where you run 'vagrant up' and 'vagrant ssh' to get connected to the /home/vagrant folder (indicating that you have entered the vagrant vm). However, when I get into the vagrant vm folder /home/vagrant I do not the files that I added in the host machine's vagrant folder.
I tried another approach by going in the vagrant vm's default folder /home/vagrant and run 'touch hello.txt'. Then I checked the host machine's vagrant folder using Finder and nope, I don't see hello.txt file either.
Appreciate any helpful inputs.
I finally found it...
Inside the Vagrantfile file, look for the following config setting:
config.vm.synced_folder
And mine's actually set as:
config.vm.synced_folder ".", "/vagrant"
When I gone back to check the /vagrant (NOT /home/vagrant) folder in my vagrant vm, there i found the files that I placed in my host machine's vagrant folder.
Although I wonder what the "." means - but in the meantime, I'm happy I found what I needed :)

Forgetting a VM in Vagrant

I've started a VM on Google Compute Engine using Vagrant with the vagrant-google provider. I no longer wish to control the VM using Vagrant, but I would like it to keep running without me interrupting it.
What's the proper way to have Vagrant "forget" about this machine?
so the instance has been installed on GCE and you can control directly from there.
Locally you can delete the .vagrant folder that vagrant created in the folder when you launch it
After this to remove references you can run vagrant global-status --prune which will remove invalid entries and clean vagrant conf file from this machine

Issues mounting a shared folder in virtualbox

I'm trying to create a shared folder between MacOS (Host) and Debian (Guest) in virtualbox. I've completed the steps of installing guest additions, creating a shared folder called "share" and a folder in debian called "sf", but when I try to run
sudo mount -t vboxsf share ~/sf
I get the error
mount: realpath /Users/USERNAME/sf: No such file or directory
I'm under the impression the second path is meant to be the directory in Debian. This also happens when I remove the ~/.
Looks like you are trying to run this command from your OSX shell. Is that possibly the case?
If yes, switch to your shell on the Debian guest. Also make sure the directory ~/sf actually does exist before you run the mount command.
Hope this helps.

Distributing vagrant VM locally

I have set up a vagrant vm on my machine. (Virtualbox)
I would like to be able to share this VM amongst other machines however would like to avoid having to download the image repeatedly.
I tried Exporting the Appliance and copying the Vagrantfile folder onto a different machine, however when i tried to connect using vagrant ssh it could not find it. I assume this is because of non-matching UUID's. How can I go around this?
Vagrant version 1.6.3
The solution was to use Vagrant Package
vagrant package --base <Name Of VM on virtualbox>
This creates a package.box file in your current directory.
You then share that package.box file, and on the new computers you execute:
vagrant init package.box
in the directory where the Vagrantfile will be created

Ubuntu guest can't see Vagrantfile in Window's host project directory

I just installed Vagrant 1.4.3 on Windows 7 64-bit and created an Ubuntu 13.10 (Saucy) box using the following:
vagrant box add saucy64-20140226 http://cloud-images.ubuntu.com/vagrant/saucy/20140226/saucy-server-cloudimg-amd64-vagrant-disk1.box
vagrant init saucy64-20140226
After doing:
vagrant up
I SSH'ed to the vagrant box using Putty. Up to this point is fine, but when I do:
$ ls
in the /vagrant directory (on the Guest), I do not see my 'Vagrantfile' or any other files from the Host machine.
Also, any files created in the Guest's /vagrant directory do not show up in the Host's synced directory.
I noticed the following when the box/vm was starting up:
[default] The guest additions on this VM do not match the installed
version of VirtualBox! In most cases this is fine, but in rare cases
it can prevent things such as shared folders from working properly. If
you see shared folder errors, please make sure the guest additions
within the virtual machine match the version of VirtualBox you have
installed on your host and reload your VM.
After researching a little more, found that the following solves the issue:
https://github.com/dotless-de/vagrant-vbguest
Here's a more detailed post:
http://kvz.io/blog/2013/01/16/vagrant-tip-keep-virtualbox-guest-additions-in-sync/
Thanks very much to the folks who created the 'vagrant-vbguest' Vagrant plugin!!!

Resources