Yesterday I received a kernel upgrade and after reboot, VirtualBox stopped working.

Here is my system info (after kernel upgrade):

matteo@workstation:~$ cat /etc/lsb-release 
matteo@workstation:~$ uname -a
Linux workstation 4.4.0-116-generic #140-Ubuntu SMP Mon Feb 12 21:23:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

I installed VirtualBox long ago with

sudo apt install linux-headers-$(uname -r)
sudo apt install virtualbox-dkms virtualbox virtualbox-qt

used on daily basis and never had problems with kernel updates. The error I receive now is

matteo@workstation:~$ sudo modprobe vboxdrv
modprobe: ERROR: could not insert 'vboxdrv': Exec format error
matteo@workstation:~$ dmesg | tail -n 1
[ 1413.167311] vboxdrv: version magic '4.4.0-116-generic SMP mod_unload modversions ' should be '4.4.0-116-generic SMP mod_unload modversions retpoline '

I found a forum post with this error message here from three days ago, unfortunately without resolution. Therfore I tried to remove the VirtualBox packeges from the Ubuntu repo, and install the latest 5.2 using this procedure. However, even after rebooting the machine, the error remains.

What can I do in this case?

  • This is happening with other modules too (e.g. bugs.launchpad.net/ubuntu/+source/xorg/+bug/1750937 and answers.launchpad.net/ubuntu/+question/664826)
    – ricab
    Feb 23 '18 at 0:52
  • 2
    A workaround for the moment is to load the previous kernel (4.4.0-112) in grub.
    – ricab
    Feb 23 '18 at 0:52
  • For those wondering how to perform the suggestion by @ricab: simply hold shift while booting, select "Advanced options for Ubuntu" and select an older kernel version from the menu, as explained here. I can confirm that my previous kernel version (4.4.0-112) does not have the problem described in the question, so that is a viable workaround until a solution is released.
    – matpen
    Feb 23 '18 at 22:24
  • In 16.04 it's the Esc key.
    – D.Bugger
    Feb 26 '18 at 8:47
  • @D.Bugger on my 16.04 shift does work. It is not my case, but I have read of some people getting it to work only with "right shift" or "left shift".
    – matpen
    Feb 26 '18 at 15:34

I was facing the same problem. After kernel upgrade my gcc version was showing as 5.4.1. Downgrading this version to 5.4.0 helped me to have retpoline for vboxdrv kernel module.

Following steps from this link helped me solve my issue:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:ubuntu-toolchain-r/test
#Select gcc version 5 using update-alternatives manually
sudo update-alternatives --config gcc

After these steps gcc --version should be (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609

Then purge all the new linux headers (4.4.0-116)

sudo apt-get purge linux-headers-4.4.0-116 linux-headers-4.4.0-116-generic linux-image-4.4.0-116-generic linux-image-extra-4.4.0-116-generic linux-signed-image-4.4.0-116-generic

Again install them

sudo apt-get install linux-generic linux-signed-generic

Then re-install virtualbox, I installed latest virtualbox-5.2 this time, but default 5.0 version of virtualbox should also work fine.

sudo apt-get purge virtualbox-dkms virtualbox virtualbox-qt
sudo apt-get install virtualbox-5.2

And, we have retpoline support in latest module

anirudh@AHDRMD34579:~$ modinfo vboxdrv 
filename:       /lib/modules/4.4.0-116-generic/misc/vboxdrv.ko
version:        5.2.6 r120293 (0x00290000)
license:        GPL
description:    Oracle VM VirtualBox Support Driver
author:         Oracle Corporation
srcversion:     4880B21EFF1B605D6402982
vermagic:       4.4.0-116-generic SMP mod_unload modversions retpoline 
parm:           force_async_tsc:force the asynchronous TSC mode (int)
  • Excellent work helped me after 6months with no access to my machines Apr 19 '18 at 15:15
  • I WANT TO GIVE YOU ALL THE POINTS IN THE WORLD!!!!! :-) But I can only upvote you once unfortunately.
    – shawty
    Jul 12 '19 at 10:49

The related problem listed in @ricab 's comment has been traced down to a problem with the new kernel requiring a certain version level of gcc to successfully compile kernel modules.

On my system the gcc update was pushed out AFTER the kernel update, causing the recompiles to fail.

Once the root cause was discovered, I was able to fix the system by uninistalling and reinstalling the new kernel. That fixed my graphics drivers, but I had to issue sudo /sbin/vboxconfig to fix virtualbox after booting into the new kernel.

My system is 14.04 so I cannot advise you as to the proper version of gcc for your 16.04 system, but this is discussed at https://bugs.launchpad.net/ubuntu/+source/xorg/+bug/1750937

  • Thank you for the link. Unfortunately, it does not seem to work in my case for Xenail (and I am not alone). I received no gcc upgrade recently, but I am already on gcc 5.4.1, and even tried with gcc 7.2.0.
    – matpen
    Feb 24 '18 at 10:57
  • @matpen: the compatible version is gcc 5.4.0 on 16.04
    – jfs
    Feb 26 '18 at 6:44
  • @jfs right, however I need the ppa gcc so I am not able to test right now.
    – matpen
    Feb 26 '18 at 15:36

I also had this problem recently and posted a question here about it. I did some digging and this is indeed a known issue.

The bug report is in my link.

Virtualbox has suddenly stopped working

I think the general concensus is to boot into the 4.4 kernel until the issue is fixed. (It is certainly the easiest solution for me.)

  • 1
    If your answer is essentially a referral to another question, it would be better to flag this question as a duplicate of the other once you earned 15 reputation. If you have the reputation don’t forget to vote for the answer(s) there that you found useful! Mar 12 '18 at 1:00
  • Understood. Will do.
    – hatterman
    Mar 12 '18 at 8:27

Not the answer you're looking for? Browse other questions tagged or ask your own question.