VirtualBox is a free and open-source hypervisor for x86 and x86-64 virtualization, which the Oracle Corporation develops. The software targets users wishing to create virtual environments for servers and desktops that allow users and administrations to run multiple guest operating systems on a single computer for either testing methods or production use. VirtualBox may be installed on Windows, macOS, Linux, Solaris, and OpenSolaris.
In the following tutorial, you will learn how to install VirtualBox on your Ubuntu 20.04 LTS operating system along with creating a new Virtual Machine from scratch.
Table of Contents
- Recommended OS: Ubuntu 20.04 – optional (Ubuntu 21.04)
- User account: A user account with sudo or root access.
- Required Packages: wget
Updating Operating System
Update your Ubuntu 20.04 operating system to make sure all existing packages are up to date:
sudo apt update && sudo apt upgrade
Import the GPG Key
The first step in installing VirtualBox latest build is first to add the GPG key:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
Example output if successful:
Import VirtualBox Repository
The next step once the GPG key is imported is to add the repository as follows:
echo "deb [arch=amd64] http://download.virtualbox.org/virtualbox/debian focal contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
Now, update your repository list to reflect the new additions.
sudo apt update
With the setup complete, execute the installation command to install VirtualBox:
sudo apt install virtualbox-6.1
Example of dependencies installed with VirtualBox:
To confirm if VirtualBox was installed successfully, check the current status as follows:
systemctl status vboxdrv
How to Use VirtualBox
How to Launch VirtualBox
To launch VirtualBox, you have two options. The first is to use the terminal command:
However, many users on desktops would use Show Applications > Virtualbox
Add & Setup New VM
To create and configure a new VM with VirtualBox is a straightforward process as follows. The tutorial will create a VM with the Linux profile for creating a Ubuntu 21.04 Desktop VM.
Step 1. Once VirtualBox is open, click on the New button as below:
Step 2. For the tutorial, it was stated the VM creation of choice would be Ubuntu 21.04. Name your VM, then click “Type Linux” and if it hasn’t been automatically selected for you select “Version: Ubuntu_64”.
Hint, if you name the VM the operating system, you install it’ll automatically pick the version for you.
Click the Next > button to proceed.
Step 3. The next window you will see is the select Memory (RAM) option. The default is 1024 MB; however, for most systems, you will need to increase this. A handy tip is to look at the min specs and determine how much memory your VM OS will require or expand to a healthy margin.
As shown below, the tutorial guest machine increased the margin to roughly 4GB. Once done, click the Next > button.
Step 4. Create or use an existing hard drive setup. Most users will typically Create a virtual hard disk now an option when creating a new VM.
Select this option and click Create button.
Step 5. When choosing the virtual storage allocation method, VDI (VirtualBox Disk Image) is recommended.
Click on the Next > button to proceed.
Step 6. Dynamically allocated when running a guest machine for best performance in disk allocation.
Click on the Next > button to proceed.
Step 7. Select the file location if the default isn’t reasonable for you. Lastly, set the time of the virtual hard disk.
Once configured, click on the Create button to finish up.
Step 8. You will now come to an overview of the virtual machine you just created. You can modify the settings of your VM in this overview now and in the future. Note, if you want to change settings, the virtual machine much be shut down.
To proceed with the Ubuntu 21.04 Desktop installation, click on the Start button as below:
Step 9. The first screen will appear when starting your VM for the first time, which will prompt you to select your ISO as the start-up disk.
Click on the icon folder as the example below.
Click on the Add + button on the top left corner as below:
Step 10. Now locate the directory and the ISO file, select it and click on the Open button:
Step 12. Click on the newly added ISO option, and this may take a second or three to sync up in the directory.
Once you have selected the ISO installation option, click on Choose button.
Step 13. In the last step, you can see the ISO file now in the start-up disk option to install.
Click on the Start button to install your VM OS system.
This will begin installing the chosen operating system; this was Ubuntu 21.04 as the example for the tutorial.
Comments and Conclusion
In the tutorial, you have learned how to install VirtualBox directly from the source repository to receive the latest updates and features in the future, along with a basic example of creating a VM using VirtualBox.
Overall, out of the many virtual machine software on the market, VirtualBox is one of the top players supplying an excellent selection of host and client combinations such as Windows from XP onwards, any Linux level 2.4 or better, Windows NT, Server 2003, Solaris, OpenSolaris, and even OpenBSD Unix.