Set VAGRANT_HOME env var, like:
VAGRANT_HOME=d:\srv\vagrant
Default is ~/.vagrant.d for Linux and %USERPROFILE%\.vagrant.d for Windows.
Set VBOX_MSI_INSTALL_PATH variable:
VBOX_MSI_INSTALL_PATH=c:\opt\VirtualBox
It is set/updated by VirtualBox installer and was VBOX_INSTALL_PATH before 4.3.12 (2014).
Use env var VAGRANT_VAGRANTFILE to control which Vagrantfile is to use:
VAGRANT_VAGRANTFILE=Vagrantfile-alpine vagrant status VAGRANT_VAGRANTFILE=Vagrantfile-debian vagrant status
Plugins are required to reconfigures when Vagrant version was updated:
vagrant plugin expunge --reinstall
and possibly:
vagrant plugin update
Vagrant VM name:
config.vm.define "NAME"
VirtualBox name:
config.vm.provider :virtualbox do |vb| vb.name = "NAME" end
Host name:
config.vm.hostname = "NAME"
https://unix.stackexchange.com/questions/176687/set-storage-size-on-creation-of-vm-virtualbox https://askubuntu.com/questions/317338/how-can-i-increase-disk-size-on-a-vagrant-vm https://stackoverflow.com/questions/49822594/vagrant-how-to-specify-the-disk-size https://github.com/sprotheroe/vagrant-disksize
Store new box from catalog locally:
$ vagrant box add ubuntu/trusty64 $ vagrant box add --provider virtualbox hashicorp/precise64
Check for box updates:
$ cd $BOXDIR $ vagrant box outdated
or:
$ vagrant box outdated --global
Disable checking for update each time you call vagrant command:
Vagrant.configure("2") do |config| config.vm.box_check_update = false end
Download box update:
$ vagrant box update
Note
vagrant box update does not magicall updates your existing boxes. In just download updated versions. To install new versio you need to destroy and install new boxes:
$ vagrant destroy $ vagrant up
To remove box at specific version:
$ vagrant box remove laravel/homestead --box-version 1.1.0
To get list of boxes with corresponding versions:
$ vagrant box list $ vagrant global-status
Any VirtualBox VM can be packages as Vagrant box. Find VM name or UUID with:
$ VBoxManage list vms
Pass it to one of:
$ vagrant package --base $VM_NAME $ vagrant package --base $VM_UUID $ vagrant package --base $VM_NAME --output my.box $ vagrant package --base $VM_UUID --output my.box
If you are in Vagrant managed directory (with .vagrant subdirectory) it is as simple as:
$ vagrant package
Note
Only one VM is packages even if Vagrant file defines several VMs.
Import packages box:
$ vagrant box add --name $NAME /path/to/new.box ... $ vagrant init $NAME ... $ vagrant up
To export box from local catalog:
$ vagrant box list $ vagrant box repackage NAME PROVIDER VERSION
Add environment variable:
VAGRANT_LOG=warn vagrant ssh VAGRANT_LOG=info vagrant ssh VAGRANT_LOG=debug vagrant ssh
or option:
vagrant up --debug
To add timestamps use one of:
VAGRANT_LOG_TIMESTAMP=1 vagrant up vagrant up --timestamp
To add both as option:
vagrant up --debug-timestamp
You may give name to provisioning script:
Vagrant.configure("2") do |config| config.vm.provision 'user_ssh', type: :shell, privileged: false do |s| ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip s.inline = "echo #{ssh_pub_key} >> /home/$USER/.ssh/authorized_keys" end config.vm.provision 'root_ssh', type: :shell, privileged: true do |s| ssh_pub_key = File.readlines("#{Dir.home}/.ssh/id_rsa.pub").first.strip s.inline = "mkdir /root/.ssh/; echo #{ssh_pub_key} >> /root/.ssh/authorized_keys" end ... end
and apply them individually:
vagrant provision --provision-with user_ssh vagrant provision --provision-with root_ssh vagrant provision --provision-with user_ssh,root_ssh
To copy files recursively to running box:
vagrant upload $SRC $DST vagrant upload $SRC $DST $BOXID
To copy to /home/vagrant:
vagrant upload $SRC . vagrant upload $SRC . $BOXID
To copy to /home/vagrant/$DIR:
vagrant upload $SRC $DIR vagrant upload $SRC $DIR $BOXID
There is 3rd patry option with:
vagrant plugin install vagrant-scp vagrant scp $SRC :$DST vagrant scp $SRC $BOXID:$DST
Install plugin:
$ vagrant plugin install vagrant-alpine Installing the 'vagrant-alpine' plugin. This can take a few minutes... Installed the plugin 'vagrant-alpine (0.3.0)'!
Create Vagrantfile:
$ vagrant init maier/alpine-3.6-x86_64