Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
How to update VirtualBox Guest Additions with vagrant
# Start the old vagrant
$ vagrant init centos-6.3
$ vagrant up
# You should see a message like:
# [default] The guest additions on this VM do not match the install version of
# VirtualBox! This may cause things such as forwarded ports, shared
# folders, and more to not work properly. If any of those things fail on
# this machine, please update the guest additions and repackage the
# box.
# Guest Additions Version: 4.1.18
# VirtualBox Version: 4.2.8
$ vagrant ssh
vagrantup:~$ sudo yum -y update
vagrantup:~$ cd /opt
vagrantup:~$ sudo wget -c \
-O VBoxGuestAdditions_4.2.8.iso
vagrantup:~$ sudo mount VBoxGuestAdditions_4.2.8.iso -o loop /mnt
vagrantup:~$ cd /mnt
vagrantup:~$ sudo sh --nox11
vagrantup:~$ cd /opt
vagrantup:~$ sudo rm *.iso
vagrantup:~$ sudo /etc/init.d/vboxadd setup
vagrantup:~$ sudo chkconfig --add vboxadd
vagrantup:~$ sudo chkconfig vboxadd on
vagrantup:~$ exit
# Now check that the Guest Additions work
$ vagrant halt
$ vagrant up
# Package the new VM
$ vagrant halt
$ vagrant package
$ mv

epzee commented Nov 15, 2013

Thanks for the gist! One question: aren't line 22 and line 25 doing the same thing?

zbal commented Dec 5, 2013


Updated for Ubuntu 13.10 -- due to some bug that require VBox 4.3 and Ubuntu ships the vagrant box with 4.2.16

Thanks! This is exactly what I needed!

You might consider using the vbguest-plugin:

wylee commented Jul 2, 2015

I think @epzee is right: line 25 (sudo /etc/init.d/vboxadd setup) doesn't seem necessary since the installer already removes the old kernel module and builds the new one.

Theaxiom commented Sep 5, 2015

Make sure you do this before you shut down: echo "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" > .ssh/authorized_keys

Perfect :)

krutcha commented Feb 5, 2016

This does not seem to work for me, perhaps I am doing it wrong. I used a basebox (precise32), then uninstalled the guest additions, installed the kernel headers, dkms, etc, and latest guest additions (5.0.10). I then ran the guest additions. After exiting and halting, I did a vagrant package. When I deploy this new .box (vagrant box add, vagrant init, vagrant up).. it has the OLD guest additions it seems every time. Is there something special needed to make the modified additions stick in a 'package'?

shovon commented Feb 11, 2016

@krutcha this guide is for CentOS, not Ubuntu.

Thanks for that tip.It worked like charm!
Saved me many hours of investigation.

Hi guys, I'm sorry I'm pretty late to this party.

I have two apparent issues with Vagrant: the guest additions not matching and the NFS mount error. When I run Vagrant Up/Reload I get this...

Mathews-MacBook-Pro:ansible mathewthomas$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Removing hosts
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160323.0.0'. The latest is version '20160509.1.0'. Run
==> default: `vagrant box update` to update.
==> default: VirtualBox VM is already running.
Mathews-MacBook-Pro:ansible mathewthomas$ vagrant reload
==> default: Removing hosts
==> default: Attempting graceful shutdown of VM...
==> default: Checking if box 'ubuntu/trusty64' is up to date...
==> default: A newer version of the box 'ubuntu/trusty64' is available! You currently
==> default: have version '20160323.0.0'. The latest is version '20160509.1.0'. Run
==> default: `vagrant box update` to update.
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address:
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    **default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: Guest Additions Version: 4.3.36
    default: VirtualBox Version: 5.0**
==> default: Checking for host entries
==> default: Skipping adding host entries ( hostsupdater: "skip" is set)
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
==> default: Mounting NFS shared folders...
**The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o 'vers=3,udp''/Users/mathewthomas/Sites/eightloop/site' /
Stdout from the command:

Stderr from the command:

mount.nfs: requested NFS version or transport protocol is not supported**

I have been having trouble for a few days. Do you think these isses could be related?



I just ran 'vagrant ssh', 'apt-get update', and 'apt-get install nfs-common nfs-kernel-server'.

Ran like a dream.

Sorry to bother you, cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment