Categories
Unix Windows

Using virt-install with KVM to install Windows XP

As a follow-up to my post on installing centos 6x using KVM, I have since had the need to install a winXP ISO on my KVM host. I had to play with the commands a bit before hitting upon the right mix, so here it is:

virt-install --name=vm_xp --ram=512 --vcpus=1,cores=1 \
--disk path=/opt/vm_xp.img,size=4 --network bridge=br0 \
-c /opt/en_winxp_pro_sp3.iso --os-variant winxp --os-type windows --hvm \
--graphics vnc,password=1234,port=5905,listen=192.168.2.10
Categories
Unix

Expanding disk space on a KVM virtual machine

I use KVM on CentOS 6.2 and had a need to expand the disk space for one of the VMs. In some cases, it makes sense to have the VM’s disk space relatively small before you know how much you are going to need, and then expand it when ready. I hate having a few VMs that are running at 20% disk usage, knowing that I am wasting space. Of course, you could use your VM with auto-expanding space, but I don’t want the trade-off of reduced disk access speed.

So, in a succinct fashion here are the steps I used to get this done! In this example, my vm is called “vm10” and I’m adding 200G

  • <shutdown your VM if running>
  • <cd into your VM image directory>
  • mv vm10.img vm10.img.bk
  •  qemu-img create -f raw addon.raw 200G
  • cat vm10.img.bak addon.raw >> vm10.img
  • <start the VM>
  • fdisk /dev/vda
  • p
  • d
  • 2
  • p
  • n
  • p
  • 2
  • <enter>
  • <enter>
  • p
  • t
  • 2
  • 8e
  • p
  • w
  • reboot
  • pvdisplay
  • pvresize /dev/vda2
  • lvresize /dev/VolGroup00/LogVol00 -l +100%FREE
  • resize2fs /dev/VolGroup00/LogVol00
  • reboot

And there you go! A newly sized VM.