Linux VPS

Create a Linux server lab VM in VirtualBox

Install VirtualBox on Windows, macOS or Linux, create an Ubuntu Server VM, choose NAT or bridged networking, set up port forwarding for SSH, and use snapshots to practise safely.

BeginnerDesktop computers2 min read

Before trying risky commands on a real VPS, practise on a virtual machine on your own computer. VirtualBox is a free type 2 hypervisor that runs on Windows, macOS (Intel and, in recent versions, Apple silicon) and Linux. This guide shows how to create a Linux VM in VirtualBox that behaves like a small VPS.

Before you start

  • A computer with at least 8 GB RAM and 30 GB free disk.
  • Hardware virtualization enabled; see enable VT-x/AMD-V.
  • The VirtualBox installer from virtualbox.org and an Ubuntu Server ISO from ubuntu.com (ARM64 ISO on Apple silicon).

Install VirtualBox

Run the installer with default options. On Windows, if Hyper-V or WSL2 is enabled, VirtualBox still works but may be slower because it runs on top of Hyper-V.

Create the VM

  1. Click New, name it lab-ubuntu, select the ISO and type Linux / Ubuntu (64-bit). Tick Skip Unattended Installation if you want to see the installer.
  2. Hardware: 2048 MB RAM and 2 CPUs.
  3. Hard disk: create a 25 GB VDI, dynamically allocated.
  4. Finish, then start the VM and complete the Ubuntu Server installer. Tick Install OpenSSH server.

Choose networking

ModeBehaviourUse for
NAT (default)VM reaches internet; host reaches VM only via port forwardsSimple, works on any network
BridgedVM gets its own IP on your LANTesting services from other devices
Host-onlyPrivate network between host and VMsMulti-VM labs

SSH into the VM with NAT port forwarding

  1. Power off the VM, open Settings → Network → Adapter 1 → Advanced → Port Forwarding.
  2. Add a rule: host port 2222 → guest port 22.
  3. Start the VM and connect from your computer:
ssh -p 2222 youruser@127.0.0.1

Now practise exactly as on a VPS: first steps on a new VPS, firewalls, web servers.

Use snapshots

Take a snapshot (Machine → Take Snapshot) before experiments. If something breaks, restore it in seconds. This is the main advantage of a lab VM.

Troubleshooting

  • "VT-x is not available": enable virtualization in firmware, or another hypervisor is holding it.
  • Only 32-bit options shown: virtualization extensions are disabled.
  • SSH connection refused: OpenSSH not installed in the guest, or the port forward is missing.

Frequently asked questions

Is a VirtualBox VM the same as a VPS?

It runs the same OS and commands, but on your computer, behind your home network, without a public IP.

VirtualBox or WSL2?

WSL2 is great for Linux tools on Windows; a VirtualBox VM is closer to a real server with its own init system and network.

Can I move the VM to a real server?

Yes, export the disk and convert it; see convert disks to qcow2.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.