How to Install VirtualBox on Ubuntu

In this article, we will examine how to install the 6.1 version of Oracle VM VirtualBox and Extension Pack, which allows you to create a new virtual machine on the Linux / Ubuntu 20.10 (Groovy Gorilla) distribution.

How to Install VirtualBox on Ubuntu

How to Set Up and Run Oracle VM VirtualBox 6.1 on Ubuntu 20.10

Oracle VM VirtualBox allows you to create virtual machines and install and run Windows, Linux, or macOS operating systems on desktop or laptop computers you are using. However, in order to create virtual computers using this software, your processor must have a virtualization feature. To find out if your processor supports virtualization, you will need to visit your hardware manufacturer’s website or use a 3rd party software.

Oracle VM is a free and popular virtualization program and is also defined in the Hypervisor Type 2 virtualization group.

After installing the VirtualBox program on your Linux computer, you can create a new virtual machine and start the operating system installation by integrating the ISO files of the operating systems into this machine. The biggest advantage is that it is open source and completely free.

After running the virtualization software on the Linux system, you need to download and install the Extension Pack required for the program. Thanks to this software, you can use the hardware of your host devices such as a USB, Webcam, or network card in guest machines.

Now, follow the steps below to install VirtualBox on Ubuntu and create a new virtual machine.

   Step 1

To download the Oracle VM for Linux systems, visit https://www.virtualbox.org/ and click the Download VBox 6.1 image.

Download VBox for Linux

   Step 2

From the Downloads section, click on Linux distributions.

Linux Distributions

   Step 3

On the Download VBox for Linux Hosts page, click on Ubuntu 19.10 / 20.04.

Ubuntu 19.10 / 20.04

   Step 4

The VirtualBox program has the exe extension on Windows and the deb file extension on Linux systems. On Linux systems, packages with deb extensions are usually installed with the dpkg command.

Press CTRL + Alt + T together on your Ubuntu operating system to open the terminal and navigate to the location of the debug package you downloaded to your computer and execute the command below to start the installation.

cd ~/Downloads
sudo dpkg -i virtualbox-6.1_6.1.18-142142~Ubuntu~eoan_amd64.deb

Deb Package Installation

   Step 5

After extracting the VBox package with the deb extension, execute the “sudo apt install -f” command and start the installation process. Next, press the Y key and then Enter to confirm the installation of additional packages and use of additional disk space as shown in the image below.

sudo apt install -f

Installing Additional Packages

   Step 6

After installing the Oracle virtual machine software, type virtualbox and press Enter to launch it in the terminal.

virtualbox

After trying to open the VirtualBox program, you may get an error like the image below. Because the necessary kernel module for VBox is not installed. If you do not fix this error, you will not be able to start the VMs as indicated in the alert.

WARNING: The vboxdrv kernel module is not loaded. Either there is no module
available for the current kernel (5.8.0-41-generic) or it failed to
load. Please recompile the kernel module and install it by

sudo /sbin/vboxconfig

You will not be able to start VMs until this problem is fixed.

Running VBox from Terminal

   Step 7

To fix the vboxdrv kernel error, you must first download and install the required dependent package. To do this, download the package related to the wget command in the terminal and install it with the dpkg command.

wget http://archive.ubuntu.com/ubuntu/pool/main/l/linux/linux-libc-dev_5.8.0-25.26_amd64.deb
sudo dpkg -i linux-libc-dev_5.8.0-25.26_amd64.deb

Downloading and Installing Linux-lib-dev Package

   Step 8

For the vboxdrv error, you need to install and compile Linux kernel headers, otherwise, the virtual machines you created as in the warning above will not be able to start. To install VirtualBox Linux kernel headers, execute the following command in the terminal and then press Y and then Enter to confirm the installation of additional packages and the additional disk space usage.

sudo apt install linux-headers-$(uname -r) build-essential dkms

Installing Linux-headers

   Step 9

Execute the following command to restart the VirtualBox services and recompile the kernel modules.

sudo /sbin/vboxconfig

sudo /sbin/vboxconfig

   Step 10

Now, run the Oracle VM software again in the terminal and check for any errors. After installing the necessary packages, the virtualization software will run smoothly on your Ubuntu system.

Running Virtualization Software from Terminal

   Step 11

To check the version of the VBox software, click Help and then About from the tool menu.

Checking the Version of Virtualization Software Installed

   Video

How to Install Extension Pack

The first thing you need to do after installing the Oracle software is to install the Extension Pack to make virtual machines work more efficiently.

After installing VBox on your system, you need to install Extension Pack. The main purpose of installing Extension Pack is to use virtual machines more effectively. After installing this package, you can exchange files between the virtual machine and your physical computer, and you can also use the virtual machine in full-screen mode.

   Step 1

Visit the website where you downloaded the VirtualBox program again, and then click on the All supported platforms option as in the image below to download the Extension Pack.

Download Extension Pack

   Step 2

Double click on the vbox-extpack file you downloaded to the Downloads location to start its installation.

Extension Pack Installation

   Step 3

As soon as you double click the file, the VirtualBox – Question window will open as follows. In this window, you are informed that you need to install Extension Pack to use USB devices, webcam, RDP, PXE ROM, disk encryption, and NVMe features on guest machines. To use the specified features, click the Install button to start the installation.

Oracle VM VirtualBox Extension Pack

   Step 4

To accept the license agreement, scroll down the page and the I Agree button will be active.

Accepting the Expansion Pack License Agreement

   Step 5

Type the root password you set when installing your Ubuntu system and click the Authenticate button.

Typing the Root Password

   Step 6

After the installation is completed, click the OK button in the warning window that indicates that the Extension Pack was successfully installed.

Expansion Pack Installation Notice Window

   Step 7

To verify that the extension package is installed, first, click on File / Preferences.

Edit / Preferences

   Step 8

After clicking Extensions from the options on the left, you can see that the relevant package has been added in the Packages section.

Checking the Extension Package

How to Create a New Virtual Machine on Ubuntu

After installing Oracle VM VirtualBox without any problems, you need to create a new virtual machine and examine if there are any errors. So, in this article, we will prepare a Windows 7 virtual machine on a Linux distribution and start its installation.

   Step 1

From the VBox tool menu, click Machine and then New.

Creating a New Virtual Machine on VBox

   Step 2

In the Name and Operating System window, configure the name, installation location, type, and version of the virtual machine you will create and click Next.

Determining the Name and Version of the Operating System

   Step 3

In the Memory Size window, specify the amount of RAM you will allocate for the virtual machine and click Next.

Setting the Virtual Machine's RAM Size

   Step 4

In the hard disk configuration window, the virtual disk size will be automatically adjusted according to the operating system version. Since older operating systems will take up less disk space after installation, or configure a virtual disk size according to the size of your disk and the operations you will do on the virtual computer.

Creating a New Virtual Disk

   Step 5

Select VDI (VirtualBox Disk Image) as the hard disk file type and click Next.

Choosing the VDI Disk Image

   Step 6

You need to determine the size of your virtual computer’s virtual disk on the physical disk of your host. There are two options here, Dynamically Allocated and Fixed Size.

If you choose a fixed disk size, it may take some time to create the virtual disk, but this is more efficient than the other option. Dynamically Allocated option refers to the disk space to be allocated from your physical disk as much as the disk space required by your operations on the virtual machine according to the disk size you specified.

If you are creating a virtual machine to perform small-scale tests or experiments, continue by choosing your Dynamically Allocated option.

Configuring the Virtual Disk to Dynamically Expand

   Step 7

In the File Location and Size window, select a location where your virtual disk will be stored. Click the Create button as it is helpful to choose the default location here.

Choosing the Virtual Machine Installation Location

   Step 8

You need to configure a few features of the virtual operating system you are creating, such as boot sequencing or virtualization features. After creating the virtual disk, click the Settings button as shown below.

Configuring Virtual Machine Settings

   Step 9

In General / Advanced location, configure Shared Clipboard and Drag and Drop settings as Bidirectional to enable file sharing and drag and drop feature between your host and VM.

Enabling File Copy Between Host and Virtual Computer

   Step 10

Remove Floppy from the Boot Order settings in System / Motherboard and configure the Hard Disk device as the primary device.

Editing Boot Sequence

   Step 11

In System / Processor location, you can adjust the number of processors depending on the hardware features and performance of your host computer. For example, if you have an Intel i7 10th processor, you can set a minimum of 4 or 8 CPUs here.

Specifying the Number of Processors for VM

   Step 12

In the Display / Screen location, enable the Enable 3D Acceleration option for a more effective and quality display.

Graphics Controller / Enable 3D Acceleration

   Step 13

If you want to connect a USB 3.0 supported External HDD to the virtual machine, enable USB Controller and tick the USB 3.0 (xHCI) Controller option.

Enabling USB 3.0 Device

   Step 14

After making the necessary settings, you need to add the ISO image, which is the installation file of a Windows or another operating system, to your VM. To add the ISO file to the virtual computer, click on Storage / Empty / Optical Drive and click Choose/Create a Virtual Optical Disk from the opened options.

Adding a Windows Image File

   Step 15

Click the Add button to select the location of the ISO image in the Optical Disk Selector window.

Choosing the Location of the Image File

   Step 16

Select the relevant file from the location where you downloaded the ISO file and click the Open button.

Windows 7 ISO File

   Step 17

Check the Windows 7 image file you added and click the Choose button.

Choosing the Windows 7 ISO File

   Step 18

Click OK to close the settings of the Win7 virtual machine.

Closing the VM's Settings Window

   Step 19

Click the Start button to begin Windows 7 installation.

Running Windows 7 Virtual Machine

   Step 20

After clicking the Start button, you can now see that Windows is copying the necessary files.

Windows is loading files...

How to Uninstall / Delete VirtualBox on Ubuntu

After installing VBox on Ubuntu, a shortcut is created in the Show Applications menu, a VMs folder where virtual machines are installed in the Home location, and a folder in /usr/lib/where the necessary files are kept. Also, a new group called vboxusers is created in user groups.

To completely delete or remove VirtualBox from your system, you have to delete all these locations or files. The easiest way to do this is to use a terminal.

   Step 1

In the image below, you can see folders and shortcuts created in four different regions. Now move on to the next step to start deleting them completely from the system.

Shortcuts and Folders of Oracle Virtualization Software

   Step 2

First, execute the following command in the terminal to uninstall the Oracle software-dependent packages and setup files.

sudo apt remove --purge *virtualbox*

Uninstall Oracle VM from Ubuntu

   Step 3

In the Package section, press Y and then Enter to confirm the packages to be removed from your system.

Confirming Packages to be Removed

   Step 4

To delete the VirtualBox VMs folder in the Home location where the virtual machines are installed, execute the following command.

sudo rm -rf ~/"VirtualBox VMs"

Deleting the Folder Where Virtual Machines Are Installed

   Step 5

To delete the configuration files of all the settings you have made in the Oracle software, execute the following command.

sudo rm -rf ~/.config/VirtualBox/

Deleting VBox User Settings

   Step 6

After using the remove command, you will see a message in the terminal stating that the location /usr/lib/is not empty. You can delete the files in this location as you no longer need them, to do this, execute the command below.

sudo rm -rf /usr/lib/"virtualbox"

/usr/lib/virtualbox

   Step 7

Finally, one of the most important components you should delete is the VirtualBox user group. First, check if the vboxusers group removed with the compgen command, and then delete the group with the groupdel command.

compgen -g | grep -i "vbox"
sudo groupdel vboxusers

Deleting the Vboxusers Group

   Video

How to Install Older Versions of VirtualBox

You can also install and use Oracle software on older versions of Ubuntu. It is useful to always keep your Linux computer up to date. If you still prefer to use the old version, you can install this virtualization software on your system.

Ubuntu
Oracle VM
YouTube Video
Slide
17.10
5.x
18.04
5.x
18.10
5.x

   Final Word


In this article, we have installed the Oracle VM virtual machine software step by step on the Linux distribution and then configured the Extension Pack. Then we have created a new virtual machine and added the Windows 7 image to the VM as an example and ran it and checked it. Finally, we have examined how to remove VBox completely from the system. Thanks for following us!

   Related Articles


How to Install VirtualBox on Windows 10
How to Create Virtual Machine on VirtualBox
How to Install Windows 10 with VirtualBox
How to Update VirtualBox on Windows
How to Install Windows 7 with VirtualBox

Add a Comment

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

error: