Most VirtualBox users may think that VirtualBox is only intended for use in a desktop environment, where virtual machine (VM) management is done via VirtualBox GUI. However, VirtualBox can in fact run on headless servers, and VirtualBox VMs launched in headless mode can be managed remotely from an external VirtualBox front-end client.
In this tutorial, I will explain how to manage VirtualBox VMs on a remote headless server.
For remote management of VirtualBox, you can use RemoteBox, which is an open-source VirtualBox client software. RemoteBox allows you to connect to a remote headless server where VirtualBox is installed, and to manage and interact with VirtualBox VMs.
For this setup, you need at least one headless server host where VirtualBox is installed. You also need a separate Linux desktop host as a VirtualBox client host. RemoteBox will be installed on the client host.
Configure VirtualBox Server
On the headless server side, you need to install VirtualBox 4.2.0 and higher.
Besides VirtualBox, you also need to install VirtualBox extension pack on the server. The extension pack is needed for remote desktop display and PXE booting.
Assuming that the version of the installed VirtualBox is 4.2.16, you can install the corresponding VirtualBox extension pack on the server as follows.
$ sudo VBoxManage extpack install ./Oracle_VM_VirtualBox_Extension_Pack-4.2.12-84980.vbox-extpack
Finally, you need to set up VirtualBox web service on the server, so that VirtualBox clients such as RemoteBox can communicate with VirtualBox remotely.
Before doing that, first determine which Linux user VirtualBox web service will run as. If you run VirtualBox web service as a particular Linux user, you can only control VMs run by the same user.
Here I will create a new user (e.g., vbox), and a new group (e.g., vboxusers) dedicated to VirtualBox web service.
$ sudo useradd -g vboxusers vbox
To configure VirtualBox web service on the server, proceed as follows.
First, create a configuration file for the web service at /etc/default/virtualbox.
VBOXWEB_USER="vbox" VBOXWEB_TIMEOUT=0 VBOXWEB_LOGFILE="/var/log/vboxwebservice.log" VBOXWEB_HOST="10.0.0.121"
In the configuration file, VBOXWEB_USER is set to the Linux user that you will run VirtualBox web service as, and VBOXWEB_HOST corresponds to the IP address of the server.
Next, initialize and set the ownership of the log file:
$ sudo chown vbox:vboxusers /var/log/vboxwebservice.log
Create VirtualBox configuration directory:
$ sudo chown vbox:vboxusers /home/vbox/.VirtualBox
Start VirtualBox web service:
Check the status of VirtualBox web service:
Checking for VBox Web Service ...running
Also, verify that VirtualBox web service is listening on port 18083.
tcp 0 0 10.0.0.121:18083 0.0.0.0:* LISTEN 15855/vboxwebsrv unix 3 [ ] STREAM CONNECTED 152848 15855/vboxwebsrv
This completes VirtualBox server configuration. Next, proceed to install RemoteBox on a client host.
Requirements for Installing RemoteBox on Client Host
For RemoteBox to communicate with the server properly, the server and client hosts are NOT required to run the same operating system.
Prior to running RemoteBox on a client host, there are several prerequisite packages that you must install first.
To install prerequisites on Ubuntu, Mint or Debian based client host:
To install prerequisites on Fedora, CentOS or RHEL based client host:
Install and Configure RemoteBox on Client Host
To run RemoteBox on a client host, download its binary package from its official website, and simply run remotebox command.
$ tar xvfvz RemoteBox-1.5.tar.gz
$ cd RemoteBox-1.5
The screenshot of Remotebox looks like the following. To connect to a VirtualBox server, click on "Connect" button in the tool bar.
Fill in the server information:
- URL: http://<IP address of the server>:18083
- Username/password: Linux user for VirtualBox web service, and its password
Once you successfully logged in to the server, you can view a list of VMs that are created on VirtualBox.
Before launching a guest VM, edit its settings in order to enable remote display for the VM.
Click on the checkbox for enabling remote display server.
Start the guest VM by clicking on "Start" button.
Upon VM's launch, RemoteBox will automatically start rdesktop to show the VM's console via a remote desktop session.
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.