Help with Systemd and virtualbox vm

gigatexal

I'm here to learn
Nov 25, 2012
2,868
577
113
Portland, Oregon
alexandarnarayan.com
I can't for the life of me seem to figure out where to put this service to startup the vm I have pi-hole running in. I can't find a vbox or virtualbox service to find a way to slot this in after. What am I missing?

Code:
[sudo] password for gigatexal:
● pi-hole-vm.service - Start Pihole vm
   Loaded: loaded (/etc/systemd/system/pi-hole-vm.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2019-03-16 21:36:05 CET; 11s ago
  Process: 1112 ExecStart=/usr/bin/vboxmanage startvm pi-hole --type headless (code=exited, status=1/FAILURE)
 Main PID: 1112 (code=exited, status=1/FAILURE)

Mar 16 21:35:59 devbox01 vboxmanage[1112]: WARNING: The character device /dev/vboxdrv does not exist.
Mar 16 21:35:59 devbox01 vboxmanage[1112]:          Please install the virtualbox-dkms package and the appropriate
Mar 16 21:35:59 devbox01 vboxmanage[1112]:          headers, most likely linux-headers-generic.
Mar 16 21:35:59 devbox01 vboxmanage[1112]:          You will not be able to start VMs until this problem is fixed.
Mar 16 21:36:00 devbox01 vboxmanage[1112]: VBoxManage: error: The virtual machine 'pi-hole' has terminated unexpectedly during startup with exit code 1 (0x1)
Mar 16 21:36:00 devbox01 vboxmanage[1112]: VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component MachineWrap, interface IMachine
Mar 16 21:36:00 devbox01 vboxmanage[1112]: Waiting for VM "pi-hole" to power on...
Mar 16 21:36:00 devbox01 systemd[1]: pi-hole-vm.service: Main process exited, code=exited, status=1/FAILURE
Mar 16 21:36:05 devbox01 systemd[1]: pi-hole-vm.service: Failed with result 'exit-code'.
Mar 16 21:36:05 devbox01 systemd[1]: Failed to start Start Pihole vm.
Code:
[Unit]
Description=Start Pihole vm

[Service]
ExecStart=/usr/bin/vboxmanage startvm pi-hole --type headless
Type=oneshot
RemainAfterExit=yes
User=gigatexal

[Install]
WantedBy=multi-user.target
 

pcmoore

Active Member
Apr 14, 2018
129
42
28
New England, USA
I hate to mention the obvious, but based on the warning/error messages you provided, have you tried installing the "virtualbox-dkms" package, or whatever the associated VirtualBox driver/kernel-module package is for your host system?

Another thing to try would be to start the VM manually after the system has fully booted just to verify that there isn't a systemd dependency that is missing and causing problems during boot.

Finally, while it doesn't appear to be the issue here, you could also try starting the VM as root to help rule out some potential permission problems.
 

gigatexal

I'm here to learn
Nov 25, 2012
2,868
577
113
Portland, Oregon
alexandarnarayan.com
Apt installed and built the dkms package.

While root the vboxmanage binary can’t see the vm but it does when gigatexal.

And it does start when I’ve logged in and run sudo systemctl start pi-hole-vm that runs the VM just fine.
 

sean

Member
Sep 26, 2013
66
33
18
CT
Sounds like an timing issue. There is nothing in the service file to indicate when it should start so systemd might run it very early in the boot. Add some After or Wants to the Unit section. I would at least have it start after the network is fully up (add network.target to After).
 
  • Like
Reactions: gigatexal