Ubuntu 22.04にvirtualbox-dkmsをインストールする方法は?

Ubuntu 22.04にvirtualbox-dkmsをインストールする方法は?

Ubuntu 22.04では、virtualbox-dkmsを(再)インストールできません。私が得るエラーは次のとおりです。

$ sudo apt-get install virtualbox-dkms 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  virtualbox-dkms
0 upgraded, 1 newly installed, 0 to remove and 2 not upgraded.
Need to get 721 kB of archives.
After this operation, 5’725 kB of additional disk space will be used.
Get:1 http://ch.archive.ubuntu.com/ubuntu jammy-updates/multiverse amd64 virtualbox-dkms amd64 6.1.38-dfsg-3~ubuntu1.22.04.1 [721 kB]
Fetched 721 kB in 0s (9’717 kB/s)         
Selecting previously unselected package virtualbox-dkms.
(Reading database ... 364763 files and directories currently installed.)
Preparing to unpack .../virtualbox-dkms_6.1.38-dfsg-3~ubuntu1.22.04.1_amd64.deb ...
Unpacking virtualbox-dkms (6.1.38-dfsg-3~ubuntu1.22.04.1) ...
Setting up virtualbox-dkms (6.1.38-dfsg-3~ubuntu1.22.04.1) ...
Loading new virtualbox-6.1.38 DKMS files...
Building for 6.5.0-14-generic
Building initial module for 6.5.0-14-generic
ERROR: Cannot create report: [Errno 17] File exists: '/var/crash/virtualbox-dkms.0.crash'
Error! Bad return status for module build on kernel: 6.5.0-14-generic (x86_64)
Consult /var/lib/dkms/virtualbox/6.1.38/build/make.log for more information.
dpkg: error processing package virtualbox-dkms (--configure):
 installed virtualbox-dkms package post-installation script subprocess returned error exit status 10
Errors were encountered while processing:
 virtualbox-dkms
E: Sub-process /usr/bin/dpkg returned an error code (1)

/var/lib/dkms/virtualbox/6.1.38/build/make.log ファイルの内容は次のとおりです。

DKMS make.log for virtualbox-6.1.38 for kernel 6.5.0-14-generic (x86_64)
Do 11 Jan 2024 13:11:46 CET
make: Entering directory '/usr/src/linux-headers-6.5.0-14-generic'
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:           gcc-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/linux/SUPDrv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrvGip.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrvSem.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrvTracer.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPLibAll.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/alloc-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/initterm-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/memobj-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/mpnotification-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/powernotification-r0drv.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/assert-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/alloc-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/initterm-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memuserkernel-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/mp-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/mpnotification-r0drv-linux.o
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrvTracer.o: warning: objtool: SUPR0TracerFireProbe+0x7: indirect jump found in RETPOLINE build
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/SUPDrvTracer.o: warning: objtool: supdrvTracerProbeFireStub+0x0: 'naked' return found in RETHUNK build
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/process-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/rtStrFormatKernelAddress-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/semevent-r0drv-linux.o
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/semeventmulti-r0drv-linux.o
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c: In function ‘rtR0MemObjNativeLockUser’:
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:1228:18: error: too many arguments to function ‘get_user_pages’
 1228 |             rc = get_user_pages(R3Ptr,                  /* Where from. */
      |                  ^~~~~~~~~~~~~~
In file included from /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/the-linux-kernel.h:102,
                 from /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:31:
./include/linux/mm.h:2430:6: note: declared here
 2430 | long get_user_pages(unsigned long start, unsigned long nr_pages,
      |      ^~~~~~~~~~~~~~
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:1261:33: error: passing argument 6 of ‘get_user_pages_remote’ from incompatible pointer type [-Werror=incompatible-pointer-types]
 1261 |                                 papVMAs                 /* vmas */
      |                                 ^~~~~~~
      |                                 |
      |                                 struct vm_area_struct **
./include/linux/mm.h:2400:33: note: expected ‘int *’ but argument is of type ‘struct vm_area_struct **’
 2400 |                            int *locked);
      |                            ~~~~~^~~~~~
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:1245:18: error: too many arguments to function ‘get_user_pages_remote’
 1245 |             rc = get_user_pages_remote(
      |                  ^~~~~~~~~~~~~~~~~~~~~
./include/linux/mm.h:2397:6: note: declared here
 2397 | long get_user_pages_remote(struct mm_struct *mm,
      |      ^~~~~~~~~~~~~~~~~~~~~
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:1304:39: error: assignment of read-only member ‘vm_flags’
 1304 |                 papVMAs[rc]->vm_flags |= VM_DONTCOPY | VM_LOCKED;
      |                                       ^~
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c: In function ‘rtR0MemObjNativeMapUser’:
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.c:1774:35: error: assignment of read-only member ‘vm_flags’
 1774 |                     vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
      |                                   ^~
cc1: some warnings being treated as errors
  CC [M]  /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/semfastmutex-r0drv-linux.o
make[3]: *** [scripts/Makefile.build:251: /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memobj-r0drv-linux.o] Error 1
make[3]: *** Waiting for unfinished jobs....
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memuserkernel-r0drv-linux.o: warning: objtool: VBoxHost_RTR0MemKernelCopyTo+0x13: redundant CLD
/var/lib/dkms/virtualbox/6.1.38/build/vboxdrv/r0drv/linux/memuserkernel-r0drv-linux.o: warning: objtool: VBoxHost_RTR0MemKernelCopyFrom+0x13: redundant CLD
make[2]: *** [scripts/Makefile.build:488: /var/lib/dkms/virtualbox/6.1.38/build/vboxdrv] Error 2
make[1]: *** [/usr/src/linux-headers-6.5.0-14-generic/Makefile:2037: /var/lib/dkms/virtualbox/6.1.38/build] Error 2
make: *** [Makefile:234: __sub-make] Error 2
make: Leaving directory '/usr/src/linux-headers-6.5.0-14-generic'

このエラーを解決するにはどうすればよいですか?

答え1

VirtualBox 7.0.12にアップグレードして問題を解決しました...私の場合は、vagrantを2.4.0にアップグレードしました。

答え2

Ubuntuは今日、virtualboxカーネルモジュールのビルド問題を解決するための修正を発表しました。

Ubuntuのバグトラッカー: virtualbox-dkms 6.1.38-dfsg-3~ubuntu1.22.04.1: virtualbox カーネルモジュールの構築に失敗しましたステータスが「Fix Released」に変更されました、コメント#9渡すツイートをサイトに埋め込む:

この問題を解決するVirtualBoxの新しいバージョンがリリースされました。

このアップデートを入手してくださいvirtualbox (6.1.48-dfsg-1~ubuntu1.22.04.1) [マルチバス]multiverse有効にする必要がありますjammy-updates

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

インストールするvirtualbox

sudo apt update
sudo apt upgrade
sudo apt install virtualbox

関連情報