If you want to create a Windows KVM guest you will need first a running KVM installation. Just follow the steps below:
Install the KVM Windows guest
create the qcow2 disk image (in the example, the image file size is set to 15GB)
$ qemu-img create -f qcow2 -o preallocation=metadata /var/lib/libvirt/images/win7.qcow2 15G
get the virtio iso image
cd /var/lib/libvirt/images $ wget https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
copy your Windows 7 disk iso file to the folder /var/lib/libvirt/images
edit the qemu configuration file
$ vi /etc/libvirt/qemu.conf
modify the following lines
vnc_listen = "0.0.0.0" vnc_password = "yourownpassword"
create the guest (answer the questions. In my example, I have set the guest name to ‘win7’)
$ virt-install --connect=qemu:///system --prompt --vnc --vnclisten=0.0.0.0 \ --vncport=5905 --disk path=/var/lib/libvirt/images/win7.qcow2,format=qcow2,bus=virtio \ --disk path=/var/lib/libvirt/images/virtio-win.iso,device=cdrom \ --cdrom /var/lib/libvirt/images/win7inst.iso --os-type=windows What is the name of your virtual machine? win7 How much RAM should be allocated (in megabytes)? 1024 Starting install... Creating domain... | 0 B 00:03 WARNING Unable to connect to graphical console: virt-viewer not installed. Please install the 'virt-viewer' package. Domain installation still in progress. Waiting for installation to complete.
Now, if you plan to use a Windows station to connect to your KVM guest using VNC, you will have to install UltraVNC viewer. I have encountered a problem to connect to my vm guest using the RealVNC viewer.
Create a VNC session to the ip address of the KVM Host and the vnc port set to “5905” (set in the virt-install command above).
Connect on your KVM guest and configure the disk driver to install Windows properly as shown below:
Click on “Custom (Advanced)”
Click on “Load drivers”
Click on the “OK” button, unselect the tick “Hide…” and then click on the “Browse” button
Browse the VirtIO iso drive and go to the OS folder you are currently installing
Click on the “Next” button to load the drivers
Click on the “Next” button to install Windows on the detected drive
You are done. Install process is running !
Clone a KVM guest
Cloning an existing KVM guest is also quiet simple. The steps are:
Create the qcow2 disk image for the clone
qemu-img create -f qcow2 -o preallocation=metadata /var/lib/libvirt/images/win7_clone.qcow2 15G
Clone the guest
virt-clone –connect=qemu:///system -o win7 -n win7_clone -f /var/lib/libvirt/images/win7_clone.qcow2 –force
- Active Directory
- Files and folders
- Operating System
- Service and process