Using VirtualBox as a Cloud Computing Server

Outline

  • Introduction
  • Requirements
  • Part 0: Installing VirtualBox and Extension Pack on the Command Line
  • Part 1: Creating and Deleting a VirtualBox VM using “VBoxManage”
  • Part 2: Enabling RDP access for a VirtualBox VM
  • Part 3: Additional Considerations

Introduction

When I was pursuing my undergraduate degree in IT, one of my favorite classes taught me about how cloud computing services worked behind the scenes. The best part was the group project I spent far too much time on. The class was split up into teams and given computers and networking equipment. Each team had to use these to create an AWS-like service on the local network to allow the creation and use of virtual machines over the network.

We had to make THIS with a Dell Optiplex and old Cisco networking equipment…
This became my entire life for a while…

Requirements

A non-virtual computer with, ideally,:

  • Several cores
  • More than 8 GB of memory
  • Plenty of hard drive space
  • Ubuntu 16 or later installed
  • VirtualBox installed with the appropriate version Extension Pack

Part 0: Installing VirtualBox and Extension Pack on the Command Line

If you don’t have VirtualBox installed, here is how to do it on the command line in Ubuntu/any distro that use the apt package manager.

sudo apt-get update -ysudo apt-get install virtualbox -yvboxver=`vboxmanage --version | awk -F '_' '{print $1}'`sudo curl https://download.virtualbox.org/virtualbox/$vboxver/Oracle_VM_VirtualBox_Extension_Pack-$vboxver.vbox-extpack > Oracle_VM_VirtualBox_Extension_Pack-$vboxver.vbox-extpack                       echo "y" | sudo vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-$vboxver.vbox-extpack                       sudo vboxmanage extpack uninstall VNC

Part 1: Creating and Deleting a VirtualBox VM using “VBoxManage”

There are many parts to creating a virtual machine and much more than is here can be learned at the official Oracle VM VirtualBox manual, particularly Chapter 8.

  • The first step is creating an XML virtual machine definition file.
VBoxManage createvm --basefolder "{absolute path}" --name VM_NAME --uuid=`uuidgen` --register
  • The second step is setting a few basic options on the VM such as CPU, RAM, VRAM, and setting time to UTC.
VBoxManage modifyvm VM_NAME --cpus 1 --memory 1024 --vram 16 --acpi on --ioapic on --pae off --x2apic on --rtcuseutc on
  • The third step is to create a virtual hard drive and storage contoller and then attach the storage to the VM.
VBoxManage createhd --filename "{absolute path}/VM_NAME.vdi" --size 10000 --variant StandardVBoxManage storagectl VM_NAME --name "SATA Controller" --add sata --bootable onVBoxManage storageattach VM_NAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "{absolute path}/VM_NAME.vdi"
  • The fourth step, techincally optional, is to add an IDE controller to the virtual machine and attach an ISO file to be booted at startup.
VBoxManage storagectl VM_NAME --name "IDE Controller" --add ideVBoxManage storageattach VM_NAME --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium "{absolute path}/operatingsystem.iso"
  • Finally, you can start the VM.
VBoxManage startvm VM_NAME
  • To delete the VM, power it off, unregister, and delete all its files.
VBoxManage controlvm VM_NAME poweroff
VBoxManage unregistervm VM_NAME --delete
rm -rf "{absolute path}/VM_NAME"

Part 2: Enabling RDP access for a VirtualBox VM

To create a RDP-ready VM, start by following Part 1 but DO NOT power on or delete the VM.

  • With the VM created and ready to be powered on, modify the VM settings to to enable RDP access.
VBoxManage modifyvm VM_NAME --vrde on --vrdeport $3 --vrdeaddress {IP address}
  • Now start the VM headless (without a window).
VBoxManage startvm VM_NAME --type headless
  • Now, from a different computer on the same network, attempt an RDP connection with software like Remmina Remote Desktop Client. Again, I blacked out an error on the image below, but as you can see, the RDP server is working and shows what you would see on a booted VM.

Part 3: Additional Considerations

Some firewall rules will need to be created to allow RDP connections and security may become an issue for you. Additionally, SSH security will need to be taken into account if you plan on installing an SSH server on any of your VMs (this will require port forwarding on the host machine to work and is easy to set up using “VBoxManage”, check here at Chapter 7). Finally, you may want a web interface to pull everything together and allow easy access to people on the network. This can be done with software like phpvirtualbox (https://github.com/phpvirtualbox/phpvirtualbox) or, with my very own creation, virtualflask (https://github.com/skatt621/virtualflask). Virtualflask requires nothing except an Ubuntu 16+ machine to be set up and comes with an easy setup script and easily editable web pages and code. Development is still active and the “Create New VM from Template” feature still needs testing.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sandeep Kattepogu

Sandeep Kattepogu

A man with a passion for information technology.