1
I have a copy of Windows XP installed on a hard drive which I would like to run with QEMU.
When I start it directly from the HDD it runs fine:
qemu -m 256 -hda /dev/sdc
Starting Windows...etc...etc...
Although the HDD capacity is 320GB, my system actually lives in a 4GB partition at the beginning of the disk:
/sbin/fdisk -l /dev/sdc
Disk /dev/sdc: 320 GB, 320070320640 bytes
255 heads, 63 sectors/track, 38913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 * 1 510 4096543 b FAT32
Warning: Partition 1 does not end on cylinder boundary.
So I figured I could only copy the partition table and the first partition (8192000 sectors) to a raw image for use with QEMU:
dd if=/dev/sdc of=winxp.img count=8192000
Of course, since winxp.img
is a copy of /dev/sdc
, it has exactly the same partition layout:
/sbin/fdisk -l winxp.img
Disk /mnt/windata/winxp.raw: 4 GB, 4186667520 bytes
255 heads, 63 sectors/track, 509 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/mnt/windata/winxp.raw1 * 1 510 4096543 b FAT32
Warning: Partition 1 does not end on cylinder boundary.
However, when I try to use the raw image with QEMU, the guest system won’t start:
qemu -m 256 -hda winxp.img
Booting from hard disk...
NTLDR is missing
What settings could I change to make my image file compatible with QEMU? Should I change something in the partition table, or in the partition itself, to make it work? Is there a QEMU option that could help?
Or is it perhaps possible to use a copy of /dev/sdc1
with QEMU instead of a copy of /dev/sdc
?
1
Trying to apply wisdom I have found here: http://manuel.kiessling.net/2013/03/19/converting-a-running-physical-machine-to-a-kvm-virtual-machine/
– Dmitry Grigoryev – 2015-04-02T09:38:55.580Tried to align the partition to cylinder boundary. Nothing changed: QEMU is still able to start Windows off the HDD, but not from the image file. – Dmitry Grigoryev – 2015-04-04T12:31:53.367
Tried to mount the image file on /dev/loop0 and start QEMU with that. Didn't work either. – Dmitry Grigoryev – 2015-04-04T12:36:08.673
So, booting from
sdc
is fine - why did you copysdb
then? And why only8192000
blocks? Did you try to copysdc
as a whole? Also, as per yourfdisk
output, disk "geometry" changed slightly, I wouldn't be surprised for NTLDR to barf :-\ Another thing: doesqemu
start when you usesdc1
? If so, try copyingsdc1
only, not the whole disk. – ckujau – 2015-04-08T01:10:42.950(1) I copied
sdc
of course, typo fixed. (2) I want to only copy the first 4GB because that's where my system lives, I don't have space on my linux machine to copy the entire 320 GB. I will try this with an external HDD. (3) What did change in the geometry exactly, apart from disk size? The partition of interest still starts on cylinder 1, ends on cylinder 510 and includes 4096543 of 1K blocks. (4) Already tried. QEMU need the partition table, so usingsdc1
is impossible. – Dmitry Grigoryev – 2015-04-08T08:32:18.2501Try to experiment with
qemu -hdachs
option to set proper geometry. – baf – 2015-04-09T07:46:22.307@baf this looks like the root cause of my problem, however, QEMU won't allow me to set
heads
to more than 16, and I have 255 (to be honest I don't quite understand why is this limitation enforced). Is it possible to somehow convert the disk geometry without losing the data, or perhaps switch to LBA mode? And should I convert my image to 16 heads, will I need reconvert it back to 255 heads if I decide to write it back on the disk? Is there a setup which will work on QEMU and physical disk alike? – Dmitry Grigoryev – 2015-04-09T11:21:29.277