HOWTO: QEMU on FreeBSD

Does anyone know how and if it's possible to boot a system installed with qemu using a real physical harddrive?

First I did:
qemu -hda /dev/ad2 -cdrom ~/iso/winxppro.iso -m 512 -boot d
Then I installed windows from within qemu.

But when I try to boot my computer natively from ad2 (secondary master)
it does not recognize the bootsector and stops.
I think qemu does not correctly use the BIOS geometry settings or bootsector location.
Is there any workaround so I can boot the disk both natively and in Qemu?
 
MG said:
Does anyone know how and if it's possible to boot a system installed with qemu using a real physical harddrive?

First I did:
qemu -hda /dev/ad2 -cdrom ~/iso/winxppro.iso -m 512 -boot d
Then I installed windows from within qemu.

But when I try to boot my computer natively from ad2 (secondary master)
it does not recognize the bootsector and stops.
I think qemu does not correctly use the BIOS geometry settings or bootsector location.
Is there any workaround so I can boot the disk both natively and in Qemu?

I think the main problem with this is the fact that your guest is Windows - that doesn't usually like hardware being changed under it (and possibly also being moved to a different bios device like when going from the first ide disk in qemu to ad2 on the physical box) - there seem to be ways around the first problem (setting up separate hardware profiles), but I guess the simpler solution would be to keep separate installations, one physical on ad2 and one in an image that you run in qemu and then possibly share a common data partition with.

If you still want to share one install, here are two links I saved that _might_ help at least a little:
http://oopsilon.com/Running-a-Windows-Partition-in-VMware
and
http://www.virtualbox.org/wiki/Migrate_Windows
 
MG said:
Does anyone know how and if it's possible to boot a system installed with qemu using a real physical harddrive?

First I did:
qemu -hda /dev/ad2 -cdrom ~/iso/winxppro.iso -m 512 -boot d
Then I installed windows from within qemu.

But when I try to boot my computer natively from ad2 (secondary master)
it does not recognize the bootsector and stops.
I think qemu does not correctly use the BIOS geometry settings or bootsector location.
Is there any workaround so I can boot the disk both natively and in Qemu?

Maybe try the other way, first isntall Windows natively on desired partition, and then try to use it under QEMU.
 
biblically or philosophically? no, literally.

MG said:
Does anyone know how and if it's possible to boot a system installed with qemu using a real physical harddrive?

First I did:
qemu -hda /dev/ad2 -cdrom ~/iso/winxppro.iso -m 512 -boot d
Then I installed windows from within qemu.

But when I try to boot my computer natively from ad2 (secondary master)
it does not recognize the bootsector and stops.
I think qemu does not correctly use the BIOS geometry settings or bootsector location.
Is there any workaround so I can boot the disk both natively and in Qemu?

I have thought about trying it, but I haven't a spare drive (nor a place to plug one in), but I'm sure with some liberal applications of -drive (instead of -hda, -cdrom) you could obviate the controller swapping around. Whether this would solve it, I don't know.

Working with fat32 instead of ntfs would make it easier to poke around with in freebsd, but I'm not certain if that would gain you anything, if you lose your soul.
 
i'm using fbsd7.0

i just tried for qemu
make install clean
and got
File to patch:

however, doing the same on qemu-devel seems to be working fine.

what are you supposed to do when the File to patch: message comes up?
is the devel version less stable (and therefore less desirable?)
 
Well done on good howto!

Discovered Qemu yesterday and wow is it cool! I am specially excited about the VNC server that comes with Qemu. This allows you to run Qemu without X server. This is the command I use to start my Qemu in VNC session which I then tunnel via SSH:

Code:
qemu-system-x86_64 -hda ~/qemu/hda.img -boot d -cdrom ~/temp/cd.iso -m 1024 -localtime -vnc :0 -k fi -usb -usbdevice tablet -std-vga&

P.S. I am running FreeBSD 7.1 on AMD64.
 
The AMD solution for networking and such is at daemonforums.

Virtualbox? Nope, not even as a front end to qemu. The current work on VirtualBox for FreeBSD requires:
dev86 patch plus a tar.gz install of dev86, certain flags to be passed to the build process such as <force> and --disable-xpcom,
The make/kmk files to be text edited,
each directory to be built after entering,
and these must be done multiple times.
There are no build instructions for compiling the source.
dev86 needs to be patched so that the build will work on both i386 and amd64 machines.
 
this is common knowledge but I'd like to add in that one can make a shell script for each instance.


eg
Code:
 #!/bin/sh /usr/local/bin/qemu -m <X> -hda <X.img> -cdrom   <X/path> -soundhw <X> -boot c
 
I compiled qemu from ports and made sure that the kqemu accelerator was included as an option to be compiled, however kldload does not recognize kqemu, it is not in /boot/kernel or /boot/modules, and when typing "info kqemu" in the qemu userland it comes back saying that kqemu support had not been compiled. Does anyone know anything about this? Any help would be greatly appreciated. Thanks
 
No I didn't. I just installed it, so can I just use kldload and it would be loaded automatically, or do I need to reinstall?
 
sossego said:
You should be able to kldload.
Code:
echo kqemu_enable=YES >> /etc/rc.conf
That is not right


It should be:
Code:
echo kqemu_load=YES >> /boot/loader.conf
echo aio_load=YES >> /boot/loader.conf
Because it kernel module. And either should be loaded when booting or when needed with
Code:
kldload aio
kldload kqemu
 
Now I learned a new stuff. "qemu"

I am new to using freebsd by the way. Every single learnings from me is very important. I did not go to school for this. I just do a self study.

I am running putty/ssh right now and it is good.



Simulation pret
 
MG said:
Does anyone know how and if it's possible to boot a system installed with qemu using a real physical harddrive?

First I did:
qemu -hda /dev/ad2 -cdrom ~/iso/winxppro.iso -m 512 -boot d
Then I installed windows from within qemu.

But when I try to boot my computer natively from ad2 (secondary master)
it does not recognize the bootsector and stops.
I think qemu does not correctly use the BIOS geometry settings or bootsector location.
Is there any workaround so I can boot the disk both natively and in Qemu?


I solved this now. Qemu 10.6 seems to do it.
It works for real harddisks, usb-drives, memory disks and image-based md devices.

ad? can be any storage device:

Code:
dd if=/dev/zero of=/dev/ad? bs=1m count=1000
fdisk -Iqu /dev/ad?
bsdlabel -wB /dev/ad?s1
newfs -m 0 -o space /dev/ad?s1a
mount /dev/ad?s1a /mnt

cd /usr/src
make installkernel installworld DESTDIR=/mnt

umount /dev/ad?s1a
qemu -hda /dev/ad? -snapshot -m 1024

edit: Now we need a tool that can write Win32 bootcode to a unix device.
When that works it must be easy to boot Qemu with a Windows cdrom an install it to the existing location. Then the system can boot straight into Windows or start FreeBSD where Windows can be started in a virtual machine.
 
MG said:
Code:
dd if=/dev/ad? of=/dev/zero bs=1m
Shouldn't this line look like that:
Code:
dd if=/dev/zero of=/dev/ad? bs=1m
You are only reading whole disk into /dev/zero, also imho this step is just a waste of time here (zeroing the whole partition/drive).

You can zero only the first sectors to be sure that no junk is there.
 
vermaden said:
Shouldn't this line look like that:
Code:
dd if=/dev/zero of=/dev/ad? bs=1m
You are only reading whole disk into /dev/zero, also imho this step is just a waste of time here (zeroing the whole partition/drive).

You can zero only the first sectors to be sure that no junk is there.

lol. Not a good backup solution, that zero device.

dd if=/dev/zero of=/dev/ad? bs=1m count=1000

makes 1000 blocks of 1MB
 
Back
Top