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.
- VirtualBox vs VMware vs Hyper-V vs WSL2
- Download and Install VirtualBox
- Download a Linux ISO
- Create a New Virtual Machine
- Optimize VM Settings Before First Boot
- Install Linux in the VM
- Install VirtualBox Guest Additions
- Set Up Shared Clipboard and Drag-and-Drop
- Set Up Shared Folders
- Take Snapshots
- Performance Tips
- Troubleshooting
VirtualBox vs VMware vs Hyper-V vs WSL2
| Tool | Cost | Host OS | Best for |
|---|---|---|---|
| VirtualBox 7 | Free | Windows, Mac, Linux | Testing distros, cross-platform dev |
| VMware Workstation Player | Free (personal) | Windows, Linux | Better performance, enterprise use |
| Hyper-V | Free (Windows Pro/Enterprise) | Windows only | Server workloads, integrated into Windows |
| WSL2 | Free | Windows only | Linux CLI tools without a full desktop |
| GNOME Boxes | Free | Linux only | Simple 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-archAlso 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:
- Choose "Install Ubuntu"
- Select language and keyboard
- Choose "Normal installation" and check both internet options
- Select "Erase disk and install Ubuntu" (this only erases the virtual disk, not your real one)
- Set timezone, username, password
- Wait for installation (~10 minutes)
- 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 rebootMethod 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 vboxserviceSet 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:
- Go to Devices → Shared Folders → Shared Folders Settings
- Add a folder: choose the host path, set a folder name, check "Auto-mount" and "Make Permanent"
- In the VM, add your user to the vboxsf group and reboot:
