Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Create a Linux Virtual Machine in VirtualBox

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can create a Linux virtual machine in VirtualBox by downloading a Linux ISO, creating a new VM, and installing the OS. This guide walks you through the entire process, from downloading the ISO to installing VirtualBox Guest Additions for better performance.

What You'll Need

  • A computer with at least 4 GB of RAM (8 GB recommended) and enough free disk space (at least 20 GB for the VM).
  • VirtualBox installed. Download it from the official VirtualBox website for your host OS (Windows, macOS, or Linux).
  • A Linux distribution ISO file. Popular choices: Ubuntu, Linux Mint, Fedora, or Debian. Download the ISO from the distribution's official website.
  • Optional: Enable virtualization in your computer's BIOS/UEFI if it's not already enabled (most modern systems have it on by default).

Step-by-Step

  1. Download a Linux ISO. Go to the official website of your chosen distribution (e.g., ubuntu.com for Ubuntu) and download the desktop ISO file. Choose the 64-bit version unless you have a very old 32-bit machine.
  2. Open VirtualBox. Launch VirtualBox from your applications menu or desktop shortcut. You'll see the main manager window.
  3. Create a new VM. Click the "New" button (or press Ctrl+N). A dialog will appear.
  4. Name the VM and set OS type. Give your VM a name (e.g., "Ubuntu 22.04"). In the "ISO Image" field, click the folder icon and browse to your downloaded ISO file. VirtualBox will automatically detect the OS type and version. If it doesn't, set "Type" to "Linux" and "Version" to the appropriate option (e.g., "Ubuntu (64-bit)"). Click "Next".
  5. Set memory (RAM) size. Use the slider to allocate RAM. The recommended minimum is 2048 MB (2 GB). If you have enough RAM, 4096 MB (4 GB) is better. The green area indicates a safe range. Click "Next".
  6. Create a virtual hard disk. Choose "Create a virtual hard disk now" and click "Create". Accept the default VDI (VirtualBox Disk Image) file type. Choose "Dynamically allocated" so the disk grows as you use it. Set the size to at least 20 GB (25 GB is safer for modern distros). Click "Create".
  7. Start the VM. Select the VM in the VirtualBox manager and click "Start" (green arrow). The VM will boot from the ISO.
  8. Install Linux. Follow the on-screen installer. You'll usually be asked to choose your language, keyboard layout, and installation type. For a typical setup, select "Erase disk and install" (this only affects the virtual disk, not your real computer). Follow the prompts to create a user account and password.
  9. Reboot the VM. After installation, the installer will ask to restart. When prompted, remove the ISO (or press Enter to reboot). In VirtualBox, you can also go to Devices > Optical Drives > Remove disk from virtual drive before rebooting.
  10. Install VirtualBox Guest Additions. After the VM boots into your new Linux system, go to the VM menu bar: Devices > Insert Guest Additions CD image. Inside the VM, open a terminal and run the following commands (for Ubuntu/Debian):
    sudo apt update && sudo apt install -y build-essential dkms linux-headers-$(uname -r)
    Then mount the CD and run the installer:
    sudo mount /dev/cdrom /media/cdrom
    sudo /media/cdrom/VBoxLinuxAdditions.run
    Reboot the VM. This enables better screen resolution, clipboard sharing, and drag-and-drop.

Common Mistakes

  • Not enabling virtualization in BIOS. If you get an error like "VT-x is not available," you need to enable Intel VT-x or AMD-V in your BIOS/UEFI settings.
  • Allocating too little RAM. Linux may run extremely slowly or fail to install with less than 2 GB. Check your host's available RAM before setting the VM memory.
  • Choosing the wrong ISO architecture. Make sure you downloaded the 64-bit ISO if your host is 64-bit and your VM is set to 64-bit.
  • Forgetting to remove the ISO after installation. The VM may boot back into the installer instead of your installed system. Remove the ISO from the virtual drive.
  • Skipping Guest Additions. Without them, the screen resolution is stuck at a low value and copy/paste between host and guest won't work.

Tips

  • Take a snapshot of the VM after a clean installation. In VirtualBox, go to Machine > Take Snapshot. This lets you revert to a working state if you break something later.
  • Use the "Bidirectional" clipboard mode (Devices > Shared Clipboard > Bidirectional) after installing Guest Additions to copy text between your host and the VM.
  • Set up a shared folder for easy file transfer: Devices > Shared Folders > Shared Folders Settings. Choose a host folder and make it permanent.
  • If your Linux VM runs slowly, increase video memory in the VM settings (Display > Video Memory) to 128 MB, and enable 3D acceleration if your host supports it.
  • For a lighter experience, choose a lightweight distribution like Xubuntu or Lubuntu if your computer has limited resources.

Troubleshooting

VM won't start or shows "VT-x is not available." Restart your computer and enter BIOS/UEFI (usually by pressing F2, F10, Del, or Esc during boot). Look for a setting like "Intel Virtualization Technology" or "AMD-V" and enable it. Save and exit.

Black screen during installation. This often happens with newer graphics cards. Try changing the VM's graphics controller: In VM settings, go to Display > Graphics Controller and try "VMSVGA" or "VBoxSVGA". Also, try disabling 3D acceleration temporarily.

Mouse not working inside the VM. Press the right Ctrl key to release the mouse. If the mouse is not captured at all, check that the VM's USB settings are set to USB 2.0 or 3.0 (Settings > USB).

Guest Additions fail to install. Make sure you installed the required packages (build-essential, dkms, linux-headers). If you see an error about missing kernel headers, run sudo apt install linux-headers-$(uname -r) again and retry.

VM is very slow. Allocate more RAM and CPU cores in VM settings (Settings > System > Processor). Also, ensure that your host has enough free resources. Closing other applications helps.

Can't resize the VM window. This is almost always because Guest Additions are not installed. Follow step 10 to install them.

Frequently Asked Questions

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

Yes, but you need to download a 32-bit ISO and set the VM version to "Linux (32-bit)". However, most modern distributions have dropped 32-bit support, so you may need an older release.

How much disk space should I allocate?

At least 20 GB for a desktop Linux installation. If you plan to install many applications or store files inside the VM, allocate more (e.g., 50 GB). Dynamically allocated disks only use the space you actually use.

Can I move the VM to another computer?

Yes. In VirtualBox, use File > Export Appliance to create an OVA file, then import it on the other computer. Alternatively, copy the VM folder (with the .vdi file) and use Machine > Add to register it.

Is it safe to install Linux in VirtualBox?

Yes. The VM is isolated from your host system. Changes inside the VM don't affect your real operating system. Just be careful not to share sensitive folders unless you intend to.

Why is my VM screen resolution stuck at 800x600?

Install VirtualBox Guest Additions (step 10). After installation and reboot, the VM will automatically adjust to the window size.

Can I use a USB drive inside the VM?

Yes. With the VM running, 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 available on the VirtualBox download page.