What is QEMU: QEMU is a FAST! processor emulator using dynamic translation to achieve good emulation speed.
It's the best emulator I've ever seen. That's why I took some time to rewrite an howto about it.
Like the old howto I chose to run DragonFlyBSD as guest OS on a NetBSD-current (3.99.3) system as host OS.
The qemu directory I use is ~/qemu.
1. Install the qemu package
# cd /usr/pkgsrc/emulators/qemu/
# make install clean
Today's pkgsrc version is 0.6.1 (nb4)
2. Download DragonFlyBSD (Optional)
Today's version is 1.2
I got in from a french mirror. The file is called dfly-1.2.0_REL.iso.gz.
The file has to be gunzipped before use.
# cd ~/qemu/
# mkdir imgs
# cd imgs
# gunzip dfly-1.2.0_REL.iso.gz
3. Create a disk image (still in ~/qemu/imgs/)
# qemu-img create -f qcow dfly.qcow 4G
This creates a 4Gb qcow format disk image file called dfly.qcow
Why qcow over raw or ... ? The qcow format compresses the image so that the empty space doesn't add up to the size of the file.
So the image doesn't take 4Gb of disk space but only the needed space!
4. Run qemu !
# qemu -m 256 -cdrom dfly-1.2.0_REL.iso -hda dfly.qcow -boot d
This means I allocate 256Mb of memory (RAM), cdrom is will be the iso image and the hard disk the image file we created the step before and boot on D ( = cdrom).
Beware! On NetBSD systems you can get a "Could not allocate physical memory" it is due to ulimit that actually limits datasize (run `limit` to see this). So you have two choices. Make it unlimited with `ulimit -d unlimited` or replace 'unlimited' with a size!
It's as easy as this.
I wont put any screenshot of the install process since it would take too much time.
But you can find the one I made for the old howto here
5. Getting a network interface up and running
This is the only tricky part of the howto!
Basically what you have to do is instruct qemu about how he should take care of the network layer.
This is to come a bit later cause I'm at work at the moment
6. Transfering data from the host os to the guest os and the other way round
This wasn't covered in my last howto. So a good has come from the bad!
Qemu has samba support. So you can specify a share of the local samba installation with the -smb argument.
I won't explain how to install samba (though it's as simple as going into the correct pkgsrc directory and run make).
All you need to do is add a share to your smb.conf. Let's call it "qemu":
[qemu] comment = QEMU share path = /home/dynek/qemu/share read only = no public = yes
You now just have to add -smb qemu when running qemu!
For more info read the manual of qemu because there's a tricky step with lmhosts. Have to try this before I can tell how it works.