Testing stuff with QEMU - Part 3: Debian GNU/kFreeBSD

Debian GNU/kFreeBSD screenshot 1

Note: This article is part of my Testing stuff with QEMU series.

From the Debian GNU/kFreeBSD port page:

Debian GNU/kFreeBSD is a port that consists of GNU userland using the GNU C library on top of FreeBSD's kernel, coupled with the regular Debian package set.

Q: Why would anybody want to do that?
A: Why not? [1]

So, after we have talked about that, let's start:

  1. Install QEMU:
    apt-get install qemu
  2. Download the latest Debian GNU/kFreeBSD installer ISO image (either for i386 or amd64):
    wget http://glibc-bsd.alioth.debian.org/install-cd/kfreebsd-i386/20070313/debian-20070313-kfreebsd-i386-install.iso
  3. Create a QEMU image which will hold the Debian GNU/kFreeBSD (i386) installation:
    qemu-img create -f qcow2 qemu_kfreebsd_i386.img 5G
  4. Boot directly from the ISO image and install Debian into the QEMU image:
    qemu -boot d -cdrom debian-20070313-kfreebsd-i386-install.iso -hda qemu_kfreebsd_i386.img
  5. The FreeBSD installer will now start. For more detailed instructions see the Installing Debian GNU/kFreeBSD manual.
    First you can choose between an "Express" or "Custom" install (I used "Express").
  6. Next you end up in the partitioning tool. Type "a" to use the entire (QEMU) disk for the installation (the disk is called "ad0", not "hda" as on Linux). Type "q" to quit the partitioning tool.
  7. You are now asked which boot manager to use. For QEMU you should use "BootMgr", the default FreeBSD boot manager. If you install on real hardware you can also use GRUB; in that case choose "None" here (see the manual for more information), but note that the installer does not install or configure GRUB for you! You should do that beforehand!
  8. Next up: The disklabel editor. Here you'll create a partition ("slice" in FreeBSD-speak) for the root filesystem and a swap partition.
    Press "c" to create a new slice (will be called "ad0s1"), enter "4GB", choose "FS" (filesystem), and enter "/" for the root filesystem. Per default the UFS2 file system will be used. To create the swap partition, press "c" again, enter "1023MB", and select "swap". The new slice is called "ad0s1b". Press "q" to quit.
  9. Choose "minimal" when asked which distribution to install.
  10. Installation media dialog: select "CD/DVD" and "acd0" (for QEMU's ATAPI/IDE CD-ROM drive).
  11. The installation will now begin, and after a while you're asked to switch to console 3 using ALT-F3. Do it.
  12. You'll have to answer a bunch of questions: geographic area + city you're in (for timezone), whether you want to participate in the Debian popularity contest, whether module-init-tools should load additional drivers (no, so press ENTER three times). The installation will soon be finished.

At the end you must select "No" as you're told to do, then reboot via "Exit Install". You can then shutdown QEMU.

  1. Restart QEMU with the newly installed Debian GNU/kFreeBSD:
    qemu -hda qemu_kfreebsd_i386.img
    Debian GNU/kFreeBSD screenshot 2
  2. Press enter at the FreeBSD boot manager prompt, then login as root (there's no password).
  3. First things first: Set up a root password:
    passwd
  4. Now let's fix networking, update the system and install a bunch of packages:
    nano /etc/network/interfaces
    Yes, there's no vi, not even a symlink to nano! Uncomment the two "ed0" lines ("ed0" is the equivalent to "eth0" on Linux, I guess).
    /etc/init.d/networking restart
    apt-get update && apt-get dist-upgrade
    apt-get install vim xorg icewm xterm
  5. You can fix your console keymap using the kbdcontrol package (just select your keymap from the menu):
    apt-get install kbdcontrol
  6. Finally, let's fix X11 and start it. But first we create a new user, as we don't want to run X11 as root:
    adduser uwe
    vi /etc/X11/xorg.conf
    The mouse device is "/dev/psm0", the protocol "PS/2", and the graphics driver should be "vesa":

      Section "InputDevice"
          Option "Device" "/dev/psm0"
          Option "Protocol" "PS/2"
      [...]
      Section "Device"
          Driver "vesa"
        
  7. That's about it. Login as "uwe" (or whatever your username is) and start X11:
    startx

Wasn't all that hard, eh? Now, if you've got some spare time, head over to the Debian GNU/kFreeBSD wiki page and help improving this port ;-) You should probably start with reading the PORTING guide.

Both kfrebsd-i386 and kfreebsd-amd64 seem to be reasonably stable already (and more than 70% of the whole Debian archive builds fine on these architectures, see kfreebsd-i386_stats and kfreebsd-amd64_stats). I'll quite likely install kfreebsd-amd64 on one of my boxes soonish and start using it, maybe I'll even find some time to fix/patch/port some packages...

[1] More elaborate answer(s) and reasons are available in the Debian wiki.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Kfreebsd under QEMU

Thanks for a very helpful page.

Some things have changed since it was written. Most are to do with the installer, so they are obvious, some other points

1) Add -enable-kvm if your host CPU is the same as the guest CPU and your host OS is Linux (I found no problems running under KVM)
2) The emulated Ethernet is now em0, not ed0, so /etc/networking/interfaces needs to reflect that

Qemu compressed hard disk image available for download

I have released a compressed raw hard disk image, created on Qemu, of Debian GNU/kFreeBSD for those that may find the installation process difficult. It is a 275 MB download, 10GB extracted. It is the base system with all updates installed as of November 23, 2008. No password for root. No additional user accounts created.

You can download it via bittorrent from the torrent file here:
http://tux9656.no-ip.biz/debian-gnu-kfreebsd-i386-qemu.torrent

BTW, this torrent file is being hosted on a Debian GNU/kFreeBSD machine. I love this OS!

Thanks for this very good

Thanks for this very good tutorial. Everythings works fine :)

^C on screen

Hi,

You wouldn't happen to know how to make screen "work", would you?

I've just set up an image and installed screen in it. When I'm in screen, ^C doesn't work... :(

Any pointers to a possible solution would be greatly appreciated. Thanks!

Keys

I think this is related to the keyboard config in general, I have problems using Shift+PAGEUP for scroll back history, for example. Did you try kbdcontrol? It should fix things in the console. In X11 the issue may be different.

I'll try to find the solution for this and post it here ASAP.

Cheers, Uwe.

scroll back history

Scrolling back history works just like it does in FreeBSD.

Use ScrollLock and then Up/Down/PgUp/PgDown work. Press ScrollLock once more to be able to type again.

P.S.: I agree Shift+PgUp is a lot faster and seems to be more intuitive. Also, ScrollLock is not available on some keyboards (like Apple PowerBook G4).

Nice roundup

Nice and short roundup how to use qemu to try something you normally wouldn't install on your working system. What's missing is to mention the qemu kernel module which speeds up thinks dramatically.

kqemu not working

I installed debian gnu/kfreebsd while running with kqemu. but duing the dist-upgrade, it (qemu) was always crashing in a segmentation fault.

I remembered I had problems with the module using open bsd so I tried removing the module and now it is working correctly..

So, my recommendation is: you probably just want to try out the OS if your playing with it in qemu. don't use it with kqemu since it makes it crash

Yeah, but kqemu will not

Yeah, but kqemu will not work everywhere unfortunately. For example, it currently doesn't build on amd64 where I did this (will report a bug) and it won't work on many other architectures where QEMU is available, I think.

Uwe.