Skip to content

Repack box from existing one

Valentin Ivaşcu edited this page May 27, 2015 · 1 revision

Open https://atlas.hashicorp.com/boxes/search and choose a box.

I`m using PuPHPet Ubuntu 14.04 x64

  1. Open F:\servers\project-name and run vagrant init puphpet/ubuntu1404-x64 to create Vagrantfile

  2. Then run vagrant up --provider virtualbox to start to compile Virtual Machine

  3. SSH into vagrant to start customizing new box vagrant ssh

  4. Update and Upgrade server: sudo apt-get update && sudo apt-get upgrade -y --force-yes

  5. Install what you want ...

  6. Clean server:

sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove

  1. Then, “zero out” the drive (only for Ubuntu)
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
  1. Clear the Bash History and exit the Virtual Machine

cat /dev/null > ~/.bash_history && history -c && exit

  1. Repackage the Virtual Machine into a New Vagrant Box

vagrant package --output mynew.box

  1. Add box to your Vagrant

vagrant box add mynewbox mynew.box

This now will “download” the box into your Vagrant install allowing to initiate this from any folder, but before we do this, let’s delete and remove the Vagrant file we built this box from.

vagrant destroy
rm Vagrantfile
rm -rf .vagrant
  1. PuPHPet

In your puphpet/config.yaml box and box_url use mynewbox then init vagrant

vagrant up