3

I followed this carefully: How to start Virtual box machines automatically when booting?

It "broke" VirtualBox. I had to remove the autostart stuff and run a reconfigure command that VirtualBox recommended in the error message to get VirtualBox working again.

Created the file /etc/default/virtualbox

# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg

This is /etc/vbox/vbox.cfg:

# Default policy is to deny starting a VM, the other option is "allow".
default_policy = deny
# Create an entry for each user allowed to run autostart
USERNAME = {
allow = true
}

Then:

sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox

sudo usermod -a -G vboxusers USERNAME

It seems it is having a problem reading /etc/vbox/vbox.cfg

:~$ ls -l /etc/vbox
total 8
-rw------- 1 USERNAME USERNAME   1 Dec 14 01:37 USERNAME.start
-rw-r--r-- 1 root     root     179 Dec 14 01:31 vbox.cfg

Next:

VBoxManage setproperty autostartdbpath /etc/vbox
VBoxManage modifyvm <uuid|vmname> --autostart-enabled on

This created USERNAME.start file in /etc/vbox directory - Although the file appears to be empty.

Then the Error:

● vboxautostart-service.service
Loaded: loaded (/usr/lib/virtualbox/vboxautostart-service.sh; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2018-12-14 01:41:57 CST; 27s ago
Process: 4002 ExecStart=/usr/lib/virtualbox/vboxautostart-service.sh start (code=exited, status=2)

Dec 14 01:41:57 HOST systemd[1]: Starting vboxautostart-service.service...
Dec 14 01:41:57 HOST vboxautostart-service.sh[4002]: /usr/lib/virtualbox/vboxautostart-service.sh: 2:/etc/vbox/vbox.cfg: default_policy: not found
Dec 14 01:41:57 HOST vboxautostart-service.sh[4002]: /usr/lib/virtualbox/vboxautostart-service.sh: 4: /etc/vbox/vbox.cfg: USERNAME: not found
Dec 14 01:41:57 HOST vboxautostart-service.sh[4002]: /usr/lib/virtualbox/vboxautostart-service.sh: 5: /etc/vbox/vbox.cfg: allow: not found
Dec 14 01:41:57 HOST vboxautostart-service.sh[4002]: /usr/lib/virtualbox/vboxautostart-service.sh: 6: /etc/vbox/vbox.cfg: Syntax error: "}" unexpected
Dec 14 01:41:57 HOST systemd[1]: vboxautostart-service.service: Control process exited, code=exited status=2
Dec 14 01:41:57 HOST systemd[1]: vboxautostart-service.service: Failed with result 'exit-code'.
Dec 14 01:41:57 HOST systemd[1]: Failed to start vboxautostart-service.service.
Little Mitch
  • 53
  • 1
  • 3
  • 10
  • I get this is several months old but Im about to try this myself and would just like to say I think going from the actual manual for the latest version of the program is going to be more helpful, give it a go if by some miracle you still need help 8 months later: https://www.virtualbox.org/manual/ch09.html#autostart I'm going to be setting up a couple VMs under ubuntu tomorrow and will try as well. – user863492 Aug 16 '19 at 02:01

1 Answers1

2

I had this problem too. The issue is that the autostart service script is trying to include /etc/vbox/vbox.cfg just like it does with /etc/default/virtualbox. You need to use a different filename for the autostart config.

Rename /etc/vbox/vbox.cfg -> /etc/vbox/autostart.cfg

Update VBOXAUTOSTART_CONFIG in /etc/default/virtualbox:

VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg