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
VirtualBox-intial
– Click the “New” button
VirtualBox-NewOS
– 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
VirtualBox-MemorySize
– 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”
VirtualBox-HD-Step1
– Press “Create” button
– Make sure VDI is the option selected in next screen
VirtualBox-HD-Step2
– Press “Continue” button
– Make sure the option “Dynamic allocation” is selected
VirtualBox-HD-Step3
– 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.)
VirtualBox-HD-Step4
– Press “Create”

You should now be back on the main screen and see your VM in the list on left hand.
VirtualBox-VM-Initial
– 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.
VirtualBox-VM-SelectISO
– 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.
VirtualBox-VM-SelectISO2
– Press the “Start” button

Eventually, the “Welcome” window will appear.
– Select the language you wish to use with Ubuntu
VirtualBox-VM-Language
– Press the “Install Ubuntu” button
In the “Preparing to install Ubuntu window:
– Tick the “Download updates while installing” checkbox
VirtualBox-VM-Confirm
– 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)
VirtualBox-VM-EraseDisk
VirtualBox-EraseDisk-Confirm
– 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:
VirtualBox-UserInfo
– 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)…
VirtualBox-VM-Installation

When asked to do so, press the “Restart Now” button.
VirtualBox-VM-RestartNow

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.
VirtualBox-EjectDisk

You should get to the login screen of Ubuntu.
– Enter your password, press “Enter”
VirtualBox-VM-Login
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”).
VM-Search-Terminal
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

VM-aptget-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

VM-aptget-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
VM-aptget-upgrade-confirm

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).
VM-SelectCD

It will open this window:
vm-runSoftware

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.
VM-Shutdown
VM-Reboot

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.
VM-settings-selected
Press the “Settings” button.

Video Memory

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

vCores

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:
VM-settings-vCores

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