sodcalculator

10 Tech How-To

Setup Linux Virtual Machine VirtualBox

Guide 10-44324 · Updated · Step by step

To set up a Linux virtual machine in VirtualBox, you download a Linux distribution ISO, create a new virtual machine, attach the ISO, and follow the installer. This guide walks through the entire process with exact menu names and settings for current VirtualBox versions.

What You Need Before Starting

VirtualBox runs on Windows, macOS, and Linux hosts. You need:

  • VirtualBox installed from the official website (virtualbox.org). Current versions are 7.x for most platforms.
  • A Linux ISO file – Ubuntu, Linux Mint, Fedora, or Debian are the most common choices. Download the 64-bit desktop ISO from the distribution’s official site.
  • At least 10 GB of free disk space for the virtual disk, plus RAM to allocate (2 GB minimum for a desktop Linux, 4 GB recommended).
  • Virtualization enabled in BIOS/UEFI – most modern PCs have it on by default, but if you see an error about VT-x/AMD-V, you’ll need to enable it in firmware settings.

Creating the Virtual Machine

  1. Open VirtualBox and click New (or press Ctrl+N).
  2. Give the VM a name (e.g., “Ubuntu 24.04”). VirtualBox auto-detects the type and version from the name, but you can set them manually: Type = Linux, Version = Ubuntu (64-bit) or the matching distribution.
  3. Set Memory size – 2048 MB minimum, but 4096 MB is smoother for desktop use. Do not exceed half of your host’s RAM.
  4. Choose Create a virtual hard disk now, then click Create.
  5. Select VDI (VirtualBox Disk Image) as the file type.
  6. Choose Dynamically allocated – the file grows as you use space, saving host disk.
  7. Set the disk size – 20 GB is a safe minimum for a desktop Linux, 50 GB if you plan to install many applications.

Attaching the ISO and Booting

  1. Select the VM in the VirtualBox Manager and click Settings.
  2. Go to Storage – under the Storage Devices tree, click the empty optical drive (often labeled “Empty”).
  3. On the right, click the disk icon next to Optical Drive, choose Choose a disk file…, and select your Linux ISO.
  4. Click OK to save settings.
  5. Select the VM and click Start (or double-click). The VM will boot from the ISO.

Installing Linux Inside the VM

The installer varies by distribution, but the general steps are the same:

  1. Choose Try or Install – you can test the live environment first, then click the Install icon on the desktop.
  2. Select your language and keyboard layout.
  3. For installation type, choose Erase disk and install Linux – this only affects the virtual disk, not your host.
  4. Set your time zone, create a username and password.
  5. Wait for the installation to finish (usually 5–15 minutes), then click Restart Now.
  6. When prompted, press Enter to reboot. The VM will eject the ISO automatically.

Installing Guest Additions (Important)

Guest Additions are drivers and tools that make the VM usable: proper screen resolution, mouse integration, shared clipboard, and drag-and-drop. Without them, the display is stuck at a low resolution and the mouse is captured awkwardly.

  1. With the VM running, go to the VirtualBox menu Devices → Insert Guest Additions CD image….
  2. Inside the VM, open a terminal and run the installer. On Ubuntu/Debian, you need build tools first: sudo apt update && sudo apt install build-essential dkms linux-headers-$(uname -r).
  3. Mount the CD and run sudo sh /media/cdrom/VBoxLinuxAdditions.run (the path may vary).
  4. Reboot the VM. You’ll now have a full-resolution display and shared clipboard.

Common Problems and Fixes

  • VT-x/AMD-V not enabled – Restart your computer, enter BIOS/UEFI (usually Del or F2), find the virtualization setting (often under Advanced or CPU Configuration), enable it, and save/exit.
  • No network connection – By default, VirtualBox uses NAT. If you have no internet, check the VM’s network adapter is set to NAT or Bridged. Bridged gives the VM its own IP on your LAN.
  • Black screen on boot – Try disabling 3D acceleration in VM Settings → Display, or increase video memory to 128 MB.
  • Slow performance – Allocate more RAM and CPU cores (Settings → System → Processor). Enable hardware acceleration if available.
  • Guest Additions won’t install – Make sure the kernel headers match your running kernel. Run sudo apt install linux-headers-$(uname -r) first.

Choosing a Linux Distribution

For beginners, Ubuntu or Linux Mint are the most forgiving – they have large communities and easy installers. Fedora is more cutting-edge but stable. Debian is rock-solid but has older packages. If you have a low-spec host, Lubuntu or Xubuntu use lighter desktops. For a server, choose Ubuntu Server or Debian without a GUI. You can also try Arch if you want to learn the internals, but it’s not recommended for a first VM.

Performance and Resource Settings

VirtualBox lets you adjust:

  • RAM – Set to at least 2 GB, but 4 GB is comfortable. Don’t allocate more than half your host’s RAM.
  • CPU cores – Give the VM 2 cores if your host has 4 or more. More cores help compile code or run heavy apps.
  • Video memory – 128 MB is the max for most VMs. Enable 3D acceleration if you need desktop effects.
  • Storage controller – Use SATA by default. NVMe is faster but not always supported by older Linux kernels.
  • Paravirtualization – Set to Default or KVM for better performance on Linux hosts.

Frequently Asked Questions

Can I run a 32-bit Linux VM on a 64-bit host?

Yes, but you must download a 32-bit ISO and create a 32-bit VM. VirtualBox will show 32-bit options only if the host CPU supports them (most do). However, 32-bit Linux is becoming rare – most distributions dropped 32-bit builds.

How do I share files between host and VM?

After installing Guest Additions, go to VM Settings → Shared Folders, add a host folder, and set it to Auto-mount. Inside the VM, it appears under /media/ (or /mnt/ on some distros). You can also use drag-and-drop if enabled in Devices → Drag and Drop.

Why is my VM so slow?

Common reasons: not enough RAM, no Guest Additions, or too many CPU cores allocated (which can cause contention). Also, make sure you’re not running other heavy apps on the host. A solid-state drive for the host improves disk I/O significantly.

Can I run Windows inside a Linux VM?

Yes, but it’s the opposite setup – you’d need a Windows ISO and a license. VirtualBox works the same way. Performance may be lower than native, but it’s fine for testing or light use.

How do I take snapshots?

With the VM powered off, click the Snapshots button (or Machine → Take Snapshot). Snapshots let you revert to a previous state – useful before risky experiments. Note that snapshots consume disk space.

Can I use a USB drive in the VM?

Yes, after installing Guest Additions, go to Devices → USB and select your USB device. You may need to install the VirtualBox Extension Pack for USB 2.0/3.0 support. The Extension Pack is free but under a different license.

Alternatives to VirtualBox

If VirtualBox gives you trouble, consider:

  • VMware Workstation Player – Free for personal use, similar features.
  • GNOME Boxes – Simpler, but fewer options; good for quick tests.
  • KVM/QEMU – Built into Linux, very fast, but steeper learning curve.
  • Hyper-V – Windows-only, but integrated into Windows Pro/Enterprise.

Each has its own settings and quirks, but the general workflow of ISO + VM creation is the same.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →