VM only starting after running modprobe vboxnetflt

Discussions related to using VirtualBox on Linux hosts.
Post Reply
MatthK
Posts: 10
Joined: 16. Nov 2021, 15:57

VM only starting after running modprobe vboxnetflt

Post by MatthK »

I have a new install of Ubuntu Server 20.04.3 LTS and installed Virtualbox 6.1. on that. I imported an existing VM from another machine and it started up successfully. Somehow, the host was setup with an insecure boot, so I tried to fix that. After that, the VM wouldn't start up anymore, with various error messages after trying almost every solution I found, including purgin Virtualbox and re-installing it.

I have setup a service to automatically start up the VM after booting the host. After a boot, the service errors out with the following errors:

Code: Select all

sudo service vbox_vm_start@ERPNext status
● vbox_vm_start@ERPNext.service - VirtualBox VM ERPNext
     Loaded: loaded (/etc/systemd/system/vbox_vm_start@.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Sat 2021-11-20 00:35:44 HKT; 16s ago
    Process: 1144 ExecStart=/usr/bin/VBoxManage startvm ERPNext --type headless (code=exited, status=1/FAILURE)
      Tasks: 0 (limit: 76627)
     Memory: 25.2M
     CGroup: /system.slice/system-vbox_vm_start.slice/vbox_vm_start@ERPNext.service

Nov 20 00:35:44 vs02 VBoxManage[1162]: WARNING: The character device /dev/vboxdrv does not exist.
Nov 20 00:35:44 vs02 VBoxManage[1162]:          Please install the virtualbox-dkms package and the appropriate
Nov 20 00:35:44 vs02 VBoxManage[1162]:          headers, most likely linux-headers-generic.
Nov 20 00:35:44 vs02 VBoxManage[1162]:          You will not be able to start VMs until this problem is fixed.
Nov 20 00:35:44 vs02 VBoxManage[1144]: VBoxManage: error: The virtual machine 'ERPNext' has terminated unexpectedly during startup with exit code 1 (0x1)
Nov 20 00:35:44 vs02 VBoxManage[1144]: VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
Nov 20 00:35:44 vs02 VBoxManage[1144]: Waiting for VM "ERPNext" to power on...
Nov 20 00:35:44 vs02 systemd[1]: vbox_vm_start@ERPNext.service: Control process exited, code=exited, status=1/FAILURE
Nov 20 00:35:44 vs02 systemd[1]: vbox_vm_start@ERPNext.service: Failed with result 'exit-code'.
Nov 20 00:35:44 vs02 systemd[1]: Failed to start VirtualBox VM ERPNext.
I disabled secure boot again, but still, the VM doesn't start. Somehow I came across another suggested solution, and suddenly it works. After a reboot of the host, I get to the above error message. I run

Code: Select all

sudo modprobe vboxnetflt
and after that, the VM starts up happily and is running just fine.

Code: Select all

matth@vs02:~$ sudo modprobe vboxnetflt
matth@vs02:~$ sudo service vbox_vm_start@ERPNext start
matth@vs02:~$ sudo service vbox_vm_start@ERPNext status
● vbox_vm_start@ERPNext.service - VirtualBox VM ERPNext
     Loaded: loaded (/etc/systemd/system/vbox_vm_start@.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-11-20 00:37:59 HKT; 3s ago
    Process: 2283 ExecStart=/usr/bin/VBoxManage startvm ERPNext --type headless (code=exited, status=0/SUCCESS)
      Tasks: 43 (limit: 76627)
     Memory: 58.1M
     CGroup: /system.slice/system-vbox_vm_start.slice/vbox_vm_start@ERPNext.service
             ├─2293 /usr/lib/virtualbox/VBoxXPCOMIPCD
             ├─2299 /usr/lib/virtualbox/VBoxSVC --auto-shutdown
             └─2315 /usr/lib/virtualbox/VBoxHeadless --comment ERPNext --startvm b1a48d9c-e8e6-4901-8530-fb32513999a7 --vrde config

Nov 20 00:37:58 vs02 systemd[1]: Starting VirtualBox VM ERPNext...
Nov 20 00:37:59 vs02 VBoxManage[2283]: Waiting for VM "ERPNext" to power on...
Nov 20 00:37:59 vs02 VBoxManage[2283]: VM "ERPNext" has been successfully started.
Nov 20 00:37:59 vs02 systemd[1]: Started VirtualBox VM ERPNext.
Now my question is, what does the modprobe vboxnetflt exactly do and why does it not "survive" a reboot? How can I fix this so it will work even after a reboot?
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: VM only starting after running modprobe vboxnetflt

Post by fth0 »

MatthK wrote:Now my question is, what does the modprobe vboxnetflt exactly do and why does it not "survive" a reboot?
Linux kernel modules (including the VirtualBox kernel modules) are loaded when needed. If you manually load the vboxnetflt module, the vboxdrv module is automatically loaded as a dependency.

FWIW, there is some documentation about automatically starting VMs in 9.21.1. Linux: Starting the Autostart Service With init.
MatthK
Posts: 10
Joined: 16. Nov 2021, 15:57

Re: VM only starting after running modprobe vboxnetflt

Post by MatthK »

Awesome, thank you very much. After adding vboxnetflt to the file /etc/modules it works just fine.

Code: Select all

sudo nano /etc/modules
Add the line

vboxnetflt

Save, and reboot, and the VM loads automatically.
Post Reply