How to Install Linux in VirtualBox (Complete Guide)

Tested with: VirtualBox 7.0, Ubuntu 26.04 LTS guest — June 2026

VirtualBox lets you run Linux inside a virtual machine on Windows, macOS, or another Linux system. It's the fastest way to try any Linux distribution without touching your existing setup. This guide covers installing VirtualBox, creating a Linux VM, optimizing performance, and setting up Guest Additions for shared clipboard and dynamic screen resizing.

Contents
  1. VirtualBox vs VMware vs Hyper-V vs WSL2
  2. Download and Install VirtualBox
  3. Download a Linux ISO
  4. Create a New Virtual Machine
    1. Step 1: New VM Wizard
    2. Step 2: Hardware Settings
    3. Step 3: Virtual Hard Disk
  5. Optimize VM Settings Before First Boot
    1. Display → Screen
    2. System → Processor
    3. Storage
    4. Network
  6. Install Linux in the VM
  7. Install VirtualBox Guest Additions
    1. Method 1: From VirtualBox Menu
    2. Method 2: From Package Manager
  8. Set Up Shared Clipboard and Drag-and-Drop
  9. Set Up Shared Folders
  10. Take Snapshots
  11. Performance Tips
  12. Troubleshooting
    1. VM is very slow
    2. Screen won't resize after Guest Additions install
    3. "VT-x is not available" error
    4. USB device not detected in VM
    5. Further Reading

VirtualBox vs VMware vs Hyper-V vs WSL2

ToolCostHost OSBest for
VirtualBox 7FreeWindows, Mac, LinuxTesting distros, cross-platform dev
VMware Workstation PlayerFree (personal)Windows, LinuxBetter performance, enterprise use
Hyper-VFree (Windows Pro/Enterprise)Windows onlyServer workloads, integrated into Windows
WSL2FreeWindows onlyLinux CLI tools without a full desktop
GNOME BoxesFreeLinux onlySimple VMs on Linux desktop

Download and Install VirtualBox

Download VirtualBox from virtualbox.org/wiki/Downloads. Choose the package for your host OS:

  • Windows: download the .exe installer and run it
  • macOS: download the .dmg and follow the installer
  • Ubuntu/Debian: use the official repo or .deb package
# Install VirtualBox on Ubuntu/Debian
wget -O- https://www.virtualbox.org/download/oracle_vbox_2016.asc |   sudo gpg --dearmor --yes --output /usr/share/keyrings/oracle-virtualbox-2016.gpg

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/oracle-virtualbox-2016.gpg]   https://download.virtualbox.org/virtualbox/debian $(lsb_release -cs) contrib" |   sudo tee /etc/apt/sources.list.d/virtualbox.list

sudo apt update && sudo apt install virtualbox-7.0 -y

# Install on Fedora/RHEL
sudo dnf install @development-tools
sudo dnf install kernel-devel kernel-headers dkms elfutils-libelf-devel
sudo dnf install VirtualBox

# Install on Arch
sudo pacman -S virtualbox virtualbox-host-modules-arch

Also download the VirtualBox Extension Pack from the same page and install it from VirtualBox → File → Tools → Extension Pack Manager. It adds USB 2.0/3.0, RDP, and encryption support.

Download a Linux ISO

Get an ISO for the distro you want to test. Good choices for VMs:

  • Ubuntu 26.04 LTS — ubuntu.com/download/desktop (best hardware support in VMs)
  • Linux Mint 22 — linuxmint.com/download.php (very user-friendly)
  • Fedora 44 Workstation — fedoraproject.org/workstation (latest GNOME)
  • Debian 12 — debian.org/distrib (stable, lightweight)

Create a New Virtual Machine

Step 1: New VM Wizard

Open VirtualBox and click New. In the wizard:

  • Name: anything descriptive (e.g., "Ubuntu 26.04")
  • ISO Image: browse to your downloaded ISO
  • Type: Linux
  • Version: Ubuntu (64-bit) or whichever matches your ISO

Check Skip Unattended Installation if you want to do the installation yourself (recommended — gives you full control over partitioning and settings).

Step 2: Hardware Settings

Recommended VM resources:

  • RAM: 4 GB minimum for a desktop Linux (2 GB for a minimal/server install)
  • CPUs: 2–4 cores (don't allocate more than 50% of your host's cores)
  • Enable EFI: on for most modern distros

Step 3: Virtual Hard Disk

  • Size: 25 GB minimum, 40 GB recommended
  • Format: VDI (VirtualBox Disk Image) — default, fine for most uses
  • Storage: Dynamically allocated — only uses real disk space as the VM grows

Optimize VM Settings Before First Boot

Before starting the VM, go to Settings and configure:

Display → Screen

  • Video Memory: set to 128 MB
  • Graphics Controller: VMSVGA (required for Guest Additions dynamic resize)
  • Enable 3D Acceleration: on (improves desktop performance)

System → Processor

  • Enable PAE/NX
  • Enable VT-x/AMD-V (nested paging)

Storage

  • Check that your ISO is attached to the virtual optical drive (IDE Controller → Optical Drive)

Network

  • NAT (default) — VM gets internet access through the host. Simple and works.
  • Bridged Adapter — VM appears on your network as a separate device. Use when you need the VM reachable from other machines.

Install Linux in the VM

Start the VM. It boots from the ISO. Follow your distro's installation process — it's the same as a normal install. For Ubuntu:

  1. Choose "Install Ubuntu"
  2. Select language and keyboard
  3. Choose "Normal installation" and check both internet options
  4. Select "Erase disk and install Ubuntu" (this only erases the virtual disk, not your real one)
  5. Set timezone, username, password
  6. Wait for installation (~10 minutes)
  7. Restart when prompted — the ISO ejects automatically

Install VirtualBox Guest Additions

Guest Additions dramatically improve the VM experience: dynamic screen resizing, shared clipboard, shared folders, and better mouse integration. Install them after booting into your installed Linux:

Method 1: From VirtualBox Menu

In the VirtualBox window, go to Devices → Insert Guest Additions CD image. Then in the terminal:

# Ubuntu/Debian
sudo apt update
sudo apt install -y build-essential dkms linux-headers-$(uname -r)

# Mount and run the installer
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run

# Reboot
sudo reboot

Method 2: From Package Manager

# Ubuntu/Debian
sudo apt install virtualbox-guest-utils virtualbox-guest-x11

# Fedora
sudo dnf install virtualbox-guest-additions

# Arch
sudo pacman -S virtualbox-guest-utils
sudo systemctl enable --now vboxservice

Set Up Shared Clipboard and Drag-and-Drop

After installing Guest Additions, enable shared clipboard in Devices → Shared Clipboard → Bidirectional. Same for drag-and-drop. These let you copy-paste text between your host and the VM.

Set Up Shared Folders

Shared folders let the VM access a folder on your host system:

  1. Go to Devices → Shared Folders → Shared Folders Settings
  2. Add a folder: choose the host path, set a folder name, check "Auto-mount" and "Make Permanent"
  3. In the VM, add your user to the vboxsf group and reboot: