3

I've recently updated a headless server to Ubuntu Server 15.10.

  • Basic Ubuntu Server
  • LAMP
  • Xubuntu minimal install

I've installed virtualbox 5.0.14 from default Ubuntu sources. I've downloaded and installed virtualbox/5.0.14/Oracle_VM_VirtualBox_Extension_Pack-5.0.14-105127.vbox-extpack

I've defined a user vbox in group vboxusers, and basically virtualbox itself works fine. But I want it to be remotely configurable by using phpvirtualbox.

I downloaded and installed phpvirtualbox-5.0-5.zip

I added the VBOXWEB_USER=vbox to file /etc/default/virtualbox.

When visiting the webpage from another machine, I got an error Could not connect to host (see msg1, and with more details in msg2, not really important though, I think.).

Using sudo netstat -peanut, it looked like vboxwebsrv was not using the correct IP address. It showed the local address as ::1:18083 instead of the expected 192.168.1.12:18083.

After some googling, I added VBOXWEB_HOST=192.168.1.12 to file /etc/default/virtualbox, but still no change after restarting the service.

However, if I stopped the service with sudo systemctl stop vboxweb.service and started it manually with sudo vboxwebsrv -H 192.168.1.12, that worked fine. sudo netstat -peanut now reported it with the expected IP/port adress.

Most of the documentation I looked at referred to init.d and I started thinking that perhaps systemd does not use the /etc/default/virtualbox file... I found that I could edit the file /lib/systemd/system/vboxweb.service, and added a -H 192.168.1.12 to the ExecStart command. After a restart of the vboxweb service, it worked! :o)

Enabled service so that it would start automatically at boot time:

sudo systemctl enable vboxweb.service

But after rebooting, there was no vboxweb showing in sudo netstat -peanut at all, although ps -ef showed the service started:

$ps -ef

root 1383 1 0 mars02 ? 00:00:00 /usr/lib/virtualbox/vboxwebsrv --pidfile /run/vboxweb.pid --background -H 192.168.1.12 -p 18083

A restart of the service will fix it, but it will not come up correctly after reboot.

So I was thinking that perhaps the vboxweb.service was started too early in the systemd initialization process. So I edited the vboxweb.service file again, with After=apache2.service (and later also tried After=multi-user.target), and verified with systemd-analyse plot that the init of vboxweb was indeed moved to the very end of the initialization sequence. But still, wboxweb was not listed in netstat -peanut

So finally to my questions:

  1. Are there conflicts between init.d and systemd, e.g. that virtualbox (from standard Ubuntu sources) relies on files that are init.d specific, while Ubuntu has moved on to systemd?
  2. Any other reason why the VBOXWEB_HOST setting in the /etc/default/virtualbox file had no effect?
  3. Was it correct to edit the vboxweb.service file (specifically with the host parameter).
  4. (and this is the important one) How do I get vboxweb service up and running with correct IP/port settings at boot time? I am all out of ideas :/

PS: I know I could have shortened this post a lot, and just kept the main question here, as I have resolved the rest (leaving only a couple of questions), but I thought it could be interesting for others to see how I've worked on this problem.

BR, Rolf

4

After some more googling and mucking about, I finally came up with a solution:

1) I concluded that the /etc/defaults/virtualbox file did not seem to have any effect on anything (just a remnant from the init.d days?). So the user and group settings in that file was wasted.

Solution: Added User=vbox and Group=vboxusers in the [Service] section of the vboxweb.service file.

2) Some of the problems I had was due to the vboxweb.config file referring to a pid-file in the /run folder, and vbox has no write access to that folder. First I tried to make a subfolder, owned by vbox, in which to store the pid file, but I learned that the /run folder gets wiped at boot time, including all subfolders.

Solution: Created a subfolder in vbox homedir, and updated vboxweb.config file with that location.

3) For some reason (which still eludes me), referring to the actual IP address, 192.168.1.12, in config.php (in the phpvirtualbox folder) and in the vboxweb.config file (as mentioned in the original post), did not work at boot time. (A later restart of the service would work though.)

Solution: Updated both config.php and vboxweb.config with IP address 127.0.0.1 instead of 192.168.1.12.

Case closed! :o) ...apart for all the questions about why things are the way they are, but I can live with that :o)

BR, Rolf

  • I have the exactly same problem, but in my case /etc/default/virtualbox make difference in configuration and there is no vboxweb.config in my system, still trying to figure out whats Is happening. – André M. Faria Nov 3 '17 at 17:28
  • 1
    TLDR; The Oracle package has a completely different systemd unit file and respects /etc/defaults/virtualbox Sorry to necromance, but adding this in hopes it'll be useful for future. I installed virtualbox 5.2.18-dfsg-2~ubuntu18.04.3 on 18.04 from the ubuntu repos and as stated it completely ignored /etc/default/virtualbox. HOWEVER, out of curiosity I also installed the Oracle version and had no issues whatsoever. Something about the Ubuntu unit file/startup script is breaking/ignoring etc/defaults/virtualbox in a way that the Oracle pkg handles just fine. – mrlitsta Feb 21 at 23:04
0

rolfhsp's answer is really helpful.

In addition, if vboxweb.service is modified to run as some other user which is non root, another failure would occur. In this situation, the cause is logged as "Failed to open “/dev/vboxdrvu”, errno=13, rc=VERR_VM_DRIVER_NOT_ACCESSIBLE", which means the user has no permission to access /dev/vboxdrvu.

By default, /dev/vboxdrvu along with /dev/vboxnetctl and /dev/vboxdru are all permitted for root only (crw-------). for non-root users to access it, the permission must be modified. According to this blog, it is archived by simply putting a "rules" file into /lib/udev/ with content below:

/lib/udev/rules.d/20-virtualbox2.rules:

KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="vboxdrvu", NAME="vboxdrvu", OWNER="root", GROUP="vboxusers", MODE="0660"
KERNEL=="vboxnetctl", NAME="vboxnetctl", OWNER="root",GROUP="vboxusers", MODE="0660"

Then restart the system, after reboot, those files have new permissions:

crw-------. 1 root root      10, 54 Mar 20 00:24 /dev/vboxdrv
crw-rw----. 1 root vboxusers 10, 53 Mar 20 00:24 /dev/vboxdrvu
crw-rw----. 1 root vboxusers 10, 52 Mar 20 00:24 /dev/vboxnetctl

Although vboxdru is still unchanged, vboxdrvu already has good permission for a non-root (in vboxusers group) to access. After this modification, vboxweb.service could be run by a non-root user successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.