Is there a way to create a Windows virtual machine on Ubuntu Server?

Solution 1:

You should use KVM, because ... because Ubuntu love Kvm

what is KVM

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V).

Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc.

The kernel component of KVM is included in mainline Linux, as of 2.6.20.

Ubuntu uses KVM as the back-end virtualization for non-graphic servers and libvirt as its toolkit/API. Libvirt front ends for managing VMs include virt-manager (GUI).

Let's go to hack

This setup guide is to configure a KVM on Ubuntu Server and management of the VMs is done remotely from another machine running Ubuntu Desktop.

SERVER SIDE

STEP #1: Install lib-virt package.

sudo apt-get install kvm libvirt-bin  

STEP #2:allow incoming tcp and udp packet on port 22 (ssh) on server

sudo ufw allow 22

DESKTOP SIDE

STEP #2: Install Virtual Machine Manager (on Ubuntu Desktop machine).

sudo apt-get install virt-manager  

STEP #3: Connect to the server: execute virt-manager

gksudo virt-manager
  • FILE.
  • ADD Connection.
    • Connect to remote computer
    • Method : SSH
    • User : your user server
    • machine name : ip address of the server

NOW YOU ARE READY TO CREATE VIRTUAL MACHINE ON THE SERVER

STEP #4: Create the Guest VM image. Virtual Machine Manager provides a GUI to easily create an image. Just right-click on the server and select “New”. You will then be prompted step-by-step on the variables (e.g. # of processors, memory, etc.) needed to be configured for your VM.

STEP #5: Install the Guest VM OS. Use your regular CD/DVD installer or iso image to install the operating system on the VM.

More information in ubuntu official server Documentation -> here

Good Luck and Happy Rocking

P.S : you souldn't be afraid of command line.....

Solution 2:

VirtualBox (what you'll have been reading about in the desktop threads) has a few command line tools that allow you to run any virtual machine in a headless state.

An example would be:

VBoxHeadless -startvm vm_name

You would still need to set up the VM which can be done, I believe, with VBoxManage (VBoxManage --help for options there). It might be easiest to do initial configuration on a desktop and then transfer the config and disk image to the server.

If you want it to run on boot, you'd want to write an init or Upstart script for it to load, or just shove the command in /etc/rc.local as a lazy, unmanaged method (you'll probably want & on the end of the command so it doesn't block the system loading).

But similarly, you might have to use Upstart so it doesn't load up until networking has come up. Play around with it and let us know what works.

But you shouldn't need to compile anything.

Edit: There are some run-on-boot suggestions in this thread.

Edit 2: There are some old installation instructions here but what is really useful there are the example VBoxManage statements:

VBoxManage createvm -name "Ubuntu 8.04 Server" -register
VBoxManage modifyvm "Ubuntu 8.04 Server" -memory "256MB" -acpi on -boot1 dvd -nic1 nat
VBoxManage createvdi -filename "Ubuntu_8_04_Server.vdi" -size 10000 -register
VBoxManage modifyvm "Ubuntu 8.04 Server" -hda "Ubuntu_8_04_Server.vdi"
VBoxManage registerimage dvd /home/ubuntu-8.04.1-server-i386.iso
VBoxManage modifyvm "Ubuntu 8.04 Server" -dvd /home/ubuntu-8.04.1-server-i386.iso

You'll need to customise them for your situation but they should give you a good reference point.

Solution 3:

You didn't ask if you need open-source/free software or commercial.

This is a good commercial solution I am personally using:

http://www.vbridges.com