Posts mit dem Label VM werden angezeigt. Alle Posts anzeigen
Posts mit dem Label VM werden angezeigt. Alle Posts anzeigen

Donnerstag, 29. August 2013

Create Virtual Machine with Windows Guest using Qemu/KVM in Ubuntu Linux


I think Qemu/KVM represents a nice native alternative to Virtualbox or similar. Although all the GUI-tools (like aQemu or Qtemu) are broken in Ubuntu 13.04, it's really easy to setup a VM using the terminal. Precisely, you only need 3 commands to get a running VM:

  1. Create an image, where your VM is installed in. For Windows (>XP) take at least 18Gb:

    qemu-img create -f qcow2 ~/VMs/Windows\ 7/Windows\ 7.qcow2 18G

  2. Install your preferred OS in the created image:

    qemu-system-x86_64 -hda ~/VMs/Windows\ 7/Windows\ 7.qcow2 -cdrom ~/windows7_image_x64_.iso -boot d -m 4096 -cpu kvm64,+nx -enable-kvm

    Explanation for the parameters:
    This launches the typical Windows installation, whereas your new image represents your HDD to install to and -cdrom sets your installation media. The -boot parameter ensures that your VM boots the proper partition (you might can leave it out) and the option -m reserves 4096MB RAM for your VM (adapt it to your system). The -cpu parameter ensures that a 64-Bit CPU is emulated, because it's a KVM CPU you have to enable KVM in Qemu too.
    Note: Adapt the options to your system, especially in case your x86 user!
     
  3. After installation completed, launch your VM with:

    qemu-system-x86_64 ~/VMs/Windows\ 7/Windows\ 7.qcow2 -m 4096 -vga std -enable-kvm -cpu kvm64,+nx

    Of course you need to define the CPU again, enable KVM and set the memory. The option -vga std enables more and higher resolution within your VM, so use it if your are unsatisfied with low resolution.
     
That's it ! Of course you can also Linux VMs with it.

Two additional tips:
  • If your mouse pointer is caged within VM, free it with LEFT-[CTRL]+[ALT]
  • You can reach your Host from the Guest from the IP 10.0.2.2. This might be handy for web developers.