I have a Vagrant box which is using the Scotch box environment. I have had an other PC and I didn't have any provisioning because I did everything manually ssh into the box.
The question, how can I take this from my first PC to my second PC? I looked the vagrant snapshot command, but I think it is'nt what I want, because it's just take a save about the box current state, but don't save the whole environment to deploy it to another PC.
Edit:
I am using VirtualBox provider.
what you can do is repackage the current VM built on this box as a new box.
once you repackage the box, it will create a new .box file of your VM with all the changes you've made and you can copy this file to your second PC, add as a new box in your vagrant and spin a new VM from this box. All the changes you have made on the box from the first PC will be available.
Related
I have tried installing latest versions of VirtualBox and Vagrant, but I keep receiving the error message below when trying to run vagrant. How can I find the problem and correct it?
No usable default provider could be found for your system.
Vagrant relies on interactions with 3rd party systems, known as
"providers", to provide Vagrant with resources to run development
environments. Examples are VirtualBox, VMware, Hyper-V.
The easiest solution to this message is to install VirtualBox, which
is available for free on all major platforms.
If you believe you already have a provider available, make sure it
is properly installed and configured. You can see more details about
why a particular provider isn't working by forcing usage with
`vagrant up --provider=PROVIDER`, which should give you a more specific
error message for that particular provider.
Be sure to install VirtualBox first, since Vagrant depends on it.
-Download and install VirtualBox
-Download and install Vagrant
-Adjust VirtualBox and Vagrant
The next step is to make some tweaks to VirtualBox and Vagrant. We need to do this because, by default, both tools store data in the same drive where they were installed (tipically the C drive). The thing with virtual machines is they can take up a lot of space, so they can eat up your main drive’s storage very quickly.
First we’ll change the storage path in Virtual Box, since it’s pretty straightforward. You now should have a program called Oracle VM VirtualBox installed. Open it and then go to File > Preferences. A
new dialog will open where you can change the folder next to the option that reads Default Machine Folder. Click the dropdown and choose Other…. Here you can choose the new folder for VirtualBox to store data.
Now we’ll do the same for Vagrant.
By default the path where data related to virtual machines is
stored is C:\Users\YourUser\.vagrant.d so I recommend changing it to a different drive. This can be done with environment variables. We need to create a variable called VAGRANT_HOME and point it to our desired location.
Open the control panel and search for the word environment. From the results choose the one that says edit environment variables for your account.
On the new dialog that appears, click the New… button.
Here you will create the new variable. Enter VAGRANT_HOME as the value for the field named Variable name.
For the field named Variable value enter the path of your choice. In my case I used C:\VM\Vagrant
I want to package a box file to a location as my disk is nearly full, does anyone know how to accomplish this.
I am running the vagrant package command
If you want to save space on your disk and you do not need to delete/recreate the VM, you can simply delete the box.
Indeed when running vagrant up, vagrant clones the current box file as the VM and do not need it afterwards. even if you delete the base box, vagrant will continue working as normal. Only in case you need to delete your VM and recreate and provision as a new VM, you will need the base box again.
I have some projects in Laravel, and when I have to give some maintenance to them, sometimes when I run vagrant up, it warns me up that I have a newer version of the laravel box, homestead, like the message below:
A newer version of the box 'laravel/homestead' is available! You currently
have version '1.1.0'. The latest is version '2.0.0'. Run
`vagrant box update` to update.
My question is, always when I run vagrant box update, it tooks like a decade to download the newer version of the box, because it seems like the hashicorp's servers are not too good enough to handle...
Having that in mind, can I give maintenance to my project while putting the machine up, and in parallel, also update the box? I really don't understand if that's really possible, or how could this impact the things.
Thank you very much, I hope to ask a question other users also have.
Having that in mind, can I give maintenance to my project while putting the machine up, and in parallel, also update the box?
Yes - you can start your current VM running vagrant up and in parallel update the existing box vagrant box update (You can even do that from any folder, in this case point to the box to be updated vagrant box update --box laravel/homestead)
Note that the box is used to create the VM when you first spin up (vagrant is basically cloning the box to create a new VM) so if you update the box, it will not affect your current VM
As mentioned by others, if you want your VM to reflect the update of the box (3rd party software for example), then yes you need to destroy the VM and recreate the VM (running vagrant up)
No, you can't update running machines.. Simply update command downloads the new image .. So if you really have to update a machine ( running or not ) you have to destroy it.
Check vagrant versioning documentation for more details
I have a Vagrant set up with 3 virtual machines. Each machine has its own shell script for provisioning.
Now I would like to share the exact same status of my set up with somebody else. Since the provisioning procedure takes really (!!) long for each machine, I hope there is another solution.
Ideally I would be able to save each machine as it is in one file, which the other person then could import into Virtualbox. Is there a way to do that?
If I understand you correctly you would like to make a Vagrant base box from provisioned by Vagrant VMs. This is not recommended way to go. How you can approach this is:
Create new VM manually with required OS in the VBox.
Adjust it so Vagrant can connect to it as described here and here.
Provision it using your shell scripts.
Install all the things you would find useful to have on this VM.
Use Vagrant to package it as a base box as described here.
After packaging it with Vagrant you will get a Vagrant base box file with .box extension. You can then pass this to your team mates (usb, network share, ftp etc.) and they can add it to their Vagrant installation and use it. Whenever they will do Vagrant up they will get fully provisioned VM in VBox with all the stuff you have packaged to it. Vagrant also gives you versioning capabilities. If properly configured whenever you will create new version of base box everybody who is using it will be notified and would be able to download and use new version of your box.
Hope I understood your problem correctly and this will help to solve it.
I like how through vagrant I can spin up my machine, configure it and get to coding. However when I do vagrant halt, and then do a vagrant up again, it rebuilds my machine from the base box. All the new stuff I installed, my project repository is gone.
I can see that the virtual machine still exists in virtual box and I can use it from there, but I want to use vagrant to manage it and access it while keep the persistence of the disk as I would accessing it directly from virtual box. My host is windows, my guest is precise64.
Thoughts?
Stephen
Maybe you want to use vagrant suspend? (via)