LWN.net Logo

Debian GNU/kFreeBSD: one more step towards a universal operating system

April 22, 2009

This article was contributed by Koen Vervloesem

One of the strengths of the Linux ecosystem is freedom of choice. The Debian distribution has given its users one more freedom: to choose between the Linux and FreeBSD kernels under the hood, with the same Debian GNU user space applications whichever is chosen. The idea goes back ten years, but it is finally coming to fruition now that two new architectures, kfreebsd-i386 and kfreebsd-amd64, have been added to the unstable and experimental archives of Debian.

The project was first announced in the Debian Weekly News for February 22nd, 1999:

Someone proposed a Debian distribution based on FreeBSD. There was considerable debate on this topic. Most of the favorable opinions expressed were based on the argument that there should be a Debian distribution for as many open source UNIX variants as possible. This was countered with the argument that this would drastically increase the workload of the package maintainers.

Shortly thereafter a plain FreeBSD port of Debian was started, with a FreeBSD kernel and FreeBSD libc under a GNU user space. To not diverge too much from the GNU/Linux architecture, the developers of the project used GNU utilities, but they quickly found out that a lot of packages needed patches because the FreeBSD libc did not provide the same extensions as GNU libc.

So after a while came the idea to port GNU libc to the FreeBSD kernel. This was done mostly by Bruno Haible in 2002, which is when the project took the shape (and name) it has now. Port maintainer Aurélien Jarno looks back at this time:

At this moment, Robert Millan suggested to add a 'k' in front of FreeBSD to form GNU/kFreeBSD meaning "kernel of". It is a way to show that except a few low level userland utilities, we are using only the kernel and not the C library of FreeBSD. In the same way a GNU/Opensolaris port is in development (Nexenta), and a GNU/kOpenSolaris port has been started recently now that GNU libc has been partly ported to the OpenSolaris kernel, solving licensing issues.

Switching to the GNU libc port has brought better compatibility with the Debian packages and, once that happened, a lot of packages were able to be built without any changes. The project got the name Debian GNU/kFreeBSD. To summarize, Debian GNU/kFreeBSD is a port that consists of a GNU user space using the GNU C library and Debian package management and system tools on top of FreeBSD's kernel. The latest Debian GNU/kFreeBSD is based on the upstream FreeBSD 7.1 kernel with a few patches.

GNU and BSD: a strange marriage

But why have the developers made such a strange chimera, a combination of a BSD kernel and a GNU user space? Is this a "because we can" project? Obviously, the developers have heard this question countless times, and the wiki lists some valid reasons why a user could prefer Debian GNU/kFreeBSD to FreeBSD or Debian GNU/Linux.

The "why" question breaks down into two questions. First, why would a user prefer Debian GNU/kFreeBSD to Debian GNU/Linux? First, the FreeBSD kernel has some nice and useful features, like the OpenBSD "pf" packet filter and "jails", a system-level virtualization feature. The developers also list cleaner kernel interfaces than Linux as an advantage, pointing to a single /dev implementation via devfs, as well as using OSS as the default sound system as examples.

Drivers can be another advantage. For example, the FreeBSD kernel has support for Windows NDIS drivers in the mainline kernel, whereas the NDISwrapper project will not likely make it into the mainline Linux kernel. The developers add: "The FreeBSD kernel might support some hardware which Linux does not support and/or the FreeBSD kernel support might be better (fewer bugs)." But, of course, this is a double-edged sword: Linux supports a lot of devices for which FreeBSD has no drivers yet.

Another interesting issue lies on the filesystem front: the Debian GNU/kFreeBSD developers say that due to licensing and patent issues, Sun's filesystem ZFS is unlikely to appear in the Linux kernel. However, now that Oracle is buying Sun, chances have improved that ZFS will get GPL-licensed. But whatever will happen, ZFS is also being ported to FreeBSD, so Debian GNU/kFreeBSD users will definitely see support for this interesting filesystem in the future.

Some of the reasons the developers give are less convincing. For example, they say: "kFreeBSD offers an alternative in case Linux is branded illegal by the SCO case or other threats. In legal terms, Linux sources are like a minefield. kFreeBSD is much less vulnerable to such attacks because of its less bazaar-like development model." Your author thinks this is very unlikely to happen.

The second part of the "why" question is: why would a user prefer Debian GNU/kFreeBSD to FreeBSD? This really comes down to preferences. Maybe the user likes the Debian package system more than FreeBSD ports, or prefers the GNU user space to the BSD world. The GNU versions of many commands are known to have more features. And at the non-technical level: Debian GNU/kFreeBSD follows the Debian Free Software Guidelines, whereas FreeBSD uses some non-free, binary-only drivers such as the ath driver for Atheros wireless chipsets. But all of this will most likely not convince BSD users to switch.

Working with Debian GNU/kFreeBSD

This all sounds interesting, but does it work in practice? The base system is fully functional and users can install Debian GNU/kFreeBSD by using the install notes. An ISO file for an install CD is available. Currently this is a version from January 2009, but users can add a Lenny-based snapshot to /etc/apt/sources.list.

The current installation CD is based on a hacked FreeBSD sysinstall, so at this moment, the installation is not straightforward for users without any FreeBSD experience. Moreover, this only works more or less correctly for standard installations. This is a temporary solution until the debian-installer is fully ported to Debian GNU/kFreeBSD. Luca Favatella, a computer engineering student at the University of Catania in Italy, will implement this as part of Google Summer of Code 2009. As part of his proposal, which has been accepted at GSOC, he will not only port debian-installer to GNU/kFreeBSD, but he will also make debian-installer less dependent on Linux: at this moment it uses many Linux-specific constructs (e.g. udev) or assumes Linux structures (e.g. setting up partitions with LVM).

Most of the core packages in Debian unstable are ported to Debian GNU/kFreeBSD. Looking at all of the architecture-independent source packages, the developers have currently ported over 80% of the 7800 source packages. Of course not all of them have been tested. There is still a large amount of packages that need fixing. The developers have a list of common practices and problems found when porting to GNU/kFreeBSD. According to Jarno, a lot of porting is rather simple (but boring). For example, support for detecting GNU/kFreeBSD was added more than six years ago to autotools, but a lot of software is still using an older version. He adds: "Also a lot of software is using #ifdef __linux__ to detect if they are using a GNU libc. This is clearly wrong, and this is also one of the more repetitive changes to make."

Several high-profile packages aren't ported yet. For example, OpenOffice.org is missing. But Jarno sees no fundamental problems for this port to happen: "There is no reason it would not work, but it is a huge task given the size of Openoffice.org sources. All the build dependencies are available, so it's mainly about tweaking the hundreds of autodetection scripts that do not know about GNU/kFreeBSD."

Wireless networking works in Debian GNU/kFreeBSD, but there are no tools to scan for networks yet. The problem is that NetworkManager is really tightly coupled to HAL, which was not available on FreeBSD. Jarno explains: "Though it has been originally designed for being portable across operating systems, a lot of kernel-specific code had to be written." However, now that HAL has been ported to FreeBSD, it should not be a big deal to get NetworkManager working. As upstream FreeBSD is doing the porting work (as a Google Summer of Code project), Debian GNU/kFreeBSD will surely get NetworkManager support in the near future.

There is a core of about 5 to 8 developers working on the Debian GNU/kFreeBSD port, but as with any open source project a lot of other people are also helping to a smaller extent. That includes package maintainers who want their package to work on the system. The project provides Debian Developer accessible machines running GNU/kFreeBSD for this purpose. Jarno estimates that about 50 people are using Debian GNU/kFreeBSD almost daily, and that a lot of people are following the development more or less closely: "We hope to see this number increasing now that it is being integrated as an official Debian architecture."

With Debian GNU/kFreeBSD, the Debian project has taken one more step towards its vision as a universal operating system. It's unique to have a platform supporting two different kernels, while the user space remains largely unchanged. Of course there's also Debian GNU/Hurd, but this still has not been officially released, and the Hurd kernel itself is still relatively immature. Debian GNU/NetBSD is still in an early stage of development. The ultimate aim is Debian GNU/Any, where the user space is abstracted completely from the running kernel with glibc. When this is possible, Debian binaries would be binary compatible with any kernel supported on Debian GNU/Any through the glibc abstraction. This total decoupling of user space and kernel will give users even more choice.


(Log in to post comments)

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 14:17 UTC (Thu) by nix (subscriber, #2304) [Link]

HAL is being ported to FreeBSD, and at the same time the HAL hackers say that HAL is obsolete and is being replaced with something that barely exists yet (whose name I forget).

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 16:27 UTC (Thu) by chema (subscriber, #32636) [Link]

Perhaps you are refering to DeviceKit.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 18:50 UTC (Thu) by jimparis (subscriber, #38647) [Link]

... or udev, which might replace DeviceKit? http://lists.freedesktop.org/archives/devkit-devel/2009-A...

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 21:57 UTC (Thu) by jengelh (subscriber, #33263) [Link]

What's with all the ominous kits? They only float likes kites...

ConsoleKit, PolicyKit, and now DeviceKit. What's next?

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 23:28 UTC (Thu) by drag (subscriber, #31333) [Link]

Kits are cool. I think it's just a way of saying "Use this if you write a desktop app and want to do X".

So if you want to program a app to work with devices.. you use devicekit! Then there is devicekit-power and devicekit-disk and such things.

I think that right now people are trying to find the correct layers of abstraction here... If you make the layers to think then the individual tools become way too complex and difficult to manage. Make the layer to high level and then application developers will avoid using your tools and then you get to many people running around making redundant and conflicting functionality. Make the layers to low and then you run into putting a high burden on app developers and you end up with conflicting functionality.

That sort of thing. I think that they are just searching around for the best way to do things before it all gets set in stone.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 24, 2009 10:34 UTC (Fri) by nix (subscriber, #2304) [Link]

Yes, one of those, probably, perhaps.

(And people wonder why HAL et al get an awful reputation? Documentation is
sparse, information on *which you should use* is even less clear, and they
get replaced with other variations on the same theme before they even get
released but *after* they've been puffed as the Latest New Thing in many
google-searchable areas, where they'll stay as wrong signposts forever.)

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 16:25 UTC (Thu) by TRS-80 (subscriber, #1804) [Link]

Unfortunately ZFS and DTrace have been remove from the Debian package on the basis that the CDDL is imcompatible with the DSFG.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 18:47 UTC (Thu) by ssam (subscriber, #46587) [Link]

if you mix freeBSD and the ZFS source, i guess the resulting code is CDDL and no longer BSD.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 19:16 UTC (Thu) by zooko (subscriber, #2589) [Link]

What? <Zooko looks.>

"""
Sources/Binaries in the following directories are licensed under
DFSG-incompatible terms and were therefore removed from the package
(and disabled in the build system):

src/sys/compat/opensolaris
src/sys/contrib/dev/ath
src/sys/contrib/dev/nve
src/sys/contrib/dev/oltr
src/sys/contrib/opensolaris
src/sys/dev/hptmv
src/sys/dev/hptrr
src/sys/dev/rr232x

The following directories contained code that is itself free, but depends
on the above cited non-free sources and was also removed (and disabled):

src/sys/dev/ath
src/sys/dev/nve
src/sys/modules/ath
src/sys/modules/ath_hal
src/sys/modules/hptmv
src/sys/modules/hptrr
src/sys/modules/nve
src/sys/modules/oltr
src/sys/modules/rr232x
src/sys/modules/zfs
"""

Which one is dtrace? It looks like ZFS is excluded, not on the basis that CDDL is incompatible with DFSG, but on the basis that it *depends* on something which is DFSG-non-free.

Anyway, who says CDDL is DFSG-non-free? Hm, a quick google for "site:packages.debian.org COMMON DEVELOPMENT AND DISTRIBUTION LICENSE" suggests that it is considered acceptable to include CDDL-licensed software in Debian.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 24, 2009 3:44 UTC (Fri) by TRS-80 (subscriber, #1804) [Link]

For FreeBSD 7.0 the majority of ZFS was in src/sys/contrib/opensolaris/uts/common/fs/zfs/ with src/sys/modules/zfs/ just having a makefile. For 7.1 ZFS is in src/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/ and DTrace (which wasn't in 7.0) is in src/sys/cddl/contrib/opensolaris/uts/common/dtrace/. The copyright file is out of date anyway, since the paths have changed, so maybe they are including ZFS and DTrace now - the source tarball still has src/sys/cddl, but I can't find the resulting kernel packages to check.

As for CDDL being non-free, most of those results are Qt-style GPL license exceptions, with the notable exception of star, which is by Jörg "cdrecord" Schilling. The changelog says '* Disable GPL incompatible "zfs"' so maybe that's their reason.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 24, 2009 14:39 UTC (Fri) by zooko (subscriber, #2589) [Link]

Yes, as far as I can tell, CDDL is accepted as DFSG-free by Debian, but it is GPL-incompatible. That's consistent with what the OSI and FSF say about CDDL.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 23, 2009 21:55 UTC (Thu) by Thalience (subscriber, #4217) [Link]

Abstraction from a particular kernel seems like an admirable goal at first glance. However, it constrains the software to the least common denominator of APIs offered by the different kernels.

Part of why I prefer Linux to *BSD is that the kernel hackers are willing to do things differently from POSIX, when POSIX is stupid.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted Apr 27, 2009 7:09 UTC (Mon) by kleptog (subscriber, #1183) [Link]

Ah, but people don't use the kernel, they use the libc. As pointed out in the article, once you get glibc ported to the kernel in question most programs just work.

Come to think of it, this means we have a FreeBSD with working UTF-8 collation. About time...

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted May 4, 2009 19:04 UTC (Mon) by muwlgr (guest, #35359) [Link]

I would rather like to see apt+dpkg ported to FreeBSD libc and userspace, and the whole installation and upgrade of FreeBSD kernel, userland and ports switched to this engine. I think, apt+dpkg is the most essential part of Debian. I also think that porting glibc to FreeBSD kernel turns it into something not being "the real" FreeBSD as we know it. On the contrary, I think that porting your userspace to another libc (FreeBSD libc, uClibc, whatever) is more useful and educative thing. And porting your higher-level infrastructure and scripts to another userspace (FreeBSD userland, busybox, etc.) is even better experience in portability.

Debian GNU/kFreeBSD: one more step towards a universal operating system

Posted May 4, 2009 19:25 UTC (Mon) by jordanb (guest, #45668) [Link]

What makes apt/dpkg so good is the breadth and high consistent quality of the debian archive, which comes from the tremendous amount of hard work the Debian developer community does keeping everything integrated.

Simply switching the packaging tool for BSD wouldn't change much. You'd have to 'port' the developer community and their output as well. As the article said, the kFBSD project originally wanted the BSD portions to have a bigger footprint, but that would have meant much less compatibility with what exists in Debian (many packages wouldn't work out of the box). They'd need a lot more DD buy-in to be useful, and porting the community would have been a much tougher sell ("you don't have to do anything differently, except maybe fix some obvious bugs" would become "you my have to port your packages to a new libc that your upstream probably doesn't care about").

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds