Linux Install & setup

Install Linux in a VM (VirtualBox)

Practical Linux guide: install Linux in a VM (VirtualBox) without the usual guesswork.

10 min read Beginner Updated 9 Jun 2026

Step-by-step guide

Work through each section in order. Stop when your issue is resolved — you do not need every step for every situation.

What you will achieve

A working Linux VM in VirtualBox with guest additions, bridged or NAT networking, and sane disk sizing — perfect for testing without risking bare metal.

1) Install VirtualBox on the host

# Debian/Ubuntu host
sudo apt install virtualbox virtualbox-ext-pack

# Fedora host
sudo dnf install VirtualBox kernel-devel-$(uname -r)

2) Create the VM

  1. New VM → type Linux, version matching your ISO (e.g. Ubuntu 64-bit).
  2. RAM: 2048 MB minimum for desktop, 1024 MB for minimal server.
  3. Create a virtual disk (VDI, dynamically allocated, 20–40 GB).
  4. Settings → Storage → attach ISO → start and install normally.

3) Guest Additions (better graphics and clipboard)

# Inside the VM after first boot (Debian/Ubuntu)
sudo apt install build-essential dkms linux-headers-$(uname -r)
# Devices menu → Insert Guest Additions CD → run:
sudo /media/cdrom/VBoxLinuxAdditions.run

4) Networking choices

  • NAT — VM reaches internet; host SSH port-forwarding needed for inbound.
  • Bridged — VM gets LAN IP like a physical machine.

Verify

VBoxManage list runningvms
ip -br a

5) Snapshots before risky changes

VirtualBox snapshots let you roll back failed upgrades. Take one named "clean-install" before testing firewall rules or distro upgrades.

VBoxManage snapshot "MyLinuxVM" take "before-upgrade"

6) CPU and I/O tuning

  • Enable VT-x/AMD-V in host BIOS if VMs fail to start 64-bit guests.
  • Assign two vCPUs for desktop; enable PAE/NX in VM settings.
  • Use VirtIO disk on KVM/libvirt hosts for better I/O — VirtualBox lacks VirtIO but benefits from fixed-size disks on HDD hosts.

7) Shared folders (host ↔ guest)

sudo usermod -aG vboxsf $USER
# mount -t vboxsf sharename /mnt/share

Log out and back in after group change. Shared folders are convenient but slower than SSH/rsync for large trees.

Headless server VMs

Skip guest additions and desktop packages. Install openssh-server, forward host port 2222 to guest 22, and manage via SSH from the host terminal.

8) Clone VM to template

VBoxManage export "MyLinuxVM" -o template.ova

OVA imports cleanly into other hypervisors for lab duplication.

Prerequisites

Host with virtualization enabled in BIOS (Intel VT-x / AMD-V). 8 GB host RAM minimum for comfortable desktop VM. ISO checksum verified. Disable Hyper-V on Windows hosts if VirtualBox reports conflicts — or use Hyper-V as hypervisor instead.

USB passthrough

VM settings → USB → add filter for specific devices. Useful for testing hardware-specific Linux drivers without bare-metal risk.

Kernel headers match

Guest additions build against uname -r — after kernel update in VM, re-run VBoxLinuxAdditions.run or DKMS module fails silently and shared folders break.

sudo apt install linux-headers-$(uname -r)

Related guides

in install linux vm