Table of Contents#
- Prerequisites
- Method 1: Install VirtualBox from Ubuntu Repositories
- Method 2: Install VirtualBox from Oracle’s Official Repositories
- Post-Installation Setup
- Verifying the Installation
- Uninstalling VirtualBox
- Troubleshooting Common Issues
- Conclusion
- References
Prerequisites#
Before installing VirtualBox, ensure your system meets these requirements:
1. System Requirements#
- Ubuntu 18.04 LTS (64-bit; 32-bit is unsupported by modern VirtualBox versions).
- At least 2 GB RAM (4 GB+ recommended for running guest OSes).
- Virtualization Technology (VT-x/AMD-V) enabled in your system’s BIOS/UEFI (critical for performance).
2. Check Virtualization Support#
To confirm your CPU supports virtualization, run:
egrep -c '(vmx|svm)' /proc/cpuinfo- If the output is
0, virtualization is disabled in BIOS/UEFI (see Troubleshooting to fix this). - If the output is
1or higher, virtualization is supported.
3. Update System Packages#
Always update your system before installing new software to avoid dependency conflicts:
sudo apt update && sudo apt upgrade -yMethod 1: Install VirtualBox from Ubuntu Repositories#
Ubuntu’s default repositories include a stable (but older) version of VirtualBox. This method is ideal for users prioritizing stability over the latest features.
Step 1: Install VirtualBox#
Run the following command to install VirtualBox and its dependencies:
sudo apt install virtualbox -y- The package name is
virtualbox(not version-specific). - Ubuntu 18.04 repositories typically ship with VirtualBox 5.2.x (older but well-tested).
Step 2: Install VirtualBox Extension Pack (Optional)#
The Extension Pack adds features like USB 3.0 support, disk encryption, and remote display. To install it:
-
Check your VirtualBox version:
virtualbox --versionExample output:
5.2.42_Ubuntur137960(version5.2.42). -
Download the matching Extension Pack from the VirtualBox Downloads Page (search for your version).
-
Install the Extension Pack via GUI:
- Launch VirtualBox → Go to File → Preferences → Extensions.
- Click the "+" icon, select the downloaded
.vbox-extpackfile, and follow prompts to accept the license.
Method 2: Install VirtualBox from Oracle’s Official Repositories#
For the latest VirtualBox version (e.g., 7.x), use Oracle’s official repositories. This ensures access to new features, security patches, and bug fixes.
Step 1: Add Oracle’s GPG Key#
Oracle signs its packages with a GPG key to verify authenticity. Import it:
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -- If you get a
wget: command not founderror, installwgetfirst:sudo apt install wget -y
Step 2: Add Oracle’s Repository#
Add the VirtualBox repository to your system. For Ubuntu 18.04 (Bionic), use:
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian bionic contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.listStep 3: Update Package List#
Refresh your system’s package index to include Oracle’s repository:
sudo apt updateStep 4: Install VirtualBox#
Install the latest VirtualBox version (replace 6.1 with the current stable version if needed, e.g., 7.0):
sudo apt install virtualbox-6.1 -y- Verify the installed version:
virtualbox --version
Step 5: Install the Latest Extension Pack#
For the latest Extension Pack, download it directly from Oracle:
wget https://download.virtualbox.org/virtualbox/6.1.46/Oracle_VM_VirtualBox_Extension_Pack-6.1.46.vbox-extpack(Replace 6.1.46 with your installed VirtualBox version.)
Install it via the command line:
sudo VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.46.vbox-extpackType yes to accept the license agreement.
Post-Installation Setup#
To use VirtualBox effectively, add your user to the vboxusers group. This grants permissions for USB devices, shared folders, and other features.
Add User to vboxusers Group#
Run:
sudo usermod -aG vboxusers $USER- Replace
$USERwith your username if you’re running the command as root. - Log out and log back in for the change to take effect.
Verifying the Installation#
1. Check Version via Command Line#
virtualbox --versionExample output: 6.1.46r158378 (confirms successful installation).
2. Launch VirtualBox GUI#
- From the command line:
virtualbox - From the Ubuntu applications menu: Search for “VirtualBox” and click the icon.
If the VirtualBox window opens without errors, the installation is complete!
Uninstalling VirtualBox#
Uninstall from Ubuntu Repositories#
If you installed via Method 1:
sudo apt remove --purge virtualbox -y
sudo apt autoremove -y # Remove leftover dependenciesUninstall from Oracle Repositories#
If you installed via Method 2 (replace 6.1 with your version):
sudo apt remove --purge virtualbox-6.1 -y
sudo apt autoremove -yTo remove Oracle’s repository and GPG key (optional):
sudo rm /etc/apt/sources.list.d/virtualbox.list
sudo apt-key del 2980AECF # Oracle's key fingerprint (verify with `sudo apt-key list`)Troubleshooting Common Issues#
1. Kernel Module Errors (“vboxdrv not loaded”)#
If VirtualBox fails to start with a kernel module error, install dependencies for building kernel modules:
sudo apt install dkms linux-headers-generic -yThen rebuild the VirtualBox kernel modules:
sudo /sbin/vboxconfig2. Enable Virtualization in BIOS/UEFI#
If egrep showed 0 earlier, enable virtualization in BIOS/UEFI:
- Reboot your system and press the BIOS key (varies by manufacturer: F2, F10, Del, or Esc).
- Navigate to the Security or Advanced tab.
- Find options like “Intel VT-x”, “AMD-V”, or “SVM Mode” and set them to Enabled.
- Save changes and exit BIOS/UEFI.
3. Extension Pack Version Mismatch#
Always install the Extension Pack version matching your VirtualBox version. Mismatched versions cause errors like “Extension pack is not compatible”.
Conclusion#
You now have VirtualBox installed on Ubuntu 18.04! Use Method 1 for stability or Method 2 for the latest features. Remember to enable virtualization in BIOS/UEFI and add your user to the vboxusers group for full functionality.
VirtualBox is a versatile tool—explore creating virtual machines for testing Linux distros, running Windows apps, or setting up development environments!