Debian – How to script install of Virtualbox Guest Additions to a Vagrant Debian box

debianvagrantvirtualbox

I would like to make use of a vanilla Vagrant box for Debian (debian/jessie64), but automate the install of VirtualBox guest additions and enable using Virtualbox sharing for the /vagrant directory from the default of using rsync. I figure I can use Vagrant shell-based provisioning and tried installing dkms and virtualbox-guest-dkms from the contrib repository as I have read in some postings but this doesn't work. Can someone advise if this is possible and how?

Best Answer

There's a plugin you can install which checks for the presence of guest additions and installs if necessary when the box is provisioned: https://github.com/dotless-de/vagrant-vbguest/

To prevent Vagrant from using rsync use an empty type parameter in the config.vm.synced_folder

Here's the one I use:

config.vm.synced_folder "./", "/vagrant", id: "vagrant-root",
      owner: "vagrant",
      group: "www-data",
      mount_options: ["dmode=775,fmode=664"],
      type: ""
Related Question