- Published on
Vagrant Tip: Sync VirtualBox Guest Additions
- Authors

- Name
- Kevin van Zonneveld
- @kvz
Quick tip. If you lose your Vagrant mounts after kernel upgrades in your virtualbox, you'll need to reinstall your VirtualBox Guest Additions. Same is true when you upgrade Vagrant, etc.
It's just a real pain and people usually avoid it by never upgrading. Or delve in once they accidentally do. But there's actually a nice & automated way of keeping your VM's guest additions in sync with virtualbox.
I was fed up with missing mountpoints and messages like these:
$ vagrant up
[default] Importing base box 'ubuntu-12.04-64bit'...
[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.22
VirtualBox Version: 4.2.6
So, Vbguest plugin to the rescue!
To install, you type this one time in the directory that
also keeps your Vagrantfile:
$ # For vagrant < 1.1.5:
$ # vagrant gem install vagrant-vbguest
$ # For vagrant 1.1.5+ (thanks Lars Haugseth):
$ vagrant plugin install vagrant-vbguest
On successful execution, the output should look something like this:
Fetching: micromachine-1.0.4.gem (100%)
Fetching: vagrant-vbguest-0.6.4.gem (100%)
Successfully installed micromachine-1.0.4
Successfully installed vagrant-vbguest-0.6.4
2 gems installed
Installing ri documentation for micromachine-1.0.4...
Installing ri documentation for vagrant-vbguest-0.6.4...
Installing RDoc documentation for micromachine-1.0.4...
Installing RDoc documentation for vagrant-vbguest-0.6.4...
And that's it. From now on every vagrant up will check & install
the correct guest additions right after booting:
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] GuestAdditions 4.2.6 running --- OK.
And if it's outdated, here's what happens:
$ vagrant up
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
[default] GuestAdditions versions on your host (4.2.10) and guest (4.2.6) do not match.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
linux-headers-3.2.0-23-generic is already the newest version.
dkms is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 126 not upgraded.
[default] Copy iso file /Applications/VirtualBox.app/Contents/MacOS/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: warning: /mnt seems to be mounted read-only.
[default] Installing Virtualbox Guest Additions 4.2.10 - guest version is 4.2.6
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.2.10 Guest Additions for Linux..........
VirtualBox Guest Additions installer
Removing installed version 4.2.6 of VirtualBox Guest Additions...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used
Tight! :)
Legacy Comments (60)
These comments were imported from the previous blog system (Disqus).
Excellent! Thanks!
I tried using this plugin, but it failed to install the additions properly: http://paste.jaraco.com/BPnL8
Looks like it did install the module though, so upon next reboot it should not try to do it again and you'll have the latest guest additions.
In the current version of Vagrant (1.1.5), the correct command for installing the plugin is:
$ vagrant plugin install vagrant-vbguest
Thanks Lars, I'm updating the post as we speak!
This didn't work for me. After vagrant up I get the following output: http://pastebin.com/z8AJgXaa
The versions don't match, it tries to install a lower version, then those guest additions are not running, then something went wrong.
The contents of /var/log/vboxadd-install.log can be found here: http://pastebin.com/ZkWAvUKc
Did I make some kind of obvious mistake?
I updated virtualbox and the problem went away :)
You, sir, are a lifesaver. I've rebuilt this test box of mine several times trying to fix this (it works on the first boot!) before discovering that this was the actual cause. I was trying to figure out how to update the guest additions, but this is perfect!
Seems to not work for me. I get an error:
An error occurred during installation of VirtualBox Guest Additions 4.2.12. Some functionality may not work as intended
Here is the output when doing vagrant up for the first time, then after that the output after doing a vagrant halt and another vagrant up.
% vagrant up 13-07-30 - 11:57:26
Bringing machine 'default' up with 'virtualbox' provider...
[default] Importing base box 'ubuntu12.04'...
[default] Matching MAC address for NAT networking...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Available bridged network interfaces:
1) eth0
2) eth1
3) lxcbr0
What interface should the network bridge to? 1
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
GuestAdditions versions on your host (4.2.12) and guest (4.1.18) do not match.
stdin: is not a tty
Reading package lists...
Building dependency tree...
Reading state information...
dkms is already the newest version.
linux-headers-3.2.0-23-generic is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Copy iso file /usr/share/virtualbox/VBoxGuestAdditions.iso into the box /tmp/VBoxGuestAdditions.iso
stdin: is not a tty
mount: warning: /mnt seems to be mounted read-only.
Installing Virtualbox Guest Additions 4.2.12 - guest version is 4.1.18
stdin: is not a tty
Verifying archive integrity... All good.
Uncompressing VirtualBox 4.2.12 Guest Additions for Linux............
VirtualBox Guest Additions installer
Removing installed version 4.1.18 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
You should restart your guest to make sure the new modules are actually used
Installing the Window System drivers ...fail!
(Could not find the X.Org or XFree86 Window System.)
An error occurred during installation of VirtualBox Guest Additions 4.2.12. Some functionality may not work as intended
stdin: is not a tty
Restarting VM to apply changes...
[default] Attempting graceful shutdown of VM...
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
GuestAdditions 4.2.12 running --- OK.
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
craig@pjoe:~/Boxes/edi
% vagrant --version 13-07-30 - 12:00:47
Vagrant version 1.2.2
craig@pjoe:~/Boxes/edi
% vagrant halt 13-07-30 - 12:00:52
[default] Attempting graceful shutdown of VM...
craig@pjoe:~/Boxes/edi
% vagrant up 13-07-30 - 12:02:13
Bringing machine 'default' up with 'virtualbox' provider...
[default] Setting the name of the VM...
[default] Clearing any previously set forwarded ports...
[default] Fixed port collision for 22 => 2222. Now on port 2200.
[default] Creating shared folders metadata...
[default] Clearing any previously set network interfaces...
[default] Available bridged network interfaces:
1) eth0
2) eth1
3) lxcbr0
What interface should the network bridge to? 1
[default] Preparing network interfaces based on configuration...
[default] Forwarding ports...
[default] -- 22 => 2200 (adapter 1)
[default] Booting VM...
[default] Waiting for VM to boot. This can take a few minutes.
[default] VM booted and ready for use!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.1.18
VBoxService inside the vm claims: 4.2.12
Going on, assuming VBoxService is correct...
GuestAdditions seems to be installed (4.2.12) correctly, but not running.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.1.18
VBoxService inside the vm claims: 4.2.12
Going on, assuming VBoxService is correct...
stdin: is not a tty
Starting the VirtualBox Guest Additions ...done.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.1.18
VBoxService inside the vm claims: 4.2.12
Going on, assuming VBoxService is correct...
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.1.18
VBoxService inside the vm claims: 4.2.12
Going on, assuming VBoxService is correct...
[default] The guest additions on this VM do not match the installed version of
VirtualBox! In most cases this is fine, but in rare cases it can
cause things such as shared folders to not work properly. If you see
shared folder errors, please update the guest additions within the
virtual machine and reload your VM.
Guest Additions Version: 4.1.18
VirtualBox Version: 4.2
[default] Configuring and enabling network interfaces...
[default] Mounting shared folders...
[default] -- /vagrant
This post really help me. I'm using ubuntu host and ubuntu precise box.
Very helpful. Thank you for sharing.
This saved my day. Thanks for the tip!
You really save my day. I think it's tutorial must be in here http://docs.vagrantup.com/v...
This post could't help me.
There is my tutorial:
Host: windows
Guest: Ubuntu
You should mount cd-rom with VBoxGuestAdditions.iso (you can find this in Program Files/Oracle/VirtualBox directory.
After this you have to log in to ubuntu and type this:
mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom
sudo sh ./VBoxLinuxAdditions.run
Thank you, thank you, thank you!!
This plugin really saved my day!!
Worked without problems for me (OS X host, Ubuntu guest). Thanks Kevin! I was really getting annoyed with that mismatch message (that's how I found your post). :)
thanks!
Very nice post. cheers!
Amazing, thanks a lot!
Thanks a lot, saved my day
Not working for me
GuestAdditions 4.3.10 running --- OK.
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Applications/MAMP/htdocs/project
Failed to mount folders in Linux guest. This is usually because
the "vboxsf" file system is not available. Please verify that
the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /vagrant /vagrant
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /vagrant /vagrant
Have you found a solution?
Nope, no yet, and I dunno why, Its said GuestAdditions running ok after upgrade, but mounting virtual files keep failing.
Issue appears resolved for Virtualbox Guest Additions 4.3.12.
Guest is Ubuntu 12.04 LTS (precise32 3.2.0-64-generic-pae), dist-upgraded today from base box "precise32".
Hi. You might actually be running into this bug http://stackoverflow.com/qu...
Thanks a lot mate!! Worked like a charm! :-)
Nice plugin! Only had one error while trying it: "Installing the Window System drivers. Could not find the X.Org or XFree86 Window System, skipping. An error occurred during installation of VirtualBox Guest Additions 4.3.10. Some functionality may not work as intended. In most cases it is OK that the "Window System drivers" installation failed."
Then the following error came up:
Failed to mount folders in Linux guest. This is usually because the "vboxsf" file system is not available. Please verify that the guest additions are properly installed in the guest and
can work properly. The command attempted was:
mount -t vboxsf -o uid=`id -u vagrant`,gid=`getent group vagrant | cut -d: -f3` /var/www /var/www
mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` /var/www /var/www
This is HEAVILY discussed on a Vagrant/GitHub issue https://github.com/mitchell...
Hi.. you might actually be running into this bug http://stackoverflow.com/qu...
Nope, not really. My avatar is the left one on the solution as I already went over it and edited the MarkUp on the fly :)
http://stackoverflow.com/a/...
I referenced the GitHub issue as all the people over there actually ran into that issue after running your "vagrant-vbguest" plugin.
thanks a lot. the output was not what you have shown but it works. They say all well that ends well so thank you again.
Thanks!! Very useful, worked like a charm!
awesome...Thanks for the rescue
$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/vagrant/embedded/bin/ruby extconf.rb
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_copy': Bad file descriptor (Errno::EBADF)
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_dup'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `dup'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `<module:logging>'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:289:in `<module:makemakefile>'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:47:in `<top (required)="">'
from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /Users/7stud/.vagrant.d/gems/gems/json-1.8.2 for inspection.
Results logged to /Users/7stud/.vagrant.d/gems/gems/json-1.8.2/ext/json/ext/generator/gem_make.out
~/vagrant_getting_started$ gem install json -v '1.8.2'
Fetching: json-1.8.2.gem (100%)
Building native extensions. This could take a while...
Successfully installed json-1.8.2
1 gem installed
~/vagrant_getting_started$ vagrant plugin install vagrant-vbguest
Installing the 'vagrant-vbguest' plugin. This can take a few minutes...
Bundler, the underlying system Vagrant uses to install plugins,
reported an error. The error is shown below. These errors are usually
caused by misconfigured plugin installations or transient network
issues. The error from Bundler is:
An error occurred while installing json (1.8.2), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.2'` succeeds before bundling.
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/opt/vagrant/embedded/bin/ruby extconf.rb
/opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_copy': Bad file descriptor (Errno::EBADF)
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `initialize_dup'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `dup'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:292:in `<module:logging>'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:289:in `<module:makemakefile>'
from /opt/vagrant/embedded/lib/ruby/2.0.0/mkmf.rb:47:in `<top (required)="">'
from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /opt/vagrant/embedded/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from extconf.rb:1:in `<main>'
Gem files will remain installed in /Users/7stud/.vagrant.d/gems/gems/json-1.8.2 for inspection.
Results logged to /Users/7stud/.vagrant.d/gems/gems/json-1.8.2/ext/json/ext/generator/gem_make.out
Thanks, that made my morning.
Thank you for providing us this! :)
Whoaw, This one saved my day. Finally I can get rid of these messages regarding inconsistent guest addition versions. Worked like a charm. Thanks a lot for sharing :-)
This worked great for me! Thanks so much for your time effort and talent!!! I owe you beer!
Awesome. Thanks!
GuestAdditions malfunctioned after a Centos 7 guest vm system update and this command fixed it. Thanks!
$ sudo vagrant plugin install vagrant-vbguest
Mine just printed: Installed the plugin 'vagrant-vbguest (0.11.0)'!
Works a treat!
Not working for me either! It gives the error that there is a space in my directory name and that ruby doesn't get that. I looked in all my maps and there isn't a space anywhere!
is there a way to upgrade the vbguest on host so that it doesn't download everytime i launch a new guest machine?
Thanks, you save my life!
It is better to configure the problem by yourself..and I believe it is much easier, read http://blog.kriptonium.com/... if you need guideline
Thanks for this, Kevin. Worked for me.
Thanks! Kevin
Works like a charm, many thanks!
Thanks a lot!
Thanks. works like a charm with v5.0.24
Working perfectly! You saved me! THANKS! :D
At first moment I thought that something went wrong because after install I still got the message about mismatched versions, but then I rebooted my vagrant server and this time got OK message :).
Work great for me. Thanks so much for sharing!!
I have a macOS Sierra host and ubuntu 12.04 64bit guest. The virtualbox vm can get *really* slow sometimes. According to 'top' (on either the host or guest) neither cpu nor memory are the issue. I'm not quite sure how to interpret iotop, but I'm not seeing anything obvious.
Here's what I see on vagrant up:
Machine booted and ready!
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.2.0
VBoxService inside the vm claims: 5.1.14
Going on, assuming VBoxService is correct...
[default] GuestAdditions 5.1.14 running --- OK.
Got different reports about installed GuestAdditions version:
Virtualbox on your host claims: 4.2.0
VBoxService inside the vm claims: 5.1.14
Going on, assuming VBoxService is correct...
==> 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:
default: Guest Additions Version: 4.2.0
default: VirtualBox Version: 5.1
==> default: Mounting shared folders...
I could care less if it the version mismatch was a minor or patch release, but this is a major version mismatch! I re-installed vagrant-vbguest, but no change. Any idea what's going on? How would I know if shared folder errors are occuring (other than the obvious not being mounted)?
Thank you so much
This is super dope, thanks! Works like charm on MacOSSierra - scotch/box