Ubuntu – Unable to install VBoxGuestAdditions 5.1.0 on Ubuntu 14.04

vagrantvirtualbox

After downloading the following iso VBoxGuestAdditions_5.1.0.iso
based on the following documentation https://www.vagrantup.com/docs/virtualbox/boxes.html

and then running the following commands

sudo mkdir /media/VBoxGuestAdditions
sudo mount -o loop,ro VBoxGuestAdditions_5.1.0.iso /media/VBoxGuestAdditions
sudo sh /media/VBoxGuestAdditions/VBoxLinuxAdditions.run

I receive and error:

Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.

When I review this log, it refers to another log file /var/log/vboxadd-install.log. When I review this log, I see the following:

make KBUILD_VERBOSE=1 CONFIG_MODULE_SIG= -C /lib/modules/3.13.0-93-generic/build SUBDIRS=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j2 modules
make[1]: Makefile: No such file or directory
make[1]: warning: -jN forced in submake: disabling jobserver mode.
make[1]: *** No rule to make target `Makefile'.  Stop.
make: *** [vboxguest] Error 2
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

I have the following packages installed. I even removed them and added them again:
linux-headers-$(uname -r) linux-generic linux-image-generic linux-headers-generic linux-signed-generic dkms build-essential

I am not certain how to debug this further. Any assistance to the problem would be appreciated.

In addition, I then attempted to use the Guest addition CD that is included with Virtual Box. Upon entering the CD and accepting the installation, the following occurs
Upon inserting the Guest Additions CD, I receive the following error:

Verifying archive integrity... All good.  
Uncompressing VirtualBox 5.1.4 Guest Additions for Linux...........
VirtualBox Guest Additions installer
Removing installed version 4.3.20 of VirtualBox Guest Additions...
Copying additional installer modules ...
Installing additional modules ...
vboxadd.sh: Building Guest Additions kernel modules.
Failed to set up service vboxadd, please check the log file
/var/log/VBoxGuestAdditions.log for details.
Press Return to close this window...

I then proceed to review the file /var/log/VBoxGuestAdditions.log, and this is what it indicates:

vboxadd.sh: failed: Look at /var/log/vboxadd-install.log to find out what went wrong.
vboxadd.sh: failed: Please check that you have gcc, make, the header files for your Linux kernel and possibly perl installed..

I then proceed to open /var/log/vboxadd-install.log and I see the following:

/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=<directory> and run Make again.  Stop.
Creating user for the Guest Additions.
Creating udev rule for the Guest Additions kernel module.

This places the system in a bad state with no way to recover except for starting over with the image.

Best Answer

it seems that there were some prerequisites you did not fulfill something like: apt-get install build-essential module-assistant linux-headers-$(uname -r)

it worked for me.