Install Windows on Linux server with QEMU Virtualization
This guide explains how you can install and use KVM for creating and running virtual machines on a CentOS 6.4 server. I will guide to install Windows on Linux server with qemu virtualization step-by-step to demonstrate how this must be done. KVM is short for Kernel-based Virtual Machine and makes use of hardware virtualization, i.e., you need a CPU that supports hardware virtualization, e.g. Intel VT or AMD-V. (Note: I wrote this quite a long time ago but it seems the article was disappeared due to some data loss in the past)
1. First, check CPU requirement
Check to be sure if your CPU supports virtualization (otherwise nothing will work):
[root@canada ~]# egrep '(vmx|svm)' --color=always /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpidIf there is nothing displayed, your CPU does not support VT and I must say “Poor you ;-)”. If it is ok, continue to next steps 🙂
2. Install necessary softwares
[root@canada ~]# yum install kvm qemu-kvm python-virtinst libvirt libvirt-python virt-manager libguestfs-tools
[root@canada ~]# chkconfig libvirtd on
[root@canada ~]# service libvirtd start. Check if the above softwares were installed properly:
[root@canada ~]# service libvirtd status
libvirtd (pid 29269) is running...
[root@canada ~]# virsh -c qemu:///system list
Id Name State
----------------------------------------------------3. Setup network bridge
- Install bridge-utils tool:
[root@canada ~]# yum install bridge-utils - View current network configuration, remember BOOTPROTO, IPADDR, NETMASK, GATEWAY:
[root@canada ~]# less /etc/sysconfig/network-scripts/ifcfg-eth0 - Create a network bridge configuration at /etc/sysconfig/network-scripts/ifcfg-br0 with the following content (be sure TYPE=Bridge):
DEVICE="br0" NM_CONTROLLED="yes" ONBOOT=yes TYPE=Bridge BOOTPROTO=static IPADDR=XXX.XXX.XXX.XXX GATEWAY=YYY.YYY.YYY.YYY DEFROUTE=yes IPV4_FAILURE_FATAL=yes IPV6INIT=yes IPV6_AUTOCONF=no IPV6ADDR=ZZZZ:ZZZZ:ZZZZ:ZZZZ::1/128 NAME="System br0" - Change the /etc/sysconfig/network-scripts/ifcfg-eth0 and comment BOOTPROTO, IPADDR, NETMASK, GATEWAY, add BRIDGE=br0:
DEVICE=eth0 #BOOTPROTO=static #IPADDR=XXX.XXX.XXX.XXX #NETMASK=TTT.TTT.TTT.TTT ONBOOT=yes #GATEWAY=YYY.YYY.YYY.YYY IPV6INIT=yes IPV6_AUTOCONF=no IPV6ADDR=ZZZZ:ZZZZ:ZZZZ:ZZZZ::1/128 BRIDGE=br0 - Restart network interface:
/etc/init.d/network restart
4. Install Windows server to KVM
- View current supported os-variant (use rhel6 if you intend to install CentOS 6) by
[root@canada images]# virt-install --os-variant list - Download Windows 2008 ISO at Microsoft Website.
- Be sure to give the /dev/kvm the permission:
[root@canada images]# chown root:kvm /dev/kvm - Install a Windows 2008 with ISO at /var/lib/libvirt/images/win2k8-eval-180d.iso, 100G HDD, 3G RAM, 2vCPU:
virt-install -n Win2k8 --description "Win 2k8" --ram=3072 --vcpus=2 --os-variant=win2k8 --accelerate --hvm -c /var/lib/libvirt/images/win2k8-eval-180d.iso --network bridge:br0 --graphics vnc,listen=XXX.XXX.XXX.XXX,port=9999,password=abc123 --disk path=/home/kvm-images/Win2k8.img,size=100. Continue by opening VNC with port 9999 and follow the installation procedures.
- Managing the VM with some of the following commands (more commands HERE):
- View all VMs:
virsh list - Displaying guest Information:
virsh dominfo [domain-id, domain-name or domain-uuid] - Suspending a guest:
virsh suspend [domain-id, domain-name or domain-uuid] - Resuming a guest:
virsh resume [domain-id, domain-name or domain-uuid] - Shutting Down a guest:
virsh shutdown [domain-id, domain-name or domain-uuid] - Rebooting a guest:
virsh reboot [domain-id, domain-name or domain-uuid] - Terminating a guest:
virsh destroy [domain-id, domain-name or domain-uuid]
- View all VMs:
TroubleShooting
- To change a VM configuration, we can edit the XML file located at /etc/libvirt/qemu and then restart the VM to take the change into account.
- We can always check which is visible commands for managing each configuration by
virsh --help|egrep "info|mem". For example, if we want to change the max allow memory on the VM to 1.5G, we can run
virsh setmaxmem VMWin2k8 1536Mon a non-active VM.
- ERROR Guest name ‘Win2k8’ is already in use. Login to virsh to undefine that name:
[root@canada images]# virsh Welcome to virsh, the virtualization interactive terminal. Type: 'help' for help with commands 'quit' to quit virsh # undefine Win2k8 Domain Win2k8 has been undefined virsh # quit
One Comment