1

When I run this als normal user :

VBoxManage list runningvms

No results, also no error output, its compleet empty ....

When I run this with sudo : sudo VBoxManage list runningvms

is see my VM is running "homeassistant" {5e97e033-e726-41ec-a3aa-3f8e6b4bf448}

The normal user is

  • a member of vboxusers
  • remove this folder rm -r ~/.config/VirtualBox
  • set the folder permission with sudo chmod -R 752 ~/.config/VirtualBox

The problem is, I want to auto start the VM on a reboot, so I made a custom service

/etc/systemd.system/ha.service

[Unit] Description=vm1 After=network.target virtualbox.service Before=runlevel2.target shutdown.target [Service] User=ovm Group=ovm Type=forking Restart=no TimeoutSec=5min RemainAfterExit=yes ExecStart=/bin/bash /home/hans/startha.sh [Install] WantedBy=multi-user.target

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

reload the config sudo systemctl daemon-reload

enable the service systemctl enable ha.service

reboot and after a couple of minutes check, but the user has no rights to start a VM so how to handle this ?

systemctl status ha

ha.service - vm1 Loaded: loaded (/etc/systemd/system/ha.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Tue 2023-04-18 13:41:08 EDT; 5min ago Process: 1119 ExecStart=/bin/bash /home/hans/startha.sh (code=exited, status=217/USER) CPU: 1ms

running Debian uch uch with no GIU, the VMS is setup from terminal and is running fine when I start it with sudo

** edit ** when i run sudo ./startha.sh from user hans the vm is starting normal ....

1
  • Change type in systemd file to "oneshot" and or change sudoers file to make command to use without sudo passwd. Or try runas command instead.
    – petep
    Apr 18, 2023 at 19:09

1 Answer 1

1

it's solved..... for some reason the user has no (execute) rights on the .vbox file on \home....VirtualBox\ VMs

I run udo chmod 777 -R \home....VirtualBox\ VMs
and now can start the vm from a user and autostart is also working.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .