已经尝试过 this Topic但没有解决它
我在/lib/systemd/system/vbox.service 下放置了一个名为 vbox.service 的文件,其中包含以下内容:
[Unit]
Description=Virtualbox Headless VM
[Service]
ExecStart=/usr/bin/VBoxHeadless --startvm 4decf7c1-7eda-461c-92aa-835d2405a22e
ExecStop=/usr/bin/VBoxManage controlvm 4decf7c1-7eda-461c-92aa-835d2405a22e poweroff
User=my_user
[Install]
WantedBy=muti-user.target
如果我通过以下方式启动和停止它
sudo systemctl start vbox
和sudo systemctl stop vbox
,一切正常
然后我输入以下内容:
sudo systemctl enable vbox
,但它不会在启动时启动
这是输出
sudo systemctl status vbox
vbox.service - Virtualbox Headless VM
Loaded: loaded (/usr/lib/systemd/system/vbox.service; enabled)
Active: inactive (dead)
CGroup: name=systemd:/system/vbox.service
Jan 05 02:38:59 exia pulseaudio[1428]: [pulseaudio] main.c: Daemon startup failed.
Jan 05 02:40:08 exia systemd[1]: Started Virtualbox Headless VM.
Jan 05 02:42:02 exia systemd[1]: Stopping Virtualbox Headless VM...
Jan 05 02:42:02 exia VBoxManage[1546]: 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Jan 05 02:42:02 exia VBoxHeadless[1375]: Oracle VM VirtualBox Headless Interface 4.2.6_OSE
Jan 05 02:42:02 exia VBoxHeadless[1375]: (C) 2008-2012 Oracle Corporation
Jan 05 02:42:02 exia VBoxHeadless[1375]: All rights reserved.
Jan 05 02:42:02 exia VBoxHeadless[1375]: VRDE server is listening on port 3389.
Jan 05 02:42:02 exia VBoxHeadless[1375]: VRDE server is inactive.
Jan 05 02:42:02 exia systemd[1]: Stopped Virtualbox Headless VM.
/usr/bin/VBoxHeadless --startvm 4decf7c1-7eda-461c-92aa-835d2405a22e 工作正常
不过有什么想法吗?
最佳答案
This page on the Arch Linux wiki包含一个稍微灵活的 systemd.service 文件和一些可能是关键的附加选项。
该页面还提到 VirtualBox 4.2 有一个内置的自动启动机制,可能会工作得更好。
/etc/systemd/system/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e99f8b86919f849a8c9b9f808a8ca9c79a8c9b9f808a8c" rel="noreferrer noopener nofollow">[email protected]</a>
[Unit]
Description=VBox Virtual Machine %i Service
Requires=systemd-modules-load.service
After=systemd-modules-load.service
[Service]
User=user
Group=vboxusers
ExecStart=/usr/bin/VBoxHeadless -s %i
ExecStop=/usr/bin/VBoxManage controlvm %i savestate
[Install]
WantedBy=multi-user.target
关于Virtualbox headless : not starting via systemd,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14171481/