Tuesday 14 December 2010

qemu-kvm w2k3 virtio disk drivers

1.) Download the disk-virtio ISO and copy the content into the guest's partition.
2.) Start VM and attach a disk:
virsh attach-disk w2k3 /mnt/bgerofi-virtual_machines/winxp/winxp.raw vdb --type disk --type file
3.) Specify the disk-virtio driver for the new SCSI device.
4.) Shutdown, undefine VM, modify xml and redifine VM so that disk is virtio.

Windows Server 2003 over qemu-kvm, "A disk read error occurred."

if you encounter a problem of getting the following error message after installing Windows Server 2003/XP in qemu-kvm, during boot:

"A disk read error occurred."

that is because:
(according to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=579166#17)

A run of testdisk on the raw image file detects a difference between
the disc geometry mentioned in the MBR and in the NTFS partitions
start sector. MBR says that there should be 255 heads and NTFS
partition boot sector assumes 16 heads.
I edidet the NTFS partition bootsector manual, and the problem went
away. When i do the setup with the plain qemu emulator there is also
no problem. For me it seems, that the it must be a problem between
seabios und the kvm. may be the kvm handels the bios information in a
different way?

Asume: A raw complete harddisc image within a bootable NTFS partition with XP or w2k3 on it.
Incident: when using these image with kvm based qemu, the system won't boot anymore

Solution:

1) set up the whole discimage as a loop device
- losetup /dev/loop0 /path/to/my/diskimage.raw
2) let kpartx create drive mappings for all partitions within the loop device
- kpartx -a /dev/loop0
3) you need to know on which partition your NTFS partition resides
- fdisk -l /dev/loop0
4) use the right partition mapping with hex-edit (eg. partition 1)
- hexedit /dev/mapper/loop0p1
5) look on hex position 0x1a, for the count of heads NTFS asumes
- in hexedit type enter and then 1A
6) change the value to 0xFF
- in hexedit type FF
7) save and exit hexedit
- press Ctrl+X to end
8) remove the partition mappings
- kpartx -d /dev/loop0
9) remove loop device
- losetup -d /dev/loop0