Skip to content

How to Install VirtualBox on Ubuntu & Debian

How to Install VirtualBox on Ubuntu & Debian

VirtualBox is a powerful x86 and AMD64/Intel64 virtualization product for enterprise and home use. This guide covers installing VirtualBox on Ubuntu and Debian Linux.


Prerequisites

  • Ubuntu 20.04+ / Debian 10+
  • Root or sudo access
  • Internet connection
  • Virtualization enabled in BIOS
  • At least 4GB RAM (8GB recommended)
  • 20GB free disk space minimum
Note: Enable VT-x/AMD-V in BIOS to run virtual machines.

Method 1: Install from Ubuntu Repository (Easiest)

Step 1: Update Package Lists

sudo apt update && sudo apt upgrade -y

Step 2: Install VirtualBox

sudo apt install virtualbox virtualbox-ext-pack -y
Success! VirtualBox is installed!

Method 2: Install from Oracle Repository (Recommended)

Step 1: Add Oracle VirtualBox Repository

sudo apt installsoftware-properties-common dkms -y
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc | sudo gpg --dearmor -o /usr/share/keyrings/oracle-vbox.gpg
echo "deb [signed-by=/usr/share/keyrings/oracle-vbox.gpg] https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list

Step 2: Update and Install

sudo apt update
sudo apt install virtualbox-7.1 -y

Available versions: virtualbox-7.0, virtualbox-7.1

Step 3: Download Extension Pack

For USB 2/3, VRDP, and disk encryption:

wget https://download.virtualbox.org/virtualbox/7.1.4/Oracle_VirtualBox_Extension_Pack-7.1.4.vbox-extpack
sudo VBoxManage extpack install Oracle_VirtualBox_Extension_Pack-7.1.4.vbox-extpack
Success! VirtualBox with Extension Pack is installed!

Launch VirtualBox

From Terminal

virtualbox

From Application Menu

  • Click “Activities” or applications icon
  • Search for “VirtualBox”
  • Click the VirtualBox icon

Install Guest Additions

Guest Additions enable shared folders, shared clipboard, better video support, and more.

Method 1: Using Device Menu

  • Start your virtual machine
  • Go to Devices → Insert Guest Additions CD Image
  • Run the installer inside the guest

Method 2: Install via Terminal

sudo apt update && sudo apt install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms -y

Create a Virtual Machine

Step 1: Create New VM

  • Click “New” in VirtualBox Manager
  • Enter a name (e.g., “Ubuntu 24.04”)
  • Select Type: Linux, Version: Ubuntu (64-bit)
  • Click Next

Step 2: Set Memory and CPU

  • Allocate RAM: 4096 MB minimum (8192 MB recommended)
  • CPUs: 2 (4 recommended)

Step 3: Create Virtual Hard Disk

  • Select “Create a virtual hard disk now”
  • Size: 25 GB minimum (50 GB recommended)
  • Select VDI (VirtualBox Disk Image)
  • Select “Dynamically allocated”

Step 4: Start the VM

  • Select your new VM
  • Click “Start”
  • Select the ISO file when prompted

VirtualBox Commands

List VMs

VBoxManage list vms

Start VM

VBoxManage startvm "VM-Name"

Power Off VM

VBoxManage controlvm "VM-Name" poweroff

Take Snapshot

VBoxManage snapshot "VM-Name" take "snapshot-name"

Check Version

VBoxManage --version

Update VirtualBox

Update via Repository

sudo apt update && sudo apt upgrade -y virtualbox-7.1

Update Extension Pack

VBoxManage extpack install --replace Oracle_VirtualBox_Extension_Pack-7.1.4.vbox-extpack

Uninstall VirtualBox

Remove VirtualBox

sudo apt remove -y virtualbox-7.1 virtualbox-7.0 virtualbox virtualbox-ext-pack

Remove Repository

sudo rm /etc/apt/sources.list.d/virtualbox.list

Troubleshooting

Virtualization Not Enabled

Error: VT-x/AMD-V is not enabled

Enable virtualization in BIOS settings.

Kernel Driver Not Installed

sudo modprobe vboxdrv

USB Not Working

Install Extension Pack and ensure user is in vboxusers group:

sudo usermod -aG vboxusers $USER

Guest Additions Not Working

Install required packages in guest:

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

Shared Folders Not Mounting

sudo mount -t vboxsf -o uid=1000,gid=1000 sharename /mountpoint

Nested Virtualization

Enable nested virtualization:

VBoxManage modifyvm "VM-Name" --nested-hw-virt on

System Requirements

  • Host: Any modern x86/x64 system
  • RAM: Minimum 4GB, recommended 8GB+
  • Disk: 20GB free for VirtualBox + VMs
  • Guest RAM: 1GB minimum per VM
  • Guest Disk: 10GB minimum per VM

Conclusion

VirtualBox is now installed! You can now:

  • Create and run virtual machines
  • Install multiple operating systems
  • Use Guest Additions for enhanced features
  • Take snapshots of your VMs
  • Share files between host and guest
Pro Tip: Enable 3D acceleration in VM settings for better graphics performance.