Install VirtualBox on Ubuntu 20.04. Also learn the commands to install VirtualBox extension pack on Ubuntu Linux. VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise as well as home use.
VirtualBox can run a “guest” operating system in a window of the host operating system without giving it direct access to your computer’s hardware. (Instead, Virtualbox passes hardware-related instructions through the “host” operating system’s drivers.) VirtualBox can run all versions of Windows, Linux, and many other x86- and AMD/Intel-based 32- and 64-bit operating systems as either a host OS or as a guest OS.
Oracle VM VirtualBox is useful in the following scenarios:
- Running multiple operating systems simultaneously. Oracle VM VirtualBox enables you to run more than one OS at a time. This way, you can run software written for one OS on another, such as Windows software on Linux or a Mac, without having to reboot to use it. Since you can configure what kinds of virtual hardware should be presented to each such OS, you can install an old OS such as DOS or OS/2 even if your real computer’s hardware is no longer supported by that OS.
- Easier software installations. Software vendors can use virtual machines to ship entire software configurations. For example, installing a complete mail server solution on a real machine can be a tedious task. With Oracle VM VirtualBox, such a complex setup, often called an appliance, can be packed into a virtual machine. Installing and running a mail server becomes as easy as importing such an appliance into Oracle VM VirtualBox.
- Testing and disaster recovery. Once installed, a virtual machine and its virtual hard disks can be considered a container that can be arbitrarily frozen, woken up, copied, backed up, and transported between hosts. On top of that, with the use of another Oracle VM VirtualBox feature called snapshots, one can save a particular state of a virtual machine and revert back to that state, if necessary. This way, one can freely experiment with a computing environment. If something goes wrong, such as prolems after installing software or infecting the guest with a virus, you can easily switch back to a previous snapshot and avoid the need of frequent backups and restores. Any number of snapshots can be created, allowing you to travel back and forward in virtual machine time. You can delete snapshots while a VM is running to reclaim disk space.
- Infrastructure consolidation. Virtualization can significantly reduce hardware and electricity costs. Most of the time, computers today only use a fraction of their potential power and run with low average system loads. A lot of hardware resources as well as electricity is thereby wasted. So, instead of running many such physical computers that are only partially used, one can pack many virtual machines onto a few powerful hosts and balance the loads between them.
Install VirtualBox from Oracle Repository
Run the following set of commands to install VirtualBox from Oracle Repository:
sudo sh -c 'echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" >> /etc/apt/sources.list.d/virtualbox.list'
NOTE: Add the following line to your /etc/apt/sources.list. According to your distribution, replace ” with ‘eoan’, ‘bionic’, ‘xenial’, ‘buster’, ‘stretch’, or ‘jessie’ (older versions of VirtualBox supported different distributions):
sudo apt update
sudo apt upgrade
sudo wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
sudo wget -q https://www.virtualbox.org/download/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt update
sudo apt install virtualbox-6.1
sudo wget https://download.virtualbox.org/virtualbox/6.1.8/Oracle_VM_VirtualBox_Extension_Pack-6.1.8.vbox-extpack
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.8.vbox-extpack
NOTE:
1. Use lsb_release -cs command to get the Ubuntu codename. For example, if you have Ubuntu version 20.04 the command will print focal.
2. During the installation of VBoxManage extpack, you will be presented with the Oracle license and prompted to accept their terms and conditions. “Do you agree to these license terms and conditions (y/n)?” You will have to type y and hit Enter to proceed the installation.
If you are experiencing The following signatures were invalid: BADSIG … when refreshing the packages from the repository? Run:
# sudo -s -H
# apt-get clean
# rm /var/lib/apt/lists/*
# rm /var/lib/apt/lists/partial/*
# apt-get clean
# apt-get update
Once installed, VirtualBox can be launched from the command line by typing virtualbox or using Ubuntu menu.