How do I install VirtualBox guest additions for CentOS 7?

vagrant init centos/7
vagrant up; vagrant halt
  • Add a CDROM to the virtual machine and select the VBoxGuestAdditions.iso file to insert in the drive.

virtual box guest additions

  • Manually add a shared folder in VirtualBox with name vagrant and path to the directory of your Vagrantfile. Vagrant doesn't set up /vagrant properly.

virtualbox shared folder

  • Edit Vagrantfile and add this to the bottom to provision the shared folder each time you start.

    config.vm.provision "shell", run: "always", inline: <<-SHELL
        mount -t vboxsf -o uid=`id -u vagrant`,gid=`id -g vagrant` vagrant /vagrant
    SHELL
    
  • Continue with

    vagrant up
    vagrant ssh
    sudo yum update
    sudo yum install kernel-devel gcc
    exit
    vagrant halt; vagrant up; vagrant ssh
    export KERN_DIR=/usr/src/kernels/`uname -r`
    sudo mount /dev/sr0/ /mnt
    cd /mnt
    sudo ./VBoxLinuxAdditions.run