Install VirtualBox in Ubuntu 20.04
VirtualBox is a free and open-source tool developed by Oracle for running virtual machines on your PC. In this article, we are going to explain how to install VirtualBox in Ubuntu 20.04.
Prerequisites
- Ubuntu server/PC with Sufficient hardware resources
- non-root user with sudo privileges
Download the Debian package from the VirtualBox download page. You can use wget
command to download the package using the terminal. The following command will download the Virtualbox Debian package version 6.1 which is the latest package when writing this tutorial.
$ wget https://download.virtualbox.org/virtualbox/6.1.12/virtualbox-6.1_6.1.12-139181~Ubuntu~eoan_amd64.deb
Install the downloaded Virtualbox package using the following command.
$ sudo dpkg -i virtualbox-6.1_6.1.12-139181~Ubuntu~eoan_amd64.deb
In some cases, you will experience an error similar to the below because of dependencies.
dpkg: error processing package virtualbox-6.1 (--install): Processing triggers for shared-mime-info (1.15-1) ... Errors were encountered while processing: virtualbox-6.1
Execute the following command to complete the VirtualBox installation on ubuntu.
$ sudo apt install -f
Now you have successfully installed the Virtualbox. To verify, click on the Activities tab located on the top left corner of your Ubuntu desktop and type VirtualBox. You will see a similar result as below.
Click to open VirtualBox.
How to create a virtual machine (VM) in VirtualBox
Let’s create a new VM in VirtualBox. First, select a new icon on the interface, and it will pop up a new window. We are going to create a Virtual machine with CentOS 8. Fill in the details accordingly. Then click next.
Choose the memory (RAM) size you wish to allocate to the VM. Consider the total memory size of your PC and the purpose of the VM. You can change this amount later. After selecting the memory size, click next.
Now it’s time to add a virtual hard disk to the virtual machine. You have three options
- Select do not add a hard disk option
- Create a virtual hard disk
- Select an existing virtual disk file
After choosing accordingly, click next
In this window, you should pick a virtual disk type. Here we select VMDK
since it is compatible with other virtualization tools.
After selecting the disk file type, you can choose to set a fixed disk size or dynamic size. In other words, the dynamic disk will grow as you use the virtual disk. Therefore select accordingly and proceed to the next step.
Now you can select the storage disk size. The recommended disk is 8 GB.
Now you have created the VM. Start the VM by clicking on the start button and it will pop up a window to choose an operating system image for the virtual machine. Click start after choosing the OS image file.
If you are facing an error similar to the below, Then enable the virtualization from your computer’s BIOS.
The virtual machine will boot to the CentOS installation window. Choose your language settings and click continue.
In this window, You have several steps to configure. First of all, choose the installation destination. Click on Installation Destination and it will open a window.
In this window, select the storage you have created earlier. Then click Done to confirm.
Now select Network & host management tab to enable networking to the virtual machine. It will open another window.
In this window enable the network connectivity and click on the Done button to save changes. You can change the hostname from this window under the Host Name input file.
You can change the operating system environment from Software Selection.
Select the Server option if you wish to install a headless version. Or else you can install CentOS with GUI. Therefore select accordingly and click on Done to save changes.
Now you have applied all the required changes. Click on the Begin Installation button to proceed with the installation.
During the installation process, you can set the root password by clicking on the Root Password tab. Enter a root password and click Done to confirm the changes.
After successfully installing CentOS on the virtual machine, click on the reboot button. You should remove the installation ISO image now. Come back to the virtual box main window.
In this main window, select the created VM and click on the settings (cock-wheel) icon. It will open up the settings window.
From this window click on the storage tab from the left side menu bar. You will see all the storage details related to the selected VM on the right side of the window.
Now select the CentOS image under the Controller: IDE section and click on the remove button which is located under the storage devices details. It will prompt a new window to confirm your action. Click on remove and proceed.
That’s it. You have successfully installed the centOS in the VM. Start the created VM from the main window.
Conclusion
In this tutorial, we explained how to install VirtualBox in Ubuntu 20.04. Moreover, how to Create a CentOS VM step by step. Please comment if you have any doubts and suggestions in the comment section.