Tuesday, 1 November 2016

Virtualbox headless

Virtualbox headless

1. To start Virtualbox headless

To start vboxweb from non-root user you must:

1.1. Create or add a user in the group vboxusers (for example, user)

sudo usermod -a -G vboxusers user
The -G switch takes a (comma-separated) list of supplementary groups to assign the user to. The -a (append) switch is important, otherwise the user will be removed from any groups not in the list.
The user will need to logout and log back in to see their new group added.

1.2. Create your custom vboxweb_mod.service file by copying /lib/systemd/system/vboxweb.service to /etc/systemd/system/vboxweb_mod.service

sudo cp /lib/systemd/system/vboxweb.service /etc/systemd/system/vboxweb_mod.service

1.3. Modify /etc/systemd/system/vboxweb_mod.service to this:

[Unit] Description=VirtualBox Web Service

[Service] Type=forking
ExecStart=/usr/bin/vboxwebsrv --pidfile /run/vboxweb/vboxweb.pid --host= --background


[Install] WantedBy=multi-user.target

1.4. Create tmpfile rule for your vboxweb_mod.service

sudo echo “d /run/vboxweb 0755 vbox vboxusers” > /etc/tmpfiles.d/vboxweb_mod.conf

1.5. Manually create the /run/vboxweb directory for first start vboxweb_mod.service

sudo mkdir /run/vboxweb
sudo chown user:vboxusers /run/vboxweb
sudo chmod 755 /run/vboxweb

1.6. Start/enable with:

sudo systemctl enable vboxweb_mod.service
The service will now run on startup.

1.7. To disable the service:

sudo systemctl disable vboxweb_mod.service

check if service is listening

sudo netstat -nap | grep vboxwebsrv