Virtualbox VBoxManage 仅显示使用 sudo 的结果,其中有很多信息我已在其他帖子中尝试过?

Virtualbox VBoxManage 仅显示使用 sudo 的结果,其中有很多信息我已在其他帖子中尝试过?

当我以普通用户身份运行此程序时:

VBoxManage 列表 runningvms

没有结果,也没有错误输出,完全是空的......

当我使用 sudo 运行它时: sudo VBoxManage 列表 runningvms

看到我的虚拟机正在运行“homeassistant”{5e97e033-e726-41ec-a3aa-3f8e6b4bf448}

普通用户是

  • vboxusers 的成员
  • 删除此文件夹 rm -r ~/.config/VirtualBox
  • 使用 sudo chmod -R 752 ~/.config/VirtualBox 设置文件夹权限

问题是,我想在重启时自动启动虚拟机,所以我创建了一个自定义服务

/etc/systemd.system/ha.service

[单元] 描述=vm1 之后=network.target virtualbox.service 之前=runlevel2.target shutdown.target [服务] 用户=ovm 组=ovm 类型=forking 重启=no TimeoutSec=5min RemainAfterExit=yes ExecStart=/bin/bash /home/hans/startha.sh [安装] WantedBy=multi-user.target

/home.hans/startha.sh #!/bin/bash sleep 40 VBoxManage startvm homeassistant --type headless

重新加载配置 sudo systemctl 守护进程重新加载

启用服务 systemctl 启用 ha.service

重新启动并经过几分钟的检查,但用户无权启动虚拟机,那么如何处理?

systemctl 状态 ha

ha.service-vm1 已加载:已加载(/etc/systemd/system/ha.service;已启用;供应商预设:已启用)活动:失败(结果:退出代码)自 2023-04-18 星期二 13:41:08 EDT;5 分钟前进程:1119 ExecStart=/bin/bash /home/hans/startha.sh(代码=exited,状态=217/USER)CPU:1ms

运行 Debian喔喔 没有 GIU,VMS 是从终端设置的,当我用 sudo 启动它时,它运行良好

** 编辑 ** 当我运行 sudo ./startha.sh来自用户 hans 的虚拟机正在正常启动....

答案1

已经解决了.....由于某种原因,用户对 \home....VirtualBox\ VMs 上的 .vbox 文件没有(执行)权限

我运行 udo chmod 777 -R \home....VirtualBox\ VMs
,现在可以从用户启动虚拟机,并且自动启动也正常运行。

相关内容