Problema con VirtualBox tras actualizar el kernel a versiones 6.8

Tras actualizar el kernel a la serie 6.8, observé que se producía un error en el servicio vboxdrv.service:

systemctl --failed
  UNIT            LOAD   ACTIVE SUB    DESCRIPTION                   
● vboxdrv.service loaded failed failed VirtualBox Linux kernel module

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.

Comprobé el estado del servicio:

systemctl --failed
  UNIT            LOAD   ACTIVE SUB    DESCRIPTION                   
● vboxdrv.service loaded failed failed VirtualBox Linux kernel module

LOAD   = Reflects whether the unit definition was properly loaded.
ACTIVE = The high-level unit activation state, i.e. generalization of SUB.
SUB    = The low-level unit activation state, values depend on unit type.
1 loaded units listed.
root@sprofesores2-pro:~# systemctl status vboxdrv.service 
× vboxdrv.service - VirtualBox Linux kernel module
     Loaded: loaded (/usr/lib/virtualbox/vboxdrv.sh; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Thu 2025-04-10 10:28:44 CEST; 5min ago
    Process: 778 ExecStart=/usr/lib/virtualbox/vboxdrv.sh start (code=exited, status=1/FAILURE)
        CPU: 836ms

abr 10 10:28:41 sprofesores2-pro systemd[1]: Starting VirtualBox Linux kernel module...
abr 10 10:28:42 sprofesores2-pro vboxdrv.sh[778]: vboxdrv.sh: Starting VirtualBox services.
abr 10 10:28:43 sprofesores2-pro vboxdrv.sh[778]: vboxdrv.sh: Building VirtualBox kernel modules.
abr 10 10:28:43 sprofesores2-pro vboxdrv.sh[1096]: Building VirtualBox kernel modules.
abr 10 10:28:44 sprofesores2-pro vboxdrv.sh[778]: vboxdrv.sh: failed: Look at /var/log/vbox-setup.log to find out what went wrong.
abr 10 10:28:44 sprofesores2-pro vboxdrv.sh[1558]: failed: Look at /var/log/vbox-setup.log to find out what went wrong.
abr 10 10:28:44 sprofesores2-pro systemd[1]: vboxdrv.service: Control process exited, code=exited, status=1/FAILURE
abr 10 10:28:44 sprofesores2-pro systemd[1]: vboxdrv.service: Failed with result 'exit-code'.
abr 10 10:28:44 sprofesores2-pro systemd[1]: Failed to start VirtualBox Linux kernel module.

Y eché un vistazo al archivo de log /var/log/vbox-setup.log:

Building the main VirtualBox module.
Error building the module:
make V=1 CONFIG_MODULE_SIG= CONFIG_MODULE_SIG_ALL= -C /lib/modules/6.8.0-57-generic/build M=/tmp/vbox.0 SRCROOT=/tmp/vbox.0 -j2 modules
make[1]: atención: se fuerza a -j2 en el submake: se restablece el modo de servidor de tareas.
warning: the compiler differs from the one used to build the kernel
  The kernel was built by: x86_64-linux-gnu-gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  You are using:           
make -f ./scripts/Makefile.build obj=/tmp/vbox.0 need-builtin=1 need-modorder=1 
# cmd_mod /tmp/vbox.0/vboxdrv.mod
  printf '%s
'   linux/SUPDrv-linux.o SUPDrv.o SUPDrvGip.o SUPDrvSem.o SUPDrvTracer.o SUPLibAll.o common/string/strformatrt.o combined-agnostic1.o combined-agnostic2.o combined-os-specific.o | awk '!x[$0]++ { print("/tmp/vbox.0/"$0) }' > /tmp/vbox.0/vboxdrv.mod
# CC [M]  /tmp/vbox.0/linux/SUPDrv-linux.o
  gcc-12 -Wp,-MMD,/tmp/vbox.0/linux/.SUPDrv-linux.o.d -nostdinc -I./arch/x86/include -I./arch/x86/include/generated  -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -I./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -I./ubuntu/include -include ./include/linux/compiler_types.h -D__KERNEL__ -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -mno-80387 -mtune=generic -mno-red-zone -mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables -mfunction-return=thunk-extern -fno-jump-tables -mharden-sls=all -fpatchable-function-entry=16,16 -fno-delete-null-pointer-checks -O2 -fstack-protector-strong -fno-omit-frame-pointer -fno-optimize-sibling-calls -ftrivial-auto-var-init=zero -fzero-call-used-regs=used-gpr -pg -mrecord-mcount -falign-functions=16 -fno-strict-overflow -fno-stack-check -fconserve-stack -Wall -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=1024 -Wno-main -Wvla -Wno-pointer-sign -Wno-array-bounds -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -g -gdwarf-5 -include /tmp/vbox.0/include/VBox/SUPDrvMangling.h -fno-omit-frame-pointer -fno-pie -Wno-declaration-after-statement -I./include -I/tmp/vbox.0/ -I/tmp/vbox.0/include -I/tmp/vbox.0/r0drv/linux -D__KERNEL__ -DMODULE -DRT_WITHOUT_PRAGMA_ONCE -DRT_OS_LINUX -DIN_RING0 -DIN_RT_R0 -DIN_SUP_R0 -DVBOX -DRT_WITH_VBOX -DVBOX_WITH_HARDENING -DSUPDRV_WITH_RELEASE_LOGGER -DVBOX_WITHOUT_EFLAGS_AC_SET_IN_VBOXDRV -DIPRT_WITHOUT_EFLAGS_AC_PRESERVING -DVBOX_WITH_64_BITS_GUESTS -DCONFIG_VBOXDRV_AS_MISC -DRT_ARCH_AMD64  -fsanitize=bounds-strict -fsanitize=shift -fsanitize=bool -fsanitize=enum  -DMODULE  -DKBUILD_BASENAME='"SUPDrv_linux"' -DKBUILD_MODNAME='"vboxdrv"' -D__KBUILD_MODNAME=kmod_vboxdrv -c -o /tmp/vbox.0/linux/SUPDrv-linux.o /tmp/vbox.0/linux/SUPDrv-linux.c   ; ./tools/objtool/objtool --hacks=jump_label --hacks=noinstr --hacks=skylake --retpoline --rethunk --sls --stackval --static-call --uaccess --prefix=16   --module /tmp/vbox.0/linux/SUPDrv-linux.o
/bin/sh: 1: gcc-12: not found
make[2]: *** [scripts/Makefile.build:243: /tmp/vbox.0/linux/SUPDrv-linux.o] Error 127
make[1]: *** [Makefile:1925: /tmp/vbox.0] Error 2
make: *** [/tmp/vbox.0/Makefile-footer.gmk:145: vboxdrv] Error 2

Revisando el log, el problema estaba claro: El kernel fue compilado con gcc-12 y es necesario disponer de gcc-12 para crear el módulo vboxdrv.

Una vez descubierto el problema, la solución es sencilla:

Primero.- Instalar el paquete gcc-12:

apt update && apt -y install gcc-12

Segundo.- Reiniciar el servicio:

systemctl restart vboxdrv.service

Tercero.- Por último, comprobamos que el módulo se ha cargado:

lsmod |grep vboxdrv
vboxdrv               696320  2 vboxnetadp,vboxnetflt
Be the first to comment