VirtualBox Guest Additions installation problem [duplicate]

I am having a problem trying to install the guest additions for my ubuntu 18.04 and virtualbox 5.2.12
I thought I did something wrong so I tried to install the additions from the CLI, unistalled and installed dkms... I even deleted the virtual machine and installed ubuntu again and it has the same error.
Can anyone help please as I did not find an updated solution to my problem. Here is the message i get when trying to install the addons:

Verifying archive integrity... All good.
Uncompressing VirtualBox 5.2.12 Guest Additions for Linux........
VirtualBox Guest Additions installer
Copying additional installer modules ...
Installing additional modules ...
VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules.
This system is currently not set up to build kernel modules.
Please install the gcc make perl packages from your distribution.
VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted
VirtualBox Guest Additions: Starting.
Press Return to close this window...

In terminal...

sudo apt-get update
sudo apt-get install build-essential gcc make perl dkms
reboot

then reinstall the VB Guest Additions.

Update:

  • purge virtualbox-guest-dkms
  • purge virtualbox-5.2 and any other virtualbox softwares
  • ls -al /lib/modules/$(uname -r)/updates/dkms and look for any leftover virtualbox kernel drivers. These need to be manually deleted.
  • dpkg -l *virtualbox* and dkms status should show no virtualbox software
  • install virtualbox-5.2 and create your VM
  • in the VM, choose the Devices menu, then "Insert Guest Additions CD Image"
  • it'll ask if you wish to install the Guest Additions
  • Note: if it doesn't automatically ask to install Guest Additions, you have to do it manually.
    • find the CD icon, on your desktop, or in Files, and open it
    • open a terminal in this directory
    • sudo ./VBoxLinuxAdditions.run

I had the same problem on Lubuntu 18.04. I had to follow the steps in heynnema's answer, but also had to install dkms. Then I reinstalled Guest Additions (mine is 5.2.12) from the disk image and it worked after a reboot. All that was left was setting up permissions for shared folders, but that's another story.

So basically:

  1. Open your terminal
  2. sudo apt-get install build-essential gcc make perl dkms
  3. reboot
  4. Open your terminal
  5. Go to the installation disk
  6. sudo sh VBoxLinuxAdditions.run
  7. reboot

This was done on a fresh Lubuntu 18.04 install.


I had similar issues. (Host: windows / Guest: Lubuntu 18.04)

Solution was simple: I had to update my Virtual Box Installation to the newest one (V5.2.22)

After updating the Virtual Box (in my host), the installtion of the virtualbox addons (in guest) worked without any problems.


As heynnema said, you will need gcc make and perl to build the kernel modules which are not installed for some reason on my machine when installing.

Try:

sudo apt-get update
sudo apt-get install build-essential gcc make perl dkms
sudo /sbin/vboxconfig

Reboot.