我正在尝试从命令行启动 VMWare Workstation VM。我可以root
通过运行以下命令在我的用户(不是)下执行此操作
/usr/bin/vmplayer /home/myUser/vmware/myVm.vmx
现在,我想将此 VM 设置为开机启动,因此我创建了一个 /lib/systemd/system/myService.service
包含以下内容的服务:
[Unit]
Description=my vm service
[Service]
User=myUser
ExecStart=/usr/bin/vmplayer /home/myuser/vmware/myVm.vmx
Environment=DISPLAY=:0
[Install]
WantedBy=multi-user.target
如果我从终端(即sudo systemctl restart myService
)运行该服务,我可以看到 VM 窗口弹出并正确启动。但是,如果我重新启动系统,VM 不会启动,这就是status
我得到的
Jan 23 12:55:59 home systemd[1]: Started myService service.
Jan 23 12:56:00 home truenas.sh[848]: [AppLoader] Use shipped Linux kernel AIO access library.
Jan 23 12:56:00 home truenas.sh[848]: An up-to-date "libaio" or "libaio1" package from your system is preferred.
Jan 23 12:56:00 home vmplayer[848]: cannot open display: :0
Jan 23 12:56:00 home systemd[1]: myService.service: Main process exited, code=exited, status=1/FAILURE
Jan 23 12:56:00 home systemd[1]: myService.service: Failed with result 'exit-code'.
我认为DISPLAY=:0
环境可以解决问题,但这是我遇到的错误,我无法解决。