# HOWTO: QEMU on FreeBSD



## vermaden (Nov 16, 2008)

I wrote short qemu howto install/usage on FreeBSD as host os, and in this example with Win2000 as guest os.

*changelog:*
1. removed useless */etc/qemu-ifup* script [it was used in older versions of qemu with tap/bridge interfaces]
2. added info about sound emulation inside qemu OS.
3. removed HACKS_CIRRUS from options [thx to *scottro* sugestion], reason here: http://forums.bsdnexus.com/viewtopic.php?pid=14036#p14036
4. sometimes OS installation requires unload of kqemu. short: install without kqemu and the use with kqemu​
Install *qemu with options showed below*:

```
# cd /usr/ports/emulators/qemu && make install clean
```


```
Options for qemu:
 [X] KQEMU          Build with (alpha!) accelerator module
 [ ] HACKS_CIRRUS   Large display speedup (buggy!)
 [ ] RTL8139_TIMER  allow use of re(4) nic with FreeBSD guests
 [ ] SAMBA          samba dependency (for -smb)
 [X] SDL            SDL/X dependency (graphical output)
 [X] CDROM_DMA      IDE CDROM DMA
```
install and configure sudo:

```
# cd /usr/ports/security/sudo && make install clean
```
sudo config:

```
# cat > /usr/local/etc/sudoers << EOF
root            ALL=(ALL) ALL
username        ALL=(ALL) NOPASSWD: ALL
EOF
```
username is YOU.

load needed modules:

```
# sudo kldload aio
# sudo kldload kqemu
```

create Windows2000 install CD image, use *cat* or *dd*:

```
% cat /dev/acd0 > ~/qemu/win2k.iso
% dd bs=2048 if=/dev/acd0 of=~/qemu/win2k.iso
```
create qemu image for new OS:

```
% qemu-img create -f qcow2 ~/qemu/win2000.img 4G
```
install new os, Windows2000 in our example:

```
% qemu -boot d -hda ~/qemu/win2000.img -m 128 -cdrom ~/qemu/win2k.iso -win2k-hack -localtime
```

if You have any problems while installing the OS then unload *kqemu* module and install again, then after install, load the *kqemu* module again:

```
% sudo kldunload kqemu
% qemu -boot d -hda ~/qemu/win2000.img -m 128 -cdrom ~/qemu/win2k.iso -win2k-hack -localtime
% sudo kldload kqemu
```

typical usage of OS under qemu:

```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime
```
typical usage of OS under qemu in snapshot mode [to commit made changes hit *left_CTRL+left_ALT+2* and type *commit*]:

```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -snapshot
```
*1.* to switch focus between qemu mouse focus and X11 mouse focus use: *left_CTRL+left_ALT*
*2.* to ensure that You use kqemu kernel module in user mode hit *left_CTRL+left_ALT+2* and type *info kqemu*, if everything is ok You will see:

```
kqemu support: enabled for user code
```
if not You will see:

```
kqemu support: disabled
```
if disabled it will work, but terribly slow, You will be running at Pentium 75 speed at host with CPU AthlonXP 1.66GHz.
*3.* to switch between qemu console and qemu os emualtion use *left_CTRL+left_ALT+2* to go to console and *left_CTRL+left_ALT+1* to back to emulation.
*4.* enabling network on emulated os, use DHCP configuration inside emulated os to get automatic IP adress 10.x.x.x

after You quit You os inside emulated os, or by qemu console *left_CTRL+left_ALT+2* and type *quit* use this command to launch again Your emulated OS:

```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime
```


How to have sound in qemu OS, You just need to launch qemu the way I listed above, only with *-soundhw sb16* or *-soundhw es1370* to emulate Sound Blaster 16, or Sound Blaster 128. You can also enable standart annoying BEEP with *-soundhw pcspk*. You can also enable all three of them like that:  *-soundhw sb16,es1370,pcspk*, or just BEEP + one of them: *-soundhw es1370,pcspk*, examples

```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw pcspk
```


```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw es1370,pcspk
```


```
% qemu -hda ~/qemu/win2000.img -m 256 -localtime -soundhw es1370,pcspk,sb16
```


*fluxbox* add-on:
in *~/.fluxbox/apps*:

```
# qemu
[app] (class=SDL_App)
  [Workspace]  {2}
  [Deco]       {BORDER}
[end]
```

resources:
*
man qemu-img
man qemu
man aio
man dd
man cat
http://kidsquid.com/cgi-bin/moin.cgi/QuickStartGuide
http://qemu-forum.ipi.fi/qemu-snapshots/
http://qemu-forum.ipi.fi/
http://qemu.org/user-doc.html
http://en.wikipedia.org/wiki/QEMU
*

The same schema works for *Solaris 10* and *WindowsXP*, You only do not use *-win2k-hack*.

*feel free to point errors, typo and Your hints/suggestions here.*


----------



## SPlissken (Nov 20, 2008)

Incredible , thanks for this 
Here is 2 screenshots





And this one, WinXP Service Pack 3 and video using Flash on french website Allocine (talking about movie)
No problem while watching the video, sound working too


----------



## lme@ (Nov 20, 2008)

How fast does XP run with kqemu?


----------



## SPlissken (Nov 20, 2008)

Well, it s on my laptop with 2 Go of ram
Here is part on dmesg
CPU: Intel(R) Core(TM)2 CPU         T7200  @ 2.00GHz (1995.02-MHz 686-class CPU)
  Origin = "GenuineIntel"  Id = 0x6f6  Stepping = 6

I allow 512 Mo to winXP , you can browse on internet and as i said you can watch flash movie , like those on youtube.


----------



## MG (Nov 23, 2008)

*Vista*

Tip: For Vista you need to steal the bios.bin file from the latest bochs port. Vista requires an ACPI and the qemu bios file does'nt have that, causing a BSOD during startup.


----------



## rliegh (Nov 24, 2008)

One comment and one question:
comment: It's probably better, and certainly easier to add yourself to the sudoers file using the visudo command. 

question: on several platforms (including freebsd 7.1/amd64) I've compiled qemu from source, including kqemu -only to find that the results of the "info kqemu" command is "support not compiled in". I've had this happen on Linux and OpenBSD (solaris too, I think -but I'm not sure). Most recently I had this happen on FreeBSD 7.1/amd64 (dispite *explicitly* selectiong the kqemu option).

Has anyone else encountered this and found a way around it?


----------



## vermaden (Nov 24, 2008)

I have been using QEMU only on i386 systems so I would not help here.


----------



## rliegh (Nov 24, 2008)

vermaden said:
			
		

> I have been using QEMU only on i386 systems so I would not help here.


It seems pretty hit-and-miss; but I just compiled qemu and it seems like this run does support kqemu.


----------



## caligula (Dec 12, 2008)

vermaden said:
			
		

> *1.* to switch focus between qemu mouse focus and X11 mouse focus use: *left_CTRL+left_ALT*




Hello,

use the qemu options "-usb -usbdevice tablet" and free your mouse by motion.


----------



## nox@ (Jan 3, 2009)

rliegh said:
			
		

> ...
> question: on several platforms (including freebsd 7.1/amd64) I've compiled qemu from source, including kqemu -only to find that the results of the "info kqemu" command is "support not compiled in". I've had this happen on Linux and OpenBSD (solaris too, I think -but I'm not sure). Most recently I had this happen on FreeBSD 7.1/amd64 (dispite *explicitly* selectiong the kqemu option).
> 
> Has anyone else encountered this and found a way around it?



I suspect you are using qemu 0.9.1 (emulators/qemu)?  If yes the answer is in the port's pkg-message (can also be read via `% pkg_info -D qemu\* |less`):

```
...
- also remember that on amd64 you need to run the amd64 (x86_64) system
emulation if you want to use kqemu, i.e. run qemu-system-x86_64 instead of
qemu (the latter only emulates a 32 bit system.)  ...
```

Btw, this has since changed in qemu svn, a snapshot of which is in ports as emulators/qemu-devel.


----------



## nox@ (Jan 3, 2009)

vermaden said:
			
		

> ...
> *changelog:*
> ...
> 3. removed HACKS_CIRRUS from options [thx to *scottro* sugestion], reason here: http://forums.bsdnexus.com/viewtopic.php?pid=14036#p14036



Actually that patch (HACKS_CIRRUS) no longer applied and has been removed from the qemu ports since.



			
				vermaden said:
			
		

> ...
> 4. sometimes OS installation requires unload of kqemu. short: install without kqemu and the use with kqemu



..or you can do: `% qemu -no-kqemu ...`



			
				vermaden said:
			
		

> ...
> *2.* to ensure that You use kqemu kernel module in user mode hit *left_CTRL+left_ALT+2* and type *info kqemu*, if everything is ok You will see:
> 
> ```
> ...



If you want kqemu to run (guest) kernel code too do: `% qemu -kernel-kqemu ...`  This is (usually) even faster, but works for less guests than userland kqemu, so you may need to experiment.



			
				vermaden said:
			
		

> ...
> resources:
> *
> man qemu-img
> ...



Also, there are FreeBSD host notes in the relevant qemu port's pkg-message(s) which can be read by
`% pkg_info -D qemu\* |less` if the port is installed (which also answer FAQs like the kqemu not compiled into the 32 bit qemu 0.9.1 on amd64), and there are the qemu-devel@nongnu.org and freebsd-emulation@FreeBSD.org mailing lists, see
http://lists.gnu.org/mailman/listinfo/qemu-devel and http://lists.freebsd.org/mailman/listinfo/freebsd-emulation respectively.  (a nice way to search FreeBSD mailinglists is also http://freebsd.markmail.org/search/.)

And finally, if you want to try svn snapshots: a (hopefully, but currently it seems to be) stable one is usually in ports as emulators/qemu-devel, and once in a while I post experimental port updates for more recent snapshots on the above mailing lists - testers are always welcome...


----------



## cloud (Jan 3, 2009)

A question with Qemu :

I have to log all incoming and outgoing traffic. But in my case, all the traffic use an existing interface, ath0 on my pc, and if I try to sniff, the guest address is nated so I can't know wich packets comes from the guest...

Someone have a solution ?


----------



## vermaden (Jan 4, 2009)

@nox

I havent updated it lately



			
				nox@ said:
			
		

> Also, there are FreeBSD host notes in the relevant qemu port's pkg-message(s) which can be read by ...



FreeBSD Handbook does not provide any info about FreeBSD as a host system:
http://freebsd.org/handbook/virtualization-host.html

I have created myself such page ans submited it for inclusion info the FreeBSD's Handbook, but there was lack of interest on the mailing lists for that unfortunelly :/
http://toya.net.pl/~vermaden/FreeBSD-Handbook-Virtualization.htm


----------



## nox@ (Jan 4, 2009)

cloud said:
			
		

> A question with Qemu :
> 
> I have to log all incoming and outgoing traffic. But in my case, all the traffic use an existing interface, ath0 on my pc, and if I try to sniff, the guest address is nated so I can't know wich packets comes from the guest...
> 
> Someone have a solution ?



Well, if you are using slirp (qemu's internal nat) your best bet is probably to     simply run tcpdump in the guest and transfer the log out later.  Otherwise you could use tuntap instead of slirp and sniff on the tap(4) interface, but since you are using wifi bridging will usually not work so you'd have to nat on the host instead. (using eg pf(4) or ipfw(8)/natd(8).)

 Oh, or maybe you could run qemu as an otherwise idle user and use pf(4) to log packets on sockets belonging to that user...


----------



## nox@ (Jan 4, 2009)

vermaden said:
			
		

> @nox
> 
> I havent updated it lately



Well this was more for the benefit of other readers than to criticise you... 



			
				vermaden said:
			
		

> ...
> FreeBSD Handbook does not provide any info about FreeBSD as a host system:
> http://freebsd.org/handbook/virtualization-host.html
> 
> ...



Oh, I hadn't seen that before!  Actually I had started some docbook myself a while ago that finally ended up in this thread (read the followups too): http://lists.freebsd.org/pipermail/freebsd-doc/2008-December/015224.html

 Maybe you can follow up to that...


----------



## vermaden (Jan 4, 2009)

nox@ said:
			
		

> Well this was more for the benefit of other readers than to criticise you...
> 
> I did not took your comment as something bad, imho good you pointed out updates that I havent checked lately.
> 
> ...



Nice work mate, I also havent seen it unfortunelly.

"follow up to that"? You mean include your work in mine part?


----------



## nox@ (Jan 4, 2009)

vermaden said:
			
		

> ...
> Nice work mate, I also havent seen it unfortunelly.
> 
> "follow up to that"? You mean include your work in mine part?



Follow up to that thread (hmm maybe this is usenet lingo and young ppl don't know it  - it means post an answer to that thread.)

 Anyway, yes you could make a `best-of-both' and post it on there... (preferably as a patch in docbook as I did it so others don't have to convert it.)


----------



## ninjaslim (Jan 8, 2009)

Thank you so much for this.  I really hope that VirtualBox gets ported though.


----------



## Maxamoto (Jan 13, 2009)

*usb_add hard drive?*

Is the assumption that it is impossible to add a USB Western Digital hard drive, either when launching qemu or via console (usb_add) correct? I have a 1TB WD hard drive that I have not been able to add at all. qemu doesn't see it with "info usbhost". I don't have it mounted from within FreeBSD. Here's the output of usbdevs -dv

# usbdevs -dv
Controller /dev/usb0:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub0
 port 1 powered
 port 2 powered
Controller /dev/usb1:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub1
 port 1 powered
 port 2 powered
Controller /dev/usb2:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub2
 port 1 powered
 port 2 powered
 port 3 addr 2: high speed, power 500 mA, config 1, Zune(0x0710), Microsoft(0x045e), rev 1.00
   ugen0
 port 4 powered
Controller /dev/usb3:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub3
 port 1 powered
 port 2 powered
Controller /dev/usb4:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub4
 port 1 addr 2: low speed, power 100 mA, config 1, Microsoft 5-Button Mouse with IntelliEye(TM)(0x0039), Microsoft(0x045e), rev 3.00
   ums0
 port 2 powered
Controller /dev/usb5:
addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub5
 port 1 powered
 port 2 powered
Controller /dev/usb6:
addr 1: high speed, self powered, config 1, EHCI root hub(0x0000), Intel(0x0000), rev 1.00
  uhub6
 port 1 addr 2: high speed, self powered, config 1, My Book(0x1100), Western Digital(0x1058), rev 1.65
   umass0
 port 2 powered
 port 3 powered
 port 4 powered
 port 5 powered
 port 6 addr 3: high speed, power 500 mA, config 1, Laptop Integrated Webcam(0x2640), OmniVision Technologies, Inc. -2640-07.07.20.3(0x05a9), rev 1.00
   ugen1


My command to launch the qemu vm is as such:

qemu -boot d -hda winxp.img -m 256 -cdrom -soundhw es1370 -usb -usbdevice tablet -localtime

Modifying this string, or attempting to add the device via qemu's console always ends in "could not add device" error. Thanks in advance for your help


----------



## adamk (Jan 13, 2009)

If the drive is detected under the FreeBSD host, why not just use "-hdb /dev/da0" (or whatever device the drive shows up as) when starting qemu?

Adam


----------



## Maxamoto (Jan 13, 2009)

adamk said:
			
		

> If the drive is detected under the FreeBSD host, why not just use "-hdb /dev/da0" (or whatever device the drive shows up as) when starting qemu?
> 
> Adam



Thanks for the suggestion. I'll give that a shot and see what happens


----------



## Maxamoto (Jan 13, 2009)

Worked perfectly! Thank you!


----------



## da_oli (Jan 30, 2009)

Great HowTo, but how can i get the network working.
On my old qemu installation i had a script that did something like this bevor qemu starts:
sudo ifconfig tap0 create
sudo /sbin/ifconfig tap0 0.0.0.0 promisc up
sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm xl0 up
sudo ifconfig bridge0 addm tap0

So, how is it working in this howto?

greets 

Oliver


----------



## da_oli (Jan 30, 2009)

Sorry for the double post, but i the solution i'm searching for is for the use of TUN/TAP-Network-Interfaces to get a complete access to the vm

greets

oliver


----------



## da_oli (Jan 30, 2009)

Okay and here is the solution 

I created a startup script for the first vm

```
#!/bin/sh
sudo ifconfig tap0 create
sudo ifconfig tap0 0.0.0.0 promisc up
sudo ifconfig bridge0 create
sudo ifconfig bridge0 addm em0 up
sudo ifconfig bridge0 addm tap0
sudo qemu -k de -boot c -hda test.img -m 512 -localtime -monitor stdio -usb -usbdevice tablet -net nic -net tap,ifname=tap0,script=no
```

and one for the second


```
#!/bin/sh
sudo ifconfig tap1 create
sudo /sbin/ifconfig tap1 0.0.0.0 promisc up
sudo ifconfig bridge0 addm tap1
sudo qemu -k de -boot c -hda test.img -m 512 -localtime -monitor stdio -usb -usbdevice tablet -net nic,macaddr=52:54:00:12:34:57 -net tap,ifname=tap1,script=no
```

Important in here is the MAC address, a very tricky thing for those who don't like to read manuals like me of course :stud

But okay, all qemu's use the same MAC 52:54:00:12:34:56
That's why its important to change the MAC on the following or all qemu's.

That works fine for me.

And sorry for the triple Post :e


----------



## MG (Feb 8, 2009)

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?


----------



## nox@ (Feb 8, 2009)

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
> ...



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


----------



## vermaden (Feb 8, 2009)

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
> ...



Maybe try the other way, first isntall Windows natively on desired partition, and then try to use it under QEMU.


----------



## fronclynne (Feb 11, 2009)

*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
> ...



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.


----------



## pradtf (Mar 1, 2009)

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?)


----------



## vermaden (Mar 1, 2009)

I havent used QEMU for ages now, I currently use VirtualBox @ OpenSolaris


----------



## ArtemD (Mar 3, 2009)

*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:


```
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.


----------



## vermaden (Mar 3, 2009)

@ArtemD

Thanks mate, QEMU is generally very nice, but its so slow ...


----------



## sossego (Mar 12, 2009)

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.


----------



## sossego (Mar 18, 2009)

this is common knowledge but I'd like to add in that one can make a shell script for each instance.


eg 
	
	



```
#!/bin/sh /usr/local/bin/qemu -m <X> -hda <X.img> -cdrom   <X/path> -soundhw <X> -boot c
```


----------



## z662 (Apr 9, 2009)

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


----------



## sossego (Apr 9, 2009)

Which version of qemu and kqemu? Developer's?


----------



## z662 (Apr 9, 2009)

I have qemu-0.9.1_10 installed


----------



## sossego (Apr 10, 2009)

Do you have the kqemu-kmod installed?


----------



## z662 (Apr 11, 2009)

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 (Apr 12, 2009)

You should be able to kldload.
	
	



```
echo kqemu_enable=YES >> /etc/rc.conf
```


----------



## z662 (Apr 13, 2009)

Ok ill give that a try and post back if I run into any problems. Thanks alot sossego!


----------



## graudeejs (Apr 13, 2009)

sossego said:
			
		

> You should be able to kldload.
> 
> 
> 
> ...


That is not right


It should be:

```
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

```
kldload aio
kldload kqemu
```


----------



## lme@ (Apr 16, 2009)

AFAIR aio is no longer needed in recent versions of qemu.


----------



## Albertos (Jun 20, 2009)

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 (Aug 6, 2009)

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
> ...




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:


```
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.


----------



## vermaden (Aug 6, 2009)

MG said:
			
		

> ```
> dd if=/dev/ad? of=/dev/zero bs=1m
> ```


Shouldn't this line look like that:

```
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.


----------



## MG (Aug 6, 2009)

vermaden said:
			
		

> Shouldn't this line look like that:
> 
> ```
> dd if=/dev/zero of=/dev/ad? bs=1m
> ...



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


----------



## vermaden (Aug 6, 2009)

MG said:
			
		

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


What backup sollution?



			
				MG said:
			
		

> dd if=/dev/zero of=/dev/ad? bs=1m count=1000
> 
> makes 1000 blocks of 1MB


Yes ... and?


----------



## MG (Aug 6, 2009)

I swapped the if and of, making dd copy /dev/ad? to /dev/zero. Fixed now.


----------



## Bernardslave (Feb 28, 2011)

While followed the howto an MP-BIOS bug: 
	
	



```
8254 timer not connected to IO-APIC
```
 error appeared. Any idea why this error?


----------



## sossego (Feb 28, 2011)

What system & OS are you emulating? http://www.google.com/search?q=8254...g.mozilla:en-US:unofficial&client=iceweasel-a
The first entry has the solution in the thread. This is for a Linux installation.


----------



## Bernardslave (Mar 1, 2011)

Oh thank you for the help, I'm trying to prove Fedora 14 in qemu over a FreeBSD 8.1 emulating by vmware. So I think I should watch bios settings of vmware.

Thanks again!


----------



## ernie (Jun 28, 2012)

Do I need to select the SDL/X option if I am just wanting to run headless machines with a VNC console? Not running Windows guest, just Linux/BSD VMs mostly LAMP. I tried Virtualbox with phpVirtualbox, but it's really messy stuff everywhere, hard to get going, looking for something simpler.


----------



## sw2wolf (Feb 22, 2014)

After `git clone [url=git://git.qemu-project.org/qemu.git]git://git.qemu-project.org/qemu.git[/url]`, how can I config it to support kqemu ?

Sincerely!


----------



## nox@ (Feb 22, 2014)

sw2wolf said:
			
		

> After `git clone [url=git://git.qemu-project.org/qemu.git]git://git.qemu-project.org/qemu.git[/url]`, how can I config it to support kqemu ?
> 
> Sincerely!


kqemu support has been dropped by upstream qemu a long time ago (since 0.12), and the kvm port was never finished.  So if you want reasonably fast virtualization you're better off using emulators/virtualbox-ose, or http://www.bhyve.org/

If you *really* want kqemu the emulators/qemu port is still available (at 0.11.1, last version that supported kqemu), but its still slower and less stable than the alternatives, and only works on 9.x and earlier.

HTH, (or at least a bit)
Juergen


----------



## zennybsd (Jul 10, 2014)

The bottlenecks are:

Virtualbox is slow, but the only working solution for any architecture as of these lines are written.  bhyve() is faster, but does not support amd64 SVM (there is a port but with the CURRENT release only).  qemu is easier to work, but the support has been discontinued.


----------



## Beastie (Jul 10, 2014)

zennybsd said:
			
		

> qemu is easier to work, but the support has been discontinued.


Support for what? A release candidate (2.1.0-rc1) has been released 2 days ago and the FreeBSD port seems to be following closely.


----------



## wblock@ (Jul 10, 2014)

VirtualBox is slow?  Well, that might depend on the processor and whether it supports VT-x.  But my VirtualBox VMs on a fast machine are faster than the real thing on mediocre hardware.  In other words, fast enough.  Although it might matter if someone wanted to use them for games, I have not tried that.


----------



## debguy (Jun 26, 2018)

i was told by sirdice:

just download the official .cow2 image

i then found (i downloaded qemu binary for windows 10) it was real darn easy.

just start quemu with the image and no options: works fine, bsd installs, automatically on internet read for further install


----------

