Upgrading Homestead to VirtualBox 5

... and making sure the right Guest Additions are used!

Reasoning 

As with everything, we need to make a consious decision when we do things. In this case a VirtualBox Guest Additions mismatch has severe performance implications and in my case has halted the synchronizing between Vagrant and OS/X.

Installation 

Requirements 

  • Homestead 2
  • VirtualBox 5 (5.0.0 or greater)
  • Vagrant 1.7.4 (or greater)

Procedure 

  1. Let's get the latest version of Vagrant (1.7.4 as of this writing) and install as usual.
  2. Then download and install the latest version of VirtualBox (5.0.0 as of this writing).
  3. Now for the tricky bit: upgrading VirtualBox Guest Additions. Let’s SSH into Homestead:
    homestead ssh
  4. Remove any existing packages that would interfere with the installation (just in case).
    sudo apt-get remove dkms build-essential linux-headers-
    sudo rm -rf /opt/VBoxGuestAdditions-
  5. Now lets install the new replacements for them:
    sudo apt-get install dkms build-essential linux-headers-$(uname -r)
  6. Great! We have the system prepped, and ready to install the new Guest Additions. In my example I am using the 5.0.0 version, but make sure you use the version that matches your VirtualBox:
    wget http://download.virtualbox.org/virtualbox/5.0.0/VBoxGuestAdditions_5.0.0.iso
  7. Create a mount point for the ISO, then mount it:
    sudo mkdir /media/VBoxGuestAdditions
    sudo mount -o loop,ro VBoxGuestAdditions_5.0.0.iso /media/VBoxGuestAdditions
  8. Now we can finally install the Guest Additions:
    sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run
  9. Once this completes successfully, we can clean up:
    sudo umount /media/VBoxGuestAdditions
    sudo rm -rf /media/VBoxGuestAdditions
    rm VBoxGuestAdditions_*.iso
  10. Exit out of Homestead, and restart it:
    exit
    homestead halt && homestead up

And we can now rejoice not seeing a Guest Addition version warning! Mission accomplished. Now pat yourself on the back, and get back to work already! 😄

Notes 

This process also fixes instances of the following error that may be encountered while running homestead up:

==> default: Mounting shared folders…
default: /vagrant => /Users/mike/.composer/vendor/laravel/homestead
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
The error output from the last command was:
mount: wrong fs type, bad option, bad superblock on vagrant,
missing codepage or helper program, or other error
In some cases useful info is found in syslog — try
dmesg | tail or so.