Creating a Debian Wheezy Base Box for Vagrant
Mike GriffinI have been playing around with Vagrant so that I can set up a VM to do some dev work on instead of trying to keep a number of computers in sync. I have a debian testing VPS that I use to host some sites so I wanted the VM to match that. I couldn’t find a base box out in the big bad internet, so I decided to build my own and use that.
I started off by downloading the Debian Wheezy NetInstall CD. This meant that I didn’t have to go through an upgrade process after I installed Debian.
Install Debian
I installed VirtualBox and Vagrant and set about my task.
- Create a new virtual machine and called it
wheezy32
- Accept all the defaults and then disable Audio and USB
- Add the netinst ISO image as a CD and boot the virtual machine
- Select your language and territory (I chose English and Ireland)
- Select your keymap (I chose Irish)
- Set your hostname (vagrant-debian-wheezy)
- Set the domain name (vagrantup.com)
- Set the root password (vagrant)
- Set up a user (vagrant with vagrant as the password too)
- Follow the defaults to set up the disk, all one partition
The base system gets installed then before you are asked for your archive mirror location and any proxy settings you have. The installer then goes off and downloads the source list for the system before asking if you want to take part in the package usage survey. I usually say no.
Deselect all tasks except “Standard system utilities” and continute to allow the system to install the required packages.
Next the installer asks about GRUB. Just take all the defaults and install it to the root of the drive.
After this is done, it’s time to reboot the virtual machine.
Install some packages
Log in as root
Add the vagrant user to sudo
Add the following to /etc/sudoers
Shrink the box size
Step back down to single user mode by typing
and enter the root password. Then run zerofree to zero out any free space on the disk
This will chug away for a couple of minutes before returning and then you can halt the virtual machine.
Make up the box
Create a folder for the box to live and change into it. Then run
This leaves you with a file called package.box
which you can add into vagrant by running
Now you can use the box as any other one in vagrant.