Skip to content

Instantly share code, notes, and snippets.

@cbrunnkvist
Created September 13, 2011 10:09
Show Gist options
  • Save cbrunnkvist/1213528 to your computer and use it in GitHub Desktop.
Save cbrunnkvist/1213528 to your computer and use it in GitHub Desktop.
Upgrading VirtualBox Guest Additions inside a running Vagrant box
#!/bin/sh
# For simplicity's sake I dump this file in the project folder and execute
# it from the VM straight out of /vagrant -> could run as part of box/basebox buildout.
alias apt-get="sudo apt-get"
alias mount="sudo mount"
alias umount="sudo umount"
# Oh. Start by making .vbox_version contain the desired version string.
VBOX_VERSION=$(cat /home/vagrant/.vbox_version)
cd /tmp
apt-get -y install linux-headers-$(uname -r)
wget http://download.virtualbox.org/virtualbox/$VBOX_VERSION/VBoxGuestAdditions_$VBOX_VERSION.iso
mount -o loop VBoxGuestAdditions_$VBOX_VERSION.iso /mnt
sh /mnt/VBoxLinuxAdditions.run
umount /mnt
rm VBoxGuestAdditions_$VBOX_VERSION.iso
# Remove items used for building, since they aren't needed anymore
apt-get -y remove linux-headers-$(uname -r)
apt-get -y autoremove
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment