我仔细地遵循了这一点:如何在开机时自动启动虚拟机?
它“破坏”了 VirtualBox。我不得不删除自动启动内容并运行 VirtualBox 在错误消息中推荐的重新配置命令,以使 VirtualBox 再次运行。
创建文件 /etc/default/virtualbox
# virtualbox defaults file
VBOXAUTOSTART_DB=/etc/vbox
VBOXAUTOSTART_CONFIG=/etc/vbox/vbox.cfg
这是 /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
}
然后:
sudo chgrp vboxusers /etc/vbox
sudo chmod 1775 /etc/vbox
sudo usermod -a -G vboxusers USERNAME
似乎在读取 /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
下一个:
VBoxManage setproperty autostartdbpath /etc/vbox
VBoxManage modifyvm <uuid|vmname> --autostart-enabled on
这会在 /etc/vbox 目录中创建 USERNAME.start 文件 - 尽管该文件看起来是空的。
然后出现错误:
● 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.
答案1
我也遇到过这个问题。问题是自动启动服务脚本试图/etc/vbox/vbox.cfg
像包含一样包含/etc/default/virtualbox
。您需要为自动启动配置使用不同的文件名。
重命名/etc/vbox/vbox.cfg
->/etc/vbox/autostart.cfg
更新VBOXAUTOSTART_CONFIG
于/etc/default/virtualbox
:
VBOXAUTOSTART_CONFIG=/etc/vbox/autostart.cfg