18

platform: OS : Ubuntu 22.04
Kernel v.: 6.5.0.14-generic

After upgrading the kernel from 6.2 to 6.5, i encountered an error from VirtualBox which is shown in the picture below about virtualbox-dkms missing.

enter image description here

I tried reinstalling the linux-headers-generic and virtualbox-dkms and reactivating it, even rebooted the system with the kernel v. 6.2 and still didn't work out.
more logs:

sudo apt install virtualbox-dkms

sudo apt install virtualbox-dkms (output)

journalctl -xeu virtualbox.service

journalctl -xeu virtualbox.service (output)

stumblebee
  • 3,547

6 Answers6

27

It is a bug, VirtualBox 6 isn't compatible with the new kernel. You have to revert-back to the old kernel or install the VirtualBox 7 from oracle:

Stop the virtualbox service:

sudo systemctl stop virtualbox.service

then:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg] https://download.virtualbox.org/virtualbox/debian jammy contrib" |
sudo tee /etc/apt/sources.list.d/vbox.list
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | 
sudo gpg --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg --dearmor
sudo apt-get update
sudo apt-get install virtualbox-7.0

Bug #2048956 : virtualbox-dkms 6.1.38-dfsg-3~ubuntu1.22.04.1: virtualbox kernel module failed to build

Update

As said @ArryBbolt3 A fix has been released solving the kernel module failed to build error.

The new VirtualBox 6.1.48-dfsg-1~ubuntu1.22.04.1 and its dependencies is available from jammy-updates. You should have the following line in your /etc/apt/sources.list ( sudo apt edit-sources):

deb http://cz.archive.ubuntu.com/ubuntu jammy-updates main multiverse

@ArrayBolt3 Thank you for this update.

GAD3R
  • 3,507
  • 1
    I can confirm that VirtualBox 7.0 works just fine with the 6.5.0-14-generic Kernel. – Terrance Jan 12 '24 at 03:36
  • 2
    Before sudo apt-get install virtualbox-7.0 you may need to stop any running daemon of VirtualBox using sudo systemctl stop virtualbox.service . Also, closing the daemons may take about 10 seconds. – rusty Jan 12 '24 at 07:01
  • 1
    I tried the commands in the answer, and now Virtualbox 7.0 is installed and running ok. Nonetheless it tried installing virtualbox-dkms files for vbox 6.1.38 and failed (due to the kernel incompatibility, I suppose). Why is that? Do I need to install virtualbox-dkms separatedly? – Gustavo Mirapalheta Jan 13 '24 at 23:25
  • 1
    @GustavoMirapalheta that is up to Oracle to correct and patch their software to work with that Kernel. Either A) they aren't going to worry about it and push to 7.0. Or B) they just haven't had time or made any updates to 6.1 yet. I actually don't think that the virtualbox-dkms is needed for VirtualBox 7.0 to operate. Plus, the version of virtualbox-dkms is still 6.1.38-dfsg-3~ubuntu1.22.04.1 so they haven't updated it anyways. – Terrance Jan 14 '24 at 06:55
  • 2
    Just for the record, this bug has officially been fixed in Jammy and all later versions of Ubuntu. – ArrayBolt3 Jan 16 '24 at 02:09
  • @ArrayBolt3 Thank you. I have successfully installed Virtualbox on Jammy. – GAD3R Jan 16 '24 at 10:56
  • 1
    I confirm that VirtualBox 7.0.12 DOES NOT WORK with kernel 6.5.0-14-generic in Ubuntu 22.04. Namely, we get lots of errors about "array out of bounds" coming from /tmp/vbox* scripts, so it cannot be considered working. I didn't even bother starting up the VirtualBox GUI because one cannot trust software whose startup scripts generate "index out of bound in array" error. So I had to revert back to 6.2.0-39-generic kernel and then VirtualBox 7.0.12 was working fine. No errors and the GUI starts up a virtual machine as expected. – Tigran Aivazian Jan 16 '24 at 15:51
  • 1
    @TigranAivazian Those are the versions I am running just fine. 7.0.12r159484 and 6.5.0-14-generic. So, I am not sure what you are bumping into. – Terrance Jan 16 '24 at 19:11
  • 2
    @TigranAivazian You may want to see https://forums.virtualbox.org/viewtopic.php?t=102574 from VirtualBox themselves. Since I don't use shared scripts I still cannot see what you are seeing, but that is the closest I think I can find. From what I am reading is that if you want shared folders to run the scripts, then you have to set them up on the host and not on the VM side. But there are claims at the bottom that it was fixed in version 6.1.22, but this could be the same issue as seen now in 7.0.12. – Terrance Jan 18 '24 at 00:29
  • @Terrance Thank you, but I didn't set anything up specifically. I just relied on whatever was setup by running sudo /sbin/vboxconfig. – Tigran Aivazian Jan 19 '24 at 21:18
  • 1
    @TigranAivazian That is very interesting. I am wondering if there was old scripts or something in there failing on the gcc version. Not 100% sure. I just ran that same command on mine and everything built without an issue. I am at a loss as to why you saw the failures in those files. – Terrance Jan 20 '24 at 14:34
  • @Terrance Curious. Those errors were on my laptop, but on my desktop also running Ubuntu 22.04 with 6.5.0-14 kernel I uninstalled VirtualBox completely and then installed the 7.0.14 version .deb file downloaded from Oracle. And everything works fine. Later on I will try to do the same on the laptop and will report if there are problems. – Tigran Aivazian Jan 21 '24 at 10:12
  • @Terrance Oh dear, the problem is a lot more serious than I thought -- I get this kernel oops in the system log: [ 4.747309] UBSAN: array-index-out-of-bounds in /tmp/vbox.0/common/log/log.c:4161:34 [ 4.747311] index 345 is out of range for type 'uint32_t [1]' [ 4.747312] CPU: 2 PID: 980 Comm: modprobe Tainted: G OE 6.5.0-14-generic #14~22.04.1-Ubuntu [ 4.747314] Hardware name: LENOVO 20BX000TUK/20BX000TUK, BIOS (the rest deleted due to the stupid limits on size!) – Tigran Aivazian Jan 21 '24 at 13:44
  • Every few seconds while running VirtualBox 7.0.14 with 6.5.0-14 kernel on ThinkPad T450s I get a kernel oops coming from VBox kernel modules. I can't post the stack trace due to some stupid message size limit on this website, unfortunately. Simply rebooting back to 6.2.0-39 kernel makes all the problems disappear and everything works fine in VirtualBox 7.0.14. – Tigran Aivazian Jan 21 '24 at 13:46
  • 1
    @GAD3R Ok, done here https://askubuntu.com/questions/1500818/virtualbox-7-0-14-with-kernel-6-5-0-14-on-thinkpad-t450s-causes-kernel-oopses-fr – Tigran Aivazian Jan 21 '24 at 14:16
7

I had the exact same issue.

I downloaded the VirtualBox 7.0.12 DEB package directly from Oracle, uninstalled virtualbox-dkms from the system and then installed the deb with sudo dpkg -i /path/to/downloaded/deb.

All working perfectly so far.

1

I just had a similar problem. I purge virtual box and dkms. then I installed the latest version.

0

Instead of completely re-installing, you could also try to reconfigure virtualbox and re-load the virtualbox kernel module:

dpkg-reconfigure virtualbox-dkms
dpkg-reconfigure virtualbox
modprobe vboxdrv

This worked for me when virtualbox broke after a kernel update (although in my case, it was an earlier version).

  • This helped me after downgrading the kernel. Then you need to recompile the VirtualBox driver for the currently running kernel and reload the kernel module with the above commands (run as root). – Fabian Streitel Jan 29 '24 at 19:18
0

Got this problem when I tried to start a Windows 10 VM under Virtualbox 7.0. Tried the accepted answer but still had the problem. Answer by TehPeGaSuS solved my problem. The Windows VM was still there, working. So just:

  • sudo apt remove virtualbox-dkms
  • sudo dpkg -i 'path to VB 7.0 .deb file downloaded from Oracle'
kente2t
  • 1
  • 1
0

I have same error, i try everything, ugrade kernel, downgrade kernel, upgrade VB from 6.1 to 7, reinstall dkms lot of times and can not run VM. Something weird: i install 7.0 and when reboot open VB and is 6.1... i don't know what else i can do.

Updating my comment: problem was kernel version, VB has a bug with newer kernel versions, downgrade kernel even more, to 6.2, and everything work again. About the weird VB switching version, it happened when install virtualbox-dkms, automatically change linux headers and VB versión.

Juan_P
  • 1