# Trying to run virtualboxes as non root.



## pauljames (Sep 5, 2011)

I have tried to get xboxwebserv to run as regular user. But then when it's started, cannot login to phpvirtualbox and cannot start any virtualbox. 

The regular user was put into vboxusers group. /etc/rc.conf has:

```
vboxheadless_user="virtuser"
vboxwebsrv_user="virtuser"
```
When the following command was run as the user wanted to run virtualboxes:


```
%VBoxHeadless -s 1stbox -n -v on -e "TCP/Address=x.x.x.x" -e "TCP/Port=5900"
```

It displays: 
	
	



```
Invalid machine name or UUID!
```

Once /etc/rc.conf  has:

```
vboxwebsrv_user="root"
vboxheadless_user="root"
```
it works, but is running as root.

Any idea's how to get all the virtualboxes and vboxwebserv to run as a regular user?


----------



## wblock@ (Sep 6, 2011)

Virtual machines are saved in ~/.VirtualBox/.  If they were created as root, they are still in /root/.VirtualBox/.  Probably should move them to /home/virtuser/.VirtualBox. The UUID thing... I don't know if you'll have to edit something after moving them and changing owner.


----------



## zodias (Sep 21, 2011)

Hi,

Try [CMD=]%VBoxHeadless --startvm YourMachineNameHere[/CMD]

Also you can add [CMD=]su -c - your_username VBoxHeadless --startvm YourMachineNameHere[/CMD]to /etc/rc.conf to "fire" the machine on boot.


----------



## pauljames (Sep 22, 2011)

It took a bit of trial and error but I have it working as non root user. In /etc/rc.conf we have:


```
vboxheadless_vm1_name="ivorytower"
vboxheadless_vm1_user="vtbox"
vboxheadless_vm2_name="Development"
vboxheadless_vm2_user="vtbox"
vboxheadless_vm2_flags="-n -m 12996 -o funk3"
```

On a reboot, these VMs don't auto start. But the bottom line of the code above, does allow for using VNC app to get to the box, which is especially useful for doing an install of an OS such as FreeBSD remotely. I just # it out once the OS is installed and *ssh -p port_number* to the newly created VM.

I wonder if one can have in the 'flags' the extra line Zodias has suggested such as:


```
vboxheadless_vm2_flags="-n -m 12996 -o funk3 su -c - your_username --startvm YourMachineNameHere
```

Perhaps something like:


```
vboxheadless_vm2_flags="-s -n -m 12996 -o funk3
```
is all that is needed. Not sure and I don't want to reboot the Server because its a production Server.

But even as root, one can just run manually

```
/usr/local/etc/rc.d/vboxheadless start vm1
```
and the vm1 will start and

```
#ps auxww |grep VBox
```
 will show the VM running as the user listed in /etc/rc.conf shown on the line 
	
	



```
vboxheadless_vm1_user="vtbox"
```


----------



## finurlix (Oct 26, 2011)

Hi,

Don't know if you got your vm to autostart at boot or not, but I got it working by using the following configuration:

/boot/loader.conf

```
vboxdrv_load="YES"
```

/etc/rc.conf

```
# Vbox conf #
vboxnet_enable="YES"  // If you use bridged networking for vm
vboxheadless_enable="YES"
vboxheadless_machines="vm1"
vboxheadless_user="vboxuser"
vboxheadless_vm1_name="actualNameOfVM"
vboxheadless_vm1_user="vboxuser"
vboxheadless_vm1_flags="--vnc --vncport 5900 --vncpass yourpassword"
```


----------

