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

Discussions related to using VirtualBox on Linux hosts.

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

Postby syphyr » 29. Jul 2021, 19:39

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"
}
syphyr
 
Posts: 1
Joined: 29. Jul 2021, 19:34

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

Postby mpack » 30. Jul 2021, 11:12

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).
mpack
Site Moderator
 
Posts: 34727
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

Postby fth0 » 30. Jul 2021, 11:56

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"
fth0
Volunteer
 
Posts: 2470
Joined: 14. Feb 2019, 03:06
Location: Germany
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...

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

Postby klaus » 30. Jul 2021, 18:35

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.
klaus
Oracle Corporation
 
Posts: 843
Joined: 10. May 2007, 14:57

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

Postby WhatHaveYou » 14. Aug 2021, 02:47

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   Expand viewCollapse view
[ "$mod_dir" != "misc" ] || return

to
Code: Select all   Expand viewCollapse view
[ "$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.
WhatHaveYou
 
Posts: 70
Joined: 25. Oct 2018, 04:13

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

Postby mpack » 14. Aug 2021, 10:43

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.
mpack
Site Moderator
 
Posts: 34727
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP


Return to VirtualBox on Linux Hosts

Who is online

Users browsing this forum: No registered users and 17 guests