Ubuntu on VirtualBox
VirtualBox lets you run a complete Ubuntu Linux installation inside a window on your current operating system — Windows, macOS, or another Linux. The Ubuntu install is isolated in its own virtual disk, so nothing on your host system is affected.
System Requirements
Your host machine (your laptop or desktop) needs:
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 8 GB | 16 GB+ |
| Free Disk | 25 GB | 40 GB+ |
| CPU | Dual-core | Quad-core |
| Virtualisation | VT-x/AMD-V enabled in BIOS |
To check if virtualisation is enabled on Linux:
grep -E 'vmx|svm' /proc/cpuinfo | head -1
# vmx (Intel) or svm (AMD) must appear
On Windows: open Task Manager → Performance → CPU → look for “Virtualisation: Enabled”.
Step 1: Download VirtualBox and Ubuntu ISO
# Download VirtualBox from:
# https://www.virtualbox.org/wiki/Downloads
# Choose the installer for your host OS (Windows, macOS, or Linux)
# Download Ubuntu 22.04 LTS ISO from:
# https://ubuntu.com/download/desktop
# File: ubuntu-22.04.3-desktop-amd64.iso (~5 GB)
# Verify the ISO checksum (optional but recommended)
sha256sum ubuntu-22.04.3-desktop-amd64.iso
# Compare against: https://ubuntu.com/download/desktop/thank-you
Step 2: Create the Virtual Machine
After installing VirtualBox, open it and click New:
| Setting | Recommended Value |
|---|---|
| Name | Ubuntu-22.04 |
| Type | Linux |
| Version | Ubuntu (64-bit) |
| RAM | 4096 MB (4 GB) |
| CPU | 2–4 cores |
| Video Memory | 128 MB |
| Disk | 25 GB (dynamically allocated) |
Important VM settings before starting (Settings → System):
- Processor tab: Enable PAE/NX
- Acceleration tab: VT-x/AMD-V (should be checked automatically)
Settings → Display:
- Video Memory: 128 MB
- Graphics Controller: VMSVGA
Step 3: Attach the Ubuntu ISO
- Go to Settings → Storage
- Click the Empty optical drive (disc icon)
- Click the disc icon on the right → Choose a disk file
- Select the Ubuntu
.isoyou downloaded - Click OK
Step 4: Install Ubuntu
- Click Start in VirtualBox
- The VM boots from the ISO — choose Try or Install Ubuntu
- Select Install Ubuntu
- Language: English → Continue
- Updates: Normal installation → Continue
- Installation type: Erase disk and install Ubuntu → Install Now
- This erases the virtual disk only — not your real hard drive
- Set timezone, username, and password
- Wait 10–20 minutes for installation to complete
- Restart when prompted — remove the virtual disc when asked (press Enter)
Step 5: Install Guest Additions
Guest Additions improve the VM experience: shared clipboard, auto-resize window, better graphics, and shared folders.
# After Ubuntu boots, open a terminal (Ctrl+Alt+T)
# 1. Install prerequisite packages
sudo apt update
sudo apt install -y build-essential dkms linux-headers-$(uname -r)
# 2. In VirtualBox menu: Devices → Insert Guest Additions CD image
# 3. Mount and run the installer
sudo mount /dev/cdrom /mnt
sudo /mnt/VBoxLinuxAdditions.run
# 4. Reboot
sudo reboot
After reboot:
- Drag the VM window to resize — Ubuntu desktop will auto-resize
- Copy/paste works between your host and the VM (enable in Settings → General → Advanced → Shared Clipboard: Bidirectional)
Step 6: Configure Shared Folders (Optional)
Shared folders let you access your host files from within the Ubuntu VM:
# In VirtualBox: Settings → Shared Folders
# Click the + icon
# Folder path: Choose a folder on your host (e.g., /Users/you/Desktop/shared)
# Folder name: shared
# Check: Auto-mount, Make Permanent
# After reboot, add your user to the vboxsf group
sudo usermod -aG vboxsf $USER
# Log out and back in
# Access the shared folder
ls /media/sf_shared/
# Your host files appear here
Step 7: Take a Snapshot
Snapshots let you save the VM state and roll back if something goes wrong — invaluable when learning:
# In VirtualBox:
# 1. With the VM running or paused, go to: Machine → Take Snapshot
# 2. Name: "Clean Ubuntu Install"
# 3. Click OK
# Now you can experiment freely — if you break something:
# Machine → Restore Snapshot → select "Clean Ubuntu Install"
Common VirtualBox Tips
# Increase VM RAM (shut down VM first)
# Settings → System → Motherboard → Base Memory
# Enable bidirectional clipboard
# Settings → General → Advanced → Shared Clipboard: Bidirectional
# Full-screen mode
# Host key (Right Ctrl) + F ← toggle fullscreen
# Host key (Right Ctrl) + H ← minimise
# Host key (Right Ctrl) + P ← pause VM
# Check Ubuntu version inside the VM
lsb_release -a
# Ubuntu 22.04.3 LTS
# Check VM resources from inside Ubuntu
nproc # Number of CPUs
free -h # RAM
df -h / # Disk space
Troubleshooting
| Problem | Solution |
|---|---|
| VM is very slow | Enable Hardware Acceleration in BIOS; increase RAM and CPU in VirtualBox settings |
| Screen is too small | Install Guest Additions (Step 5) |
| Copy/paste doesn’t work | Settings → General → Advanced → Shared Clipboard: Bidirectional |
| “VT-x is disabled” error | Enable virtualisation in your BIOS/UEFI settings |
| Network not working inside VM | Settings → Network → Adapter 1 → Attached to: NAT |
Key Takeaways
- VirtualBox lets you run Ubuntu inside your existing OS — no partitioning needed
- Allocate at least 4 GB RAM and 25 GB disk to the VM
- Guest Additions enable auto-resize, clipboard sharing, and shared folders
- Take a snapshot before major changes — rollback takes seconds
- The Ubuntu terminal inside VirtualBox is a real Linux environment
| ← Back to Setup & Environment | Next → WSL2 on Windows |