Freebsd on Freebsd using QEMU

Posted: August 7th, 2012 | Author: | Filed under: FreeBSD, virtualization | Tags: , , | Comments Off on Freebsd on Freebsd using QEMU

My system looks like this:


$ uname -a
FreeBSD xxxx.xxx.net 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012 [email protected]:/usr/obj/usr/src/sys/GENERIC amd64

1) Install qemu from /usr/ports/emulators/qemu

2) Load following 2 modules:

$ sudo kldload aio
$ sudo kldload kqemu

3) Get iso of the guest OS, in my case its FreeBSD so I got one from:
ftp://ftp.freebsd.org/pub/FreeBSD/releases/ISO-IMAGES/9.1/

4) Create qemu image: (‘man 1 qemu-img’ for more information)

$ qemu-img create -f qcow2 ~/qemu/fbsd9_1beta.img 8G


$ ls -l ~/qemu/
total 652448
-rw-r--r-- 1 hpanchasara hpanchasara 667693056 Aug 7 12:43
FreeBSD-9.1-BETA1-amd64-disc1.iso
-rw-r--r-- 1 hpanchasara hpanchasara 262144 Aug 7 12:44 fbsd9_1beta.img

Then I tried to launch it with: (‘man 1 qemu’ for more information)

$ qemu -boot d -hda ~/qemu/fbsd9_1beta.img -m 512M -cdrom ~/qemu/FreeBSD-9.1-BETA1-amd64-disc1.iso -localtime

But got following errors:

Listing a few to help the web-crawler which intern helps some lost soul like me:
“CPU doesn’t support long mode”
“Can’t work out which disk we are booting from…”
“panic: free: guard1 fail @ …”

Asking “the Internet” helped me narrow down the root causes to following:

1) 32 bit host cannot have 64 bit guest – which was not the case for me.
2) Machine should be virtualization capable – it is.
from /var/run/dmesg.boot, it should have VMX or SVM under “Features”.

FreeBSD 9.0-RELEASE #0: Tue Jan 3 07:46:30 UTC 2012
[email protected]:/usr/obj/usr/src/sys/GENERIC amd64
CPU: Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz (3392.37-MHz K8-class CPU)
Origin = "GenuineIntel" Id = 0x206a7 Family = 6 Model = 2a Stepping = 7
Features=0xbfebfbff
Features2=0x179ae3bf
AMD Features=0x28100800
AMD Features2=0x1
TSC: P-state invariant, performance statistics

3) Virtualization support should be enabled in bios – it was enabled.

$ sudo dmidecode | grep VME
VME (Virtual mode extension)

4) Use of incorrect qemu binary – that was the culprit.

“qemu” has different binary versions depending on the platform/systems:

$ qemu
qemu qemu-system-mips qemu-system-ppcemb
qemu-img qemu-system-mips64 qemu-system-sh4
qemu-system-arm qemu-system-mips64el qemu-system-sh4eb
qemu-system-cris qemu-system-mipsel qemu-system-sparc
qemu-system-m68k qemu-system-ppc qemu-system-sparc64
qemu-system-microblaze qemu-system-ppc64 qemu-system-x86_64

Using following I could successfully launch the guest FreeBSD instance:

$ qemu-system-x86_64 -boot d -hda ~/qemu/fbsd9_1beta.img -m 512 -cdrom ~/qemu/FreeBSD-9.1-BETA1-amd64-disc1.iso -localtime

On this first launch, it does FreeBSD install from the specified iso to the .img file. This is a typical FreeBSD installation process.

One the installation is done, you I could launch the VM via:

$ qemu-system-x86_64 -boot c -hda ~/qemu/fbsd9_1beta.img


Comments are closed.