Creating an Ubuntu Virtual Machine on VirtualBox

      No Comments on Creating an Ubuntu Virtual Machine on VirtualBox

In this post, we will see how to install and run an Ubuntu (Linux) virtual machine (VM) on our computer using a software called Virtual Box.
A virtual machine is a virtual computer with its own operating system, disk space and memory that runs on a host computer. To run a virtual machine, you need a special software called a hypervisor. There are many hypervisors available on the market and VirtualBox is one of them and its free! There are other options like VMWare Player but that one is not free on MacOS. So, using a hypervisor, you can take any PC you have that’s running a Windows, MacOS or Linux operating system (OS) and have it host a virtual machine. That virtual machine can run the same OS or another one.

Why would we want to have virtual machines? There are many reasons for that:
– Test a new software. Once the tests are done, we get rid of the VM and we are sure we haven’t changed anything on our “real” computer.
– Create a VM that we will copy and share on many computers. You can find such pre-configured VMs on the internet that already have tools preinstalled on them.
– Have access to a different OS than the one on the host computer.
– Test the beta or a new version of an OS before installing it “for real” on your computer
– Easily migrate from one computer to another. When you upgrade your PC, you can copy your VM to your new computer. That way, you don’t have to reinstall and reconfigure everything
– ..

OK, let’s get back to the installation!

We will create an Ubuntu VM running on an iMac (OS X) and VirtualBox.
If you want to do the same thing, on Windows, the same steps will also apply.

Install VirtualBox

Download the application .pkg from here. You have to chose the OS that your computer is running on. In my case, I chose the version for OS X since I am doing the installation on my iMac.
Double click the downloaded file and follow the default installation instructions, using the default parameters.

Installing Ubuntu

– Download the Ubuntu ISO file from here. I had 2 options and decided to go for the version with long term support: 14.04.3 LTS.
– Launch VirtualBox
– Click the “New” button
– Enter the following values in the popup window:
– Name: Name you want your virtual machine to have
– Type: Linux
– Version: Ubuntu (64 bits)
– Press “Continue” button
– Select 5020MB of RAM (This works well when 8GB of RAM on host computer. Adjust according to your host computer memory, ideally leaving at least 2 to 3GB to your host OS)
– Press “Continue” button
– Select “Create new virtual disk”
– Press “Create” button
– Make sure VDI is the option selected in next screen
– Press “Continue” button
– Make sure the option “Dynamic allocation” is selected
– Press “Continue” button
– Change the disk size to 40GB. (You may want to allocate more or less disk space depending on your hard disk size. I think 8GB is the minimum you should use.)
– Press “Create”

You should now be back on the main screen and see your VM in the list on left hand.
– Make sure your VM is selected in the list.
– Press the “Start” button
It will open a window asking you to select the virtual optical disk file.
– Press the small icon beside the disk name.
– Browse to the Ubuntu ISO file you downloaded previously and double click that file to select it.
– Press the “Start” button

Eventually, the “Welcome” window will appear.
– Select the language you wish to use with Ubuntu
– Press the “Install Ubuntu” button
In the “Preparing to install Ubuntu window:
– Tick the “Download updates while installing” checkbox
– Press the “Continue” button
In the “Installation type” window:
– Leave as is and press the “Install Now” button (unless you are reusing an existing virtual disk that already contains another OS)
– You may have a warning saying that the disk is too small. Don’t worry, its size will be increased as required. So, you can press the “Continue” button.
In the “Where are you” screen:
– Select your timezone
Press the “Continue” button
– Select your keyboard settings and press “Continue”
In the “Who are you” window:
– Enter the requested information and press the “Next” button. Make sure to remember your password!!!

The system will be busy for quite a while (11 minutes in my case)…

When asked to do so, press the “Restart Now” button.

It will eventually stall at a black screen with some blue text asking you to remove the installation media.
Simply press the “Enter” key on your keyboard.

You should get to the login screen of Ubuntu.
– Enter your password, press “Enter”
You should now be in Ubuntu!

Your screen should look like mine with the Ubuntu desktop being very small and I can’t make it larger or go in full screen mode.
Let’s fix it right away!

First, you need to fix your Ubuntu installation.
Login into your Virtual Machine.

Press the button with Ubuntu logo in the top left corner of the screen (it’s the “Search your computer and online resources button”).
In the search box, type: “terminal”
You should see an icon to launch a terminal. Click it.
In the terminal window, type the following:

sudo apt-get update


It will ask you for your password. Provide it.

You will see text scrolling on the terminal.
Once the command is completed, you will be back to the prompt.
Type the following:

sudo apt-get-upgrade


The upgrade mode will look at what is not up to date and ask you if it should update to the latest version.
Press ‘y’ + Enter

That command will probably take over an hour to perform its job, so be patient!
Once it’s completed, you will be back to the terminal prompt.
Type the following:

sudo apt-get install dkms

When that command is completed, reboot your virtual machine by typing the following in the terminal:

sudo reboot

When you VM has been restarted, open the “Devices” menu. On Mac, it show when your virtual machine window is having focus.
Click the “Insert Guest Additions CD image…” menu option.

In Ubuntu, select the CD we just inserted (it shows in the list of applications on the left side of the screen).

It will open this window:

Press the “Run Software” button (on right side).
It will ask you for your password and then proceed with the installation.

Once the installation is completed, you must reboot Ubuntu again.
You can do it by clicking the “gear” icon on the top right corner of the window.
Then, select “Shutdown…” and “Restart” as in these 2 screen captures.

That’s it!
You can now enjoy your Ubuntu virtual machine in full screen mode!

Additional Configuration

You will probably want to change some other default VM configuration parameters, especially the amount of RAM allocated to your virtual video card and the number of vCores your VM can use.

If your VM is currently running, shut it down.
Then, make sure your VM is selected in the VMs list.
Press the “Settings” button.

Video Memory

Select the “Display” tab.
Increase the Video Memory setting to 32MB or whatever value you find suitable.
Press the “OK” button.


Select the “System” tab.
In that screen, select the “processor” tab.
My iMac is having a CPU with 4 cores in hyper threading, so the equivalent of 8 vCores.
I decided to use 4 vCores for my Ubuntu VM.
So, I configured the VM as this:

Once done with the configuration, press the “OK” button.
You can now restart your VM!

Leave a Reply

Your email address will not be published. Required fields are marked *

Comments Protected by WP-SpamShield Spam Plugin