Package vagrant box to location - 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.

Related

Vagrant box import on other device

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.

does "vagrant destroy" erase apache configs?

I'm new to vagrant, I'm using scotchbox.
I've configured a couple of vhosts in apache.
I guess the right way to do this would have been to change the provisionning of my box (as it's the aim of vaghrant right?) but i did the old school way by simpply editing my config files and so on...
Now my question is :
if i run vagrant destroy, do i loose all my configs?
is there any other command (vagrant halt, vagrant suspend?) that would allow me to reboot my host machine without loosing my config?
vagrant destroy will remove entire VM so any changes that were made manually will be lost. Vagrant halt only turns of the power so to speak so nothing is lost. If you run your machine again or reboot it all your data is save, just don't use --provision option that will recreate all initial configuration.

Edit files in a Virtualbox VM (vagrant box) from host

I was messing with systemd in my Vagrant box and I think I did something wrong since the box won't boot anymore. What I need to do is to remove certain files under /etc/systemd in my Vagrant box. However since I can't boot it, I have to remove those files from the host, but I don't know how to do it.
The VM provider is virtualbox. Both the host and the guest are ubuntu 15.04.
Thanks in advance!
option 1: you can try to add vagrant ssh -c 'cmd to run' in your vagrant file, but as you said it really does not boot, I give it really low chance to success.
option 2: create a new VM and add the hard drive from the old box to the new box (add new hard drive from existing disk), boot it and you might need to mount the new hard drive then you should be able to access your data so make the change in your /etc/systemd or whatever files you need and save. once you have made all your fix, you should be able to reboot from the old vm.
I ended up just creating a new VM but I'm fairly certain that this would work: you just mount the virtual disk file (.vmdk in my case) as a hard drive and make the fix. For different formats of virtual disks you need different tools to mount them, which I'm not going to cover here.

Is it possible to export/import a virtual box machine in one file?

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.

vagrant Temp files on windows

I'm using vagrant on windows. Stored in C:/Users/user.name/AppData/Local/Temp/ I have the following folders corresponding maybe to different instanciation of a my Virtual Box (1Gb each).
C:/Users/user.name/AppData/Local/Temp/vagrant-20130315-6356-1ptg2bm/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130315-6356-hg7lmy/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130315-8124-x3hd9e/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130315-8704-1j5rshk/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130318-8492-158p1us/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130318-9304-12usn7r/
C:/Users/user.name/AppData/Local/Temp/vagrant-20130320-6348-1cbn0vn/
As I'm using VirtualBox to run and save my last vagrant instance, I have no more recent folders and I doubt those are still relevant.
May I delete them without risk or how could I run them back from the command line to check if there would be something to save there ?
Thanks in advance
Assuming those are saved states / snapshots :
The safest bet is to move the files, then select "Discard save state" from VirtualBox.
Start up vagrant (power it up) and you'll probably be fine. If not, just point the VM back to the save states.

Resources