After building a Vagrant base box, Vagrant and Virtual Box updates incurred lots of upgrades. This article gives a recipe to do that quickly and efficiently.

Build a new environment

mkdir /tmp/upgrade
cd /tmp/upgrade
vagrant init squeeze64
vagrant up
vagrant halt

At that point the VM is stoped. Launch it from the Virtual Box GUI and mount the guest tools (Host+D).

Upgrade

Log into the VM through vagrant:

vagrant ssh

Upgrade the OS and the tools:

sudo aptitude update
sudo aptitude dist-upgrade
sudo mount /dev/scd0 /mnt
sudo aptitude install build-essential linux-headers-$(uname -r)
sudo /mnt/VBoxLinuxAdditions.run 
sudo rm -rf /usr/src/vboxguest*
# insert whatever other upgrades you may need to do here.
sudo aptitude purge build-essential linux-headers-$(uname -r)
sudo aptitude clean
sudo init 1

Clean up

Re-log through the console and execute:

rm -r /var/cache/*/*
mount -o remount,ro /dev/sda1
zerofree /dev/sda1
halt

Package the VM:

cd /tmp/upgrade
vagrant package
vagrant box remove squeeze64
vagrant box add squeeze64 /tmp/upgrade/package.box

Destroy the upgrade environment:

cd /tmp/upgrade
vagrant destroy

Update (10/12/2011): The base box has been updated to Virtual Box Guest Additions v4.1.4 and the latest Debian Squeeze updates.

Update (12/02/2011): The base box has been updated to Virtual Box Guest Additions v4.1.6 and the latest Debian Squeeze updates.

Update (02/08/2012): The base box has been updated to Virtual Box Guest Additions v4.1.8 and the latest Debian Squeeze updates.

Update (03/25/2012): The base box has been updated to Virtual Box Guest Additions v4.1.10, and chef 0.10.8 and the latest Debian Squeeze updates.

Update (04/04/2012): The base box has been updated to Virtual Box Guest Additions v4.1.12 and the latest Debian Squeeze updates.

Update (29/04/2012): The package has been updated to the latest Debian Squeeze updates and the nfs-common package was installed.

Update (05/08/2012): The base box has been updated to Virtual Box Guest Additions v4.1.14 and the latest Debian Squeeze updates.