Error in vboxdrv.sh causes vbox modules to always be rebuilt

Discussions related to using VirtualBox on Linux hosts.
Post Reply
syphyr
Posts: 1
Joined: 29. Jul 2021, 19:34

Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by syphyr »

There is an error in vboxdrv.sh which causes the virtualbox modules to be rebuilt each time the computer is started. modules_available() will always return 0 because the conditional is incorrect.

--- vboxdrv.sh.back 2021-07-16 17:30:37.000000000 +0200
+++ vboxdrv.sh 2021-07-29 19:33:28.735947637 +0200
@@ -327,7 +327,7 @@
# Extract last component of module path and check whether it is located
# outside of /lib/modules/*/misc.
mod_dir="$(dirname "$mod_path" | sed 's;^.*/;;')"
- [ "$mod_dir" != "misc" ] || return
+ [ "$mod_dir" = "misc" ] || return

echo "1"
}
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by mpack »

These are user forums, and you posted in a rather obscure part of them. You should raise this as a BugTracker ticket, with proper version indicators. I'm sure something like this will be fixed almost instantly.

Another thing you could do is post in the Discuss the 6.1.26 topic. The devs do at least read that (I hope).

For others: the relevant location is <src>\Vbox\Installer\linux\vboxdrv.sh, the "module_available()" function, around line 327. This function appears to have been introduced recently (it wasn't present in the 6.1.10 sources I had on my PC, but does appear in 6.1.26).
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by fth0 »

Judging from the VirtualBox 6.1.24 Changelog (*) and the comments (2 x "externally built") above and inside the module_available() function, the changes in vboxdrv.sh were deliberately made to prevent VirtualBox from building its kernel modules when the Linux distribution already installed them itself, with the unwanted consequence that VirtualBox now builds its kernel modules after every boot of the Linux host.

I've already asked klaus on IRC if it's a bug or a feature. ;) Waiting for the answer ...

(*) "Linux host: Installer will not attempt to build kernel modules if system already has them installed and modules versions match current version"
klaus
Oracle Corporation
Posts: 1110
Joined: 10. May 2007, 14:57

Re: Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by klaus »

Was told by the dev who made the change that it's unfortunately a bug which slipped through. Classic inverted condition which easily happens with such shell script magic.

The proposed fix is correct, so anyone with the skills to edit the installed file should be able to apply the fix.
WhatHaveYou
Posts: 70
Joined: 25. Oct 2018, 04:13

Re: Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by WhatHaveYou »

Ah! This seems to explain why of late the loading of the VirtualBox driver doubles my boot time.

I take it from the 'diff' provided that the fix - which for some reason has not been pushed to the Ubuntu PPA - is as follows. In vboxdrv.sh (which on my system has the path /usr/lib/virtualbox/vboxdrv.sh), change line 330 from

Code: Select all

[ "$mod_dir" != "misc" ] || return
to

Code: Select all

[ "$mod_dir" = "misc" ] || return
For the record: the amount of trouble that VirtualBox has caused me, on Windows and Linux hosts, has been so great over the years that (1) I just removed it from Windows, (2) I should replace it with another virtualizer on Linux.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Error in vboxdrv.sh causes vbox modules to always be rebuilt

Post by mpack »

WhatHaveYou wrote: which for some reason has not been pushed to the Ubuntu PPA...
Ubuntu has their own VirtualBox fork which is therefore supported by Ubuntu, not by the VirtualBox devs.
Post Reply