How to Run Linux as a Virtual Machine on Windows for Dual-OS Development Workflow


2 views

As developers, we often need access to Linux tools (like grep, awk, or Docker) while maintaining compatibility with Windows-only applications. Virtualization provides the perfect balance without dual-booting or maintaining separate machines.

The major options for Windows users are:

  • Oracle VirtualBox (free, open-source)
  • VMware Workstation Player (free for personal use)
  • Hyper-V (built into Windows Pro/Enterprise)
  • WSL 2 (lightweight alternative)

Here's how to create an Ubuntu VM (works similarly for other distros):

# Download VirtualBox and Ubuntu ISO first
# Create new VM with these settings:
VBoxManage createvm --name "UbuntuDev" --ostype "Ubuntu_64" --register
VBoxManage modifyvm "UbuntuDev" --memory 4096 --cpus 2
VBoxManage createhd --filename "ubuntu.vdi" --size 25000
VBoxManage storagectl "UbuntuDev" --name "SATA" --add sata
VBoxManage storageattach "UbuntuDev" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "ubuntu.vdi"
VBoxManage storageattach "UbuntuDev" --storagectl "SATA" --port 1 --device 0 --type dvddrive --medium "/path/to/ubuntu.iso"

For better performance:

  • Enable nested virtualization if your CPU supports it
  • Install Guest Additions for seamless mouse integration
  • Configure shared folders between host and guest
# After booting the VM, install Guest Additions:
sudo apt update
sudo apt install build-essential dkms linux-headers-$(uname -r)
# Then from VirtualBox menu: Devices > Insert Guest Additions CD image
sudo ./VBoxLinuxAdditions.run

Bridged networking gives your VM its own IP on the network:

VBoxManage modifyvm "UbuntuDev" --nic1 bridged --bridgeadapter1 "YourNetworkAdapter"

For developers who primarily need Linux CLI tools:

wsl --install -d Ubuntu
wsl --set-version Ubuntu 2
  • VT-x not available: Enable virtualization in BIOS
  • Slow performance: Allocate more RAM/CPU, enable 3D acceleration
  • Network problems: Check firewall settings, try NAT networking

As developers, we often need access to Linux tools (like grep, awk, or Docker CLI) while also requiring Windows applications (such as Adobe Creative Suite or specific IDEs). Virtualization provides the perfect solution without dual-booting or maintaining separate hardware.

Here are the most common solutions for running Linux VMs on Windows:

1. Oracle VM VirtualBox (Free, open-source)
2. VMware Workstation Pro (Paid, high performance)
3. Hyper-V (Windows built-in)
4. WSL 2 (Not full VM but lightweight alternative)

Let's walk through a complete Ubuntu installation:

  1. Download VirtualBox from virtualbox.org
  2. Get Ubuntu ISO from ubuntu.com/download
  3. Create new VM:
    VBoxManage createvm --name "UbuntuDev" --ostype Ubuntu_64 --register
    VBoxManage modifyvm "UbuntuDev" --memory 4096 --cpus 2
    VBoxManage createhd --filename "ubuntu.vdi" --size 20000
    VBoxManage storagectl "UbuntuDev" --name "SATA" --add sata
    VBoxManage storageattach "UbuntuDev" --storagectl "SATA" --port 0 --device 0 --type hdd --medium "ubuntu.vdi"
    VBoxManage storagectl "UbuntuDev" --name "IDE" --add ide
    VBoxManage storageattach "UbuntuDev" --storagectl "IDE" --port 0 --device 0 --type dvddrive --medium /path/to/ubuntu.iso
    
  4. Start the VM and complete Ubuntu installation

For better development experience:

# Enable shared folders
VBoxManage sharedfolder add "UbuntuDev" --name "code" --hostpath "C:\dev" --automount

# Set up port forwarding for web development
VBoxManage modifyvm "UbuntuDev" --natpf1 "http,tcp,,8080,,80"
VBoxManage modifyvm "UbuntuDev" --natpf1 "ssh,tcp,,2222,,22"

# Enable clipboard sharing
VBoxManage modifyvm "UbuntuDev" --clipboard bidirectional

To get near-native performance:

  • Enable 3D acceleration in VM settings
  • Install Guest Additions:
    sudo apt install build-essential dkms linux-headers-$(uname -r)
  • Allocate at least 25% of host RAM
  • Use SSD storage if available

If you don't need full desktop environment:

wsl --install -d Ubuntu
wsl --set-version Ubuntu 2
wsl --update