windows_vm_in_kvm_on_headless_ubuntu_server

This is an old revision of the document!


Windows VM in KVM/QEMU on headless Ubuntu server

without using libvirt

install kvm

apt-get install kvm qemu

now create a disk image

qemu-img create -f raw /vm/windows.img 100G

(note: creating a raw image has severale advantages: if your filesystem supports sparse files, it only uses the actually used space of your virtual disk on your physical disk.. all journalling filesystems that use inodes support that, so ext4 for example works fine. second you can easily mount it using mount -o loop <imgfile> <mountpoint> at any time. however, it does not support snapshots, use qcow2 if you need snapsots or if your filesystem does not support sparse files)

in my case i had a windows 7 cd that i installed from.. if your server dos not have a cd rom you can also us an iso image instead.

since I want to use virtio for fast hdd emulation, we also need the virtio drivers

cd /vm
wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso

run qemu and install windows. access the display via VNC

qemu-system-x86_64 -enable-kvm -k de-ch -name windows -vnc :1 -cdrom /dev/cdrom -boot d -drive file=/vm/windows.img,if=virtio,format=raw,index=0 -m 4096

now connect with your favourite vnc client to the ip of your server and install windows. you need to load the derivers from the second cdrom that is emulated. make sure you choose the correct virtio storage driver for your windows version. it may load the wrong one if you just select the root directory and let the installer search for it, resulting in an unstable windows vm

once the installation is done, shut down your windows vm. it is now time to make it autostart upon boot of your linux machine.. in order to do that i used Thomas Martin's kvm-simple-init of which i keep a local copy (dated 2016-01-23)

  • windows_vm_in_kvm_on_headless_ubuntu_server.1453561156.txt.gz
  • Last modified: 23.01.2016 15:59
  • by Pascal Suter