How to Install Ubuntu on VirtualBox: A Step-by-Step Guide

In this article, we will give you an instruction with step-by-step screenshots to show you how to install Ubuntu on VirtualBox.

VirtualBox is free, open-source, and cross-platform virtualization software that creates a virtual machine on top of your OS. This machine will have its own virtualized disk and access to a part of your systemโ€™s CPU and memory.

When configuring a virtual machine, the user can specify how many CPU cores and how much RAM and disk space should be devoted to the virtual machine.

Before starting, you need to download the Ubuntu ISO file you want to install from the Ubuntu download page. Once you have the ISO file downloaded, you can proceed to install Ubuntu on a VirtualBox virtual machine.

Setting up a Virtual Machine in VirtualBox

Create New Virtual Machine

To create a new virtual machine for installing Ubuntu on VirtualBox, open VirtualBox and click “New.”

VirtualBox - Create a New Virtual Machine

Enter a name for your virtual machine (e.g., Ubuntu), select “Linux” as the type, and select “Ubuntu (64-bit)” as the version.

Ubuntu Virtual Machine Details

Allocate RAM

The memory size depends on your host machine’s memory size. As our physical machine used in this example has enough RAM (32 GB), we’ll set 4 GB of RAM for a virtual machine to install Ubuntu on VirtualBox.

You can select any amount of memory you wish, but don’t add more than 50% of your total RAM.

Allocate RAM

Create Virtual Hard Disk

Check the “Create a virtual hard disk now” option, so we can later define our Ubuntu virtual hard disk size and click the “Create” button.

VirtualBox - Create a Virtual Hard Disk

Accept the default “VDI (VirtualBox Disk Image)” drive file type and click the “Next” button.

Set Virtual Hard Disk File Type

Next, we’ll dynamically allocate storage on our physical disk. This option allows you to save space on your physical disk until the virtual disk grows to its maximum given size. Again, click the “Next” button.

Set Virtual Hard Disk Type

Set the virtual hard drive file location by clicking on the folder-shaped icon. The virtual hard drive is a section of your computer’s hard drive space that will be used to store your virtual machine.

Set the file size of the virtual disk to 20 GB or more.

Click “Create” to finish setting up your Ubuntu virtual machine on VirtualBox.

Create Virtual Hard Disk

Start Ubuntu Virtual Machine

The wizard will close and go back to VirtualBox Manager. Select your Virtual Machine and click the “Start” button.

Finish Creating VirtualBox Virtual Machine

When you first start Ubuntu virtual machine with VirtualBox, you must select a start-up disk. Start this process by clicking the little folder icon.

Select Start-up Disk

You will need to find and select the Ubuntu image (installation ISO file) you want to install. Next, click the “Add” button to bring up a file dialog box.

Use this file dialog box to find and select the Ubuntu image you downloaded earlier. Confirm your choice by clicking the “Choose” button.

VirtualBox Optical Disk Selector

With the Ubuntu ISO installation file selected, click the “Start” button.

Select Start-up Disk

Finally, we can install the Ubuntu operating system to our VirtualBoxโ€™s virtual machine. The virtual machine boots from the ISO Ubuntu installation image.

Install Ubuntu in VirtualBox

Things from here are Ubuntu-specific. To go ahead and install, click “Install Ubuntu.”

Start Ubuntu Installation with VirtualBox

Choose your keyboard layout and click the “Continue” button.

Choose Keyboard Layout

Typically you will want Ubuntu to be installed on your VirtualBox virtual machine as a “Normal installation.”

Make sure “Download updates while installing Ubuntu” and “Install third-party software for graphics and Wi-Fi hardware and additional media formats” options are selected.

This will ensure that everything Ubuntu needs to run will be installed. Click the “Continue” button. 

Updates and Other Software

Check “Erase disk and install Ubuntu” and hit the “Install Now” button.

Ubuntu Installation Type

Confirm by clicking on the “Continue” button.

Write the Changes to Disk

With the correct time zone selected, click the “Continue” button.

Set Ubuntu Timezone

The last thing we need to do is create an account. Enter your preferred name, username, and password. Note that this user will have sudo privilege. Lastly, click the “Continue” button.

Create User Account

The installation will continue until it is finished.

Installing Ubuntu with VirtualBox - Installation Progress

You are almost done. Wait patiently for Ubuntu to be installed on VirtualBox. This process can take anywhere between 5 and 10 minutes.

Once Ubuntu has finished installing itself, you will see a notification window. To proceed, click the “Restart Now” button.

Ubuntu with VirtualBox - Installation Completed

Upon restarting, you will see a message about removing the installation medium. Just press the “Enter” key.

And thatโ€™s all. Select your name, then enter your password and sign in to your newly installed Ubuntu on VirtualBox.

Ubuntu with VirtualBox - Login Screen

Ubuntu will load your desktop as though you were using a separate computer.

Ubuntu running with VirtualBox

Installing VirtualBox Guest Additions on Ubuntu

VirtualBox Guest Additions are drivers and system utilities intended to improve usability, virtual machine performance, and tight integration with a host OS.

The VirtualBox Guest Additions offer the following features:

  • Better video support
  • Mouse pointer integration
  • Shared clipboard
  • Shared folders
  • Drag and drop support
  • Seamless windows
  • Generic host/guest communication channels
  • Better Time synchronization between guest and host

You need to run these commands in the virtual Ubuntu system.

First, update your Ubuntu guest operating system software packages:

sudo apt update
sudo apt upgrade

Once the upgrade completes, reboot your Ubuntu guest operating system and run:

sudo apt install build-essential dkms linux-headers-$(uname -r)Code language: JavaScript (javascript)

Next, from the Virtual Machine menu bar, go to “Devices” and click on “Insert Guest Additions CD image.” This helps to mount the Guest Additions ISO file inside your virtual machine.

Install VirtualBox Guest Additions

A dialog window will prompt you to “Run” the installer to launch it.

Run Guest Additions ISO

Enter your user’s password and click the “Authenticate” button.

Authenticate with sudo in Order to Install Guest Additions

This should open up the installation in a terminal window. Once the installation is complete, press the “Enter” key.

Installing VirtualBox Guest Additions

Finally, restart your system to reload kernel modules.

With Guest Additions installed, the clipboard of your guest OS can be shared with your host OS. To enable “Shared Clipboard and Drag’n’Drop functionality”, open VirtualBox Manager and click on “Settings.”

VirtualBox VM Settings

Next, go to “General” -> “Advanced” and enable the two options from the drop-down menu.

VirtualBox enable Shared Clipboard and Drag and Drop

Conclusion

VirtualBox is free and is an excellent tool for running multiple operating systems on a single OS. In addition, it is the easiest and safest way to install a “new computer” on your machine with no risk.

Todayโ€™s article explained how to install Ubuntu on VirtualBox. If you encounter any issues getting Ubuntu to install as a VirtualBox virtual machine, please feel free to ask your questions in the comment box below.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%