Vagrant boxes are the package format for Vagrant environments. There are a lot of boxes, but in some cases you need customize your box. You can automatize your bootstrap with a script or chef, but the virtual machine start up consume time. To reduce the bootstrap time, you can create your own custom box.

Once you have started and installed your virtual machine, you can create your own box following the next steps:

  1. Create a new vm from a base box
  vagrant init basebox
  vagrant up
  1. Customize you virtual machine

  2. Clean the box

  sudo apt-get clean
  sudo dd if=/dev/zero of=/EMPTY bs=1M
  sudo rm -f /EMPTY
  cat /dev/null > ~/.bash_history && history -c && exit
  1. Package de virtual machine to a new vagrant box
  vagrant package --output
  1. Add the new box to your vagrant install
  vagrant box add boxname
  1. Destroy de virtual machine
  vagrant destroy
  rm Vagrantfile
  1. Configure the nex box in your Vagrantfile
  vagrant init boxname

Edit the Vagrantfile and configure it.

  1. Start up the virtual machine
  vagrant up


-- 2015-11-04 --

With vagrant 1.7.4, I have had problems to authenticate to the box with private/public keys. To resolve this issues, I have configured the authentication with username/password.

  config.ssh.username = 'vagrant'
  config.ssh.password = 'vagrant'