Re: VirtualBox kmod won't load "module already loaded or in kernel"

From: Edward Sanford Sutton, III <mirror176_at_hotmail.com>
Date: Mon, 29 Jul 2024 02:07:00 UTC
On 7/28/24 16:21, Graham Menhennitt wrote:
> Thanks for replying, Piotr.
> 
> While, what you say is true, I don't understand why it's necessary to 
> build anything at all. I'd like to run purely from FreeBSD releases and 
> packages. I shouldn't have to build anything from ports.

when a new minor version comes out, the builds are still done for the 
previous minor version instead until it is EOL (3 months?). If you limit 
upgrades until such time then you can use the formally released packages 
without issue. I don't think there is a way this will change unless the 
official packages build for all supported releases instead of just the 
lowest minor # releases; this is only sometimes an issue with kernel 
modules and I thought it would be considered a bug if it happened with 
software that stays in userspace.

> Graham
> 
> On 24/07/2024 7:41 pm, Piotr Smyrak wrote:
>> On Fri, 19 Jul 2024 13:37:41 +1000
>> Greg 'groggy' Lehey <grog@freebsd.org> wrote:
>>
>>> On Friday, 19 July 2024 at 13:23:46 +1000, Graham Menhennitt wrote:
>>>> Hello all,
>>>>
>>>> I'm running FredBSD 14.1 amd64 with a GENERIC kernel. I've installed
>>>> VirtualBox from packages. But I can't load any of its kmod modules.
>>>> When I try, I get a message:
>>>>      # kldload vboxdrv
>>>>      kldload: can't load vboxdrv: module already loaded or in kernel
>>>>      #
>>>> However, neither of those things is true:
>>>>      # kldstat -v|grep -i virtualbox
>>>>      #
>>> Yes.  It lies.  It's VB's inimitable way of saying "you have the wrong
>>> module version for this kernel".  It should be sufficient to rebuild
>>> the virtualbox-ose-kmod port.  Don't install the package, because it
>>> doesn't know what kernel you have.
>> It's worth to note that there is a systematic solution to rebuild ports
>> that install kernel modules each time a new kernal is installed from
>> sources. Placing such a line in /etc/make.conf will induce rebuilding
>> of kmod port by system Makefiles:
>>
>> PORTS_MODULES += emulators/virtualbox-ose-kmod

To avoid the build getting stuck when setting that variable, make sure 
to either do a test run from the ports tree directly to get through all 
config screens or do a single threaded kernel build (remove -j 
definition, don't just set it to 1). Run `make -C 
/usr/ports/emulators/virtualbox-ose-kmod config-recursive` before 
building the kernel and provide answers to the dialogs. Alternatively 
you could undefine PORTS_MODULES, build the kernel multithreaded, 
redefine the variable, and rebuild the kernel but without -j defined; 
this allows you to answer dialogs as they are (eventually) presented and 
likely eliminates the ability to build ports with multiple make jobs too 
which includes the ports modules and their dependencies. This should be 
repeated before any kernel build if the ports tree has been updated or 
relevant port configurations have been removed. The issue results from 
ports trying to present a dialog to the terminal but the terminal that 
is attached from the parent make when jobs count is defined is not 
interactive. https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=259702 
can be closed if this is has been resolved.

>> HTH,
>