Resize Windows 7 Guest virtualised under KVM on Centos 6

centos6kvm-virtualization

I created a windows 7 virtual machine on Centos 6 running the following:

virt-install --name=W7VIRT64 --ram=768 --disk path=/var/lib/libvirt/images/guest1-win7-32,size=8 --vnc --network network=default --os-type=windows --os-variant=win7 --cdrom=/root/win7.iso

I was able to successfully install the guest OS and get it to boot.

How do I go about increasing the disk image size to 20G using non-gui tools?

Best Answer

First locate to your image directory. Then make sure your image is raw type. You can check it using

qemu-img info your_image

. If it is not raw type you can use

qemu-img convert

to convert it to raw type. Then:

dd if=/dev/zero of=temp bs=1G count=0 seek=20 #create temporary file of 20GB

cat temp >> your_image #append the temporary file to the end of your image

Next you may use gparted or partition magic to resize your partion. And last but not least just reboot you windows and let check disk utility to do its part. Good luck...C: