Early this month (October 2006), the NetBSD project is due to release the next version of its OS. NetBSD is the oldest of the free BSD-derived operating systems still in active development, beginning life as a patch set for 386BSD. It is also the one with which I am least familiar, so I asked some of the developers to tell me what was so special about their system.
As with the rest of the BSD family, NetBSD is a complete operating system—kernel and userland—derived from the Berkeley Software Distribution version of UNIX. By the time it reached version 1.0, it already had support for six platforms, with more being added every release. The current total is 57, including 17 different CPU types.
Of Course, It Runs NetBSD
NetBSD has a well-deserved reputation for portability. Part of this reputation comes from the driver layer, which makes use of an abstraction layer known as the Modular Portability Layer (MPL). This layer enables a single driver to be easily used on all architectures by hiding details of exactly how the host talks to the hardware and dramatically reduces the amount of work needed to port it to a new architecture. It was a running joke for years that NetBSD was the OS to run on your toaster, and last year the team proved it by demonstrating a NetBSD-enabled toaster.
This portability was responsible for my first introduction to NetBSD. With version 7.0, RedHat dropped support for the SPARC32 architecture. While looking for an alternative to run on some old SparcStations that were being used as X terminals, I came across NetBSD. At the time, Linux’s handling of the SPARC32 MMU had some major issues (I don’t know if they have been fixed now), and NetBSD was noticeably faster. NetBSD has given a new lease on life to a lot of old hardware. Ports to systems such as old Apple 68K-based machines mean that it is often a very cheap way of getting a taste of UNIX.
Although the number of ports is impressive, the team is quick to point out that this does not necessarily correspond to portability. Geert Hendrickx explains:
You should understand that "portability" is not the same as "number of ports," though. Making an actual port still requires 1) manpower and 2) hardware, thus money, both of which NetBSD certainly has much less than (for example, Linux). And Linux ports are often quite "brute forced," involving a lot of code rewriting.
When NetBSD is ported to a new platform, this typically involves writing the code that sits at the bottom of the abstraction layer and writing drivers for any required hardware. In some cases, the drivers may already exist, but it is common for a new platform to have things such as keyboard controllers that are not present in existing systems, and so need adding. Hubert Feyer explained that the focus on portability is as important as ever:
With the ever-growing number of devices, not only in the traditional computer market but also more and more in the embedded area, portability is the key to NetBSD. Without proper infrastructure for writing portable code, like bus and DMA abstractions and a driver framework that sits on top of that, we could not deliver an operating system that runs on more than 50 hardware platforms and 14(?) CPU architectures—all from one source tree, including kernel, userland, and the X Window System.
This approach makes it a lot easier to maintain ports. When a new feature, such as the native threading support added in 2.0, is added higher up the abstraction stack, all the ports automatically gain it. This is in contrast with a system such as Linux, in which a number of ports are close to being forks and require a lot of pack-porting to bring up to feature-parity with the main branch. This portability, along with the permissive license, has attracted a number of hardware developers to NetBSD. It is found in a number of systems that the end user would not even think of as needing an operating system, such as Ricoh laser printers and photocopiers. When I asked why system developers would choose Linux over NetBSD, Hubert Feyer made this suggestion:
The primary reason why a lot of companies are choosing Linux over NetBSD, though, would be hype: Linux gets a lot more media attention; many people don’t even know that NetBSD exists. As a consequence, there is a lot more commercial software and support for Linux, and unfortunately this seems to form a closed loop. Fortunately, there are a number of companies that look beyond the latest hype and recognize the strengths of NetBSD: companies like Avocent, Sony, Brocade, Force 10, Wasabi Systems, NEC, Ricoh, and others.