How to Install VirtualBox on Ubuntu 16.04

Reading Time: 3 minutes

What is a VirtualBox?

This is handy when you need to run software that is only available on one Operating System, for example, if you wanted to run Windows software on your Ubuntu computer or vice versa. The only limitations are RAM and disk space for running each virtual machine.

There are two open-source options for VirtualBox, one from Ubuntu and the other from Oracle. For this tutorial, we will give you the steps to installing the Oracle option as it is the industry standard. If you have any questions regarding these steps we advise reviewing Oracle’s excellent documentation.

Requirements for Oracle’s VirtualBox

You will need at least 512 MB of RAM to run a different Operating System, but likely you will want a lot more say, 2 to 3 G of RAM and in general, the more RAM you have, the better the performance of the virtual machine. You will also want to check the minimum RAM requirements of the guest operating system. For any Windows distribution, you will want at least 2G of RAM just for the virtual machine.

This also assumes you have a relatively new processor for your server or computer. As for the disk space, this will also vary based upon the distribution that you are using. VirtualBox itself is rather small needing only around 30M of space, but the files for the distribution will vary. For example, with a Windows 10 installation, it’s possible to need more than 10G of disk space. Depending on what you are hoping to do with the virtual machine will determine what size of hard disk you will need on your server, but 150G is a good size to make sure you have room to grow. In short, while you can do with less regarding VirtualBox, it’s best to add some wiggle room for growth and workability.

 

Installing Oracle VirtualBox

To start the installation, SSH into your computer and open a terminal as root, then follow these steps:

  1. First, open the following file with your favored text editor (in this example we’ll use vim)

vim /etc/apt/sources.list

  1. At the bottom of the file, add this line of text:

deb https://download.virtualbox.org/virtualbox/debian xenial contrib

And save the file by typing in

:wq

  1. Then we need to download the public key by running this command:

wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -

  1. Then you just run the following command to install:

sudo apt-get update
sudo apt-get install virtualbox-6.0

Running the Virtual Machine

Normally you use the VirtualBox Graphical User Interface (GUI) to manage your virtual machines, but a server does not have a desktop environment/graphics card to use the GUI. Fortunately, VirtualBox comes with a tool called VBoxHeadless that allows you to connect to the virtual machines over a remote desktop connection, so there’s no need for the VirtualBox GUI.

When starting the process of creating a new virtual machine, it’s beneficial to begin with the help command to see where you want to go:

VBoxManage --help

And from here you have officially installed VirtualBox on your server.

Additional Steps for Adding a Virtual Machine

There are the basic commands you will need to use to create a virtual machine on the server . In this example, you will create a Windows XP Virtual Machine on your Ubuntu 16.04 server.  And with that, we’ll start a new virtual machine called Windows XP which will run its namesake, Windows XP.

  1. First, create the virtual machine itself

VBoxManage createvm --name "Windows XP" --ostype WindowsXP --register

  1. Then make sure the virtual machine has required resources for the operating system, if you are unsure of the minimum requirements for your guest operating system (the virtual machine that you will be installing), its best to check these in the official documentation. In this case, we are adding 4G of RAM to be sure we have plenty of RAM to work with.

VBoxManage modifyvm "Windows XP" --memory 4096 --acpi on --boot1 dvd --nic1 nat

  1. Next create a virtual hard disk for the operating system, in this case, 10G:

VBoxManage createhd --filename "WinXP.vdi" --size 10000

  1. Add an IDE Controller to the new virtual machine

VBoxManage storagectl "Windows XP" --name "IDE Controller"
 --add ide --controller PIIX4

  1. Set the VDI file you created as the first virtual hard disk of the new virtual machine:

VBoxManage storageattach "Windows XP" --storagectl "IDE Controller"
--port 0 --device 0 --type hdd --medium "WinXP.vdi"

  1. Attach the ISO file that contains the operating system installation. You will want to install this later for the virtual machine to boot from.

VBoxManage storageattach "Windows XP" --storagectl "IDE Controller"
--port 0 --device 1 --type dvddrive --medium /full/path/to/iso.iso

  1. Enable the VirtualBox Remote Desktop Extension, the VRDP server, as follows:

VBoxManage modifyvm "Windows XP" --vrde on

  1. Start the virtual machine using the VBoxHeadless command:

VBoxHeadless --startvm "Windows XP"

If you are looking to install VirtualBox on a server, we advise looking into our VPS products which are perfect for all your server needs. Our managed products come with our 24/7 tech support from level 3 technicians and our 100% uptime guarantee.

 

Avatar for Cameron Paxton

About the Author: Cameron Paxton

Latest Articles

How to use kill commands in Linux

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article

Change the root password in WebHost Manager (WHM)

Read Article