UNIX Unleashed, Internet Edition
- 28 -
The BSD FAQ
by Jordan K. Hubbard
This chapter describes the BSD operating system technology from the University of California at Berkeley's Computer Systems Research Group (CSRG) and its use in UNIX systems today. This chapter covers the following topics:
A History of BSD
Almost 30 years ago now, the UNIX operating system was born at AT&T's Bell Laboratories through the efforts of Ken Thompson, Dennis Ritchie, and other researchers there. Releases up through the seventh edition of AT&T's UNIX were also made available to academic institutions for a small fee, leading to the formation of a small group of academic researchers and other early users who began working on improvements to the system, taking it in many new directions.
One such group of users was the University of California at Berkeley's Computer Systems Research Group (CSRG) who used UNIX as a research system and, as part of a DARPA grant, to develop and implement the ARPANET protocols that eventually became TCP/IP, the backbone of today's modern Internet.
Because their changes were also somewhat extensive, the CSRG distributed them to the other users of AT&T's UNIX as complete releases of its own, known as the Berkeley Software Distributions (BSD). During its 15-year run, the CSRG added several features to the UNIX operating system, among them better memory management, job control, a fast and robust file system (UFS) and, of course, TCP/IP networking itself.
By 1989, the CSRG had rewritten so much of AT&T UNIX that only 5 to 10 percent of the BSD distribution was in fact original AT&T code, leading to the first "unencumbered" code release known as "Net/1." It was followed shortly afterward by "Net/2."
Following the release of Net/2, several groups of people then took up the obvious challenge of rewriting that missing 5 to 10 percent from scratch, among them Bill and Lynn Jolitz, who completed the Net/2 code for the i386 PC platform and then released it as 386BSD, also submitting these changes back to UCB. Berkeley Software Design, Inc. (http://www.bsdi.com) also adopted the Net/2 code to the i386 PC platform in creating what was then called BSD/386 (one substantial rewrite later, it was renamed to BSD/OS), a purely commercial OS release.
At this point, however, AT&T's USL group (UNIX Systems Labs--those responsible for the UNIX brand) was becoming seriously concerned about the availability of non-AT&T UNIX clones and, in 1992, they brought a lawsuit against BSDI and UCB because they believed these groups violated UNIX trade secrets.
This lawsuit put a serious crimp in BSD's development for over a year. After much legal wrangling, the issue was finally resolved in February 1994, following USL's sale to Novell, a company that had no real interest in pursuing the long and unpopular lawsuit it had inherited.
Under the terms of the resolution, UCB was allowed to freely distribute its latest BSD version with some of the disputed files removed. This release was known as 4.4BSD Lite and is the release upon which all the modern BSD releases (for both legal and technical reasons) are based. Following the release of 4.4BSD Lite, the CSRG was also disbanded and reunited again only briefly to release their final BSD distribution, 4.4BSD Lite2.
The perceived lack of support for 386BSD by Bill Jolitz also led two groups to take 386BSD and maintain it, thus beginning the FreeBSD (http://www.freebsd.org) and NetBSD (http://www.netbsd.org) projects. Both groups were based on the Net/2 technology until the lawsuit and subsequent legal settlement, after which they moved to 4.4BSD Lite and, eventually, 4.4 BSD Lite2.
Currently, both the FreeBSD and NetBSD groups are over four years old and have moved far past their original starting points. 386BSD, by contrast, appears to have died rather completely and has been essentially replaced by its more active brethren.
A third BSD variant, OpenBSD (http://www.openbsd.org), was also recently spun off from the NetBSD project and maintains its own source repository and goal-set as an entirely independent project. Given the large degree of commonality OpenBSD still retains with its older NetBSD cousin, the sections on NetBSD are largely applicable to OpenBSD as well.
The chart in Figure 28.1 shows the timeline from AT&T's initial release up through the latest releases of FreeBSD and NetBSD.
Among these various operating systems, FreeBSD is also slightly unusual in that it has branched three different lines of parallel development: A "2.1-stable" branch, for legacy customers and other commercial interests that are only interested in the most critical bug fixes and enhancements; a "2.2-release" branch for the current release technology (which will also progress on its own, taking only select fixes and new features just as in the 2.1-stable branch); and, finally, the "3.0-current" branch, which represents FreeBSD's mainstream development, often experimental and not necessarily guaranteed to work at any given time.
This somewhat unique arrangement was necessitated by the fact that FreeBSD has a higher percentage of commercial users than the other free variants but still needs to work within the same volunteer developer-driven model, where developers shouldn't be constrained in their work by commercial users attempting to apply the brakes. The three-branch scheme gives legacy, current, and future customers/developers a way of getting what they need, albeit at the cost of slightly higher development overhead.
The following sections contain the answers to some general questions that are often asked.
Where can I get general information about BSD?
Depending on which of the various *BSDs you're interested in, you can visit the relevant Web pages, which follow:
The FreeBSD Project Page
The NetBSD Project page
The OpenBSD Project page
Berkeley Software Design, Inc.
Each group also has a central FTP server site available as ftp.FreeBSD.ORG, ftp.NetBSD.ORG, ftp.OpenBSD.ORG, ftp.BSDI.com, and so on, from which you can download more information and (only in the case of the free variants) the latest releases.
Does the CSRG Project at UC Berkeley still exist?
No, afraid not. It was disbanded around the time that 4.4 Lite was released. The original developers got together only once more to do the final 4.4 Lite2 release some time later. The CSRG and its BSD releases are gone, the task of maintaining the OS technology now having fallen to other organizations.
So who "runs" BSD development now?
No one "runs" BSD per se, although some of the original BSD developers went on to start BSDI. The many thousands of other users and developers of BSD went on to support one of the free *BSD versions, the selection of a particular variant largely on the user's specific goals.
Which BSD is best for me?
This question is somewhat difficult to answer only because each flavor has its own strengths and weaknesses, and user requirements also vary widely. However, I can fairly say that
If you need to run on something other than the x86 (Intel PC) architecture, check out NetBSD. It is the oldest and most mature member of the BSD family, which can be run on a wide variety of non-Intel architectures.
If you're using an x86 PC (or, soon, an ALPHA machine), then check out FreeBSD. The developers have maximized the performance and general usability of BSD for the PC and have an excellent track record in creating high-performance servers for large commercial applications.
If you need commercial support or are somehow put off by the idea of "free" OS software, then BSDI's product is really your only practical choice.
Is BSD available for my hardware?
See the "Types of Hardware Supported by BSD" section of this chapter for a full description of the hardware supported by FreeBSD and NetBSD (also largely applicable to OpenBSD and BSDI).
What's the difference between BSD and Linux?
Simply put, Linux is a new from-scratch OS development effort, whereas BSD is the continuation of a project that is now almost 20 years old.
You'll find many benefits to starting such development anew, just as you'll find many benefits to using software that has been tested and improved over time. Which OS will work best for you depends largely on your taste and needs.
I'm probably safe in saying that Linux leads BSD in the area of user population and support for more oddball peripherals than the average BSD supports. I can also safely say that in the general area of TCP/IP networking, BSD is without peer. TCP/IP networking was first developed for UNIX under BSD, and this history shows in the maturity and robustness of BSD's networking code.
Finally, the largest difference between BSD and Linux is probably more ideological than anything else. Each Linux distribution--and Linux itself is technically only the kernel--bundles up its utilities differently and with different packaging and installation technologies, all development except for the kernel being largely decentralized. The BSD groups, on the other hand, are highly centralized and provide the entire system as their product, everything from the ls command to the kernel. Given that they control each and every utility, they also can use source code control systems and such to keep track of it all. This practice is unfortunately rather rare in the Linux world, a deliberate degree of anarchy in the development process being something that its proponents generally approve of, trading off centralized control for a more "grassroots" development approach.
Can I use BSD technology in commercial products?
Yes, the vast majority of BSD code is covered by the BSD Copyright, which, unlike the GNU Public License (used by Linux and other GNU software), allows distribution in both binary and source forms without undue stipulations or restrictions on the process. Other code that incorporates BSD sources, both whole or in part, is also not required to be distributed in source form, a sometimes unpleasant (and very deliberate) artifact of the GPL.
I'm an Internet Service Provider; is BSD for me?
Absolutely. Using BSD and readily available PC or workstation equipment, you can easily create almost anything an ISP would need, from Web servers to shell account machines, news servers to mail hubs, dial-in servers to IP routers--you name it. All such applications may be served with BSD technology and, with BSD's advanced networking capabilities, highly reliably as well. FreeBSD is probably the most popular free variant for ISPs right now. If you visit the Web site, you can find list of some of the many who are using it, a list that includes everyone from Walnut Creek CD-ROM to Yahoo.
Can I share BSD files and printers with my Windows 95, Windows NT, and Macintosh machines?
Yes, a package called SAMBA (available from ftp://ftp.freebsd.org/pub/FreeBSD/FreeBSD-current/ports/net/samba.tar.gz) provides Windows 95 and Windows NT connectivity to your BSD resources. You can use a package called netatalk, now bundled with most of the BSD variants, to provide AppleTalk connectivity. You should investigate the documentation that comes with each of these packages for more information on their configuration and use.
How do I get tech support or report problems with BSD?
The various BSD groups have mailing lists and USENET newsgroups from which you can generally obtain volunteer support. You should also be sure to investigate the documentation and discussion archives that each group also maintains before asking questions because your question may already be answered by documentation that you can find in just a few minutes using your Web browser.
Each of the free *BSD groups also supports use of the send-pr command (man send-pr provides documentation on it) for entering a bug report into their central PR databases, after which it can be tracked and analyzed without getting lost as easily as an e-mail message might. The FreeBSD group also provides a Web interface (http://www.freebsd.org/send-pr.html) to their PR mechanism, allowing you to query and generate PRs using your Web browser.
Is BSD truly free?
Yes, in all cases except BSDI's product, you can freely download it from many public FTP sites, redistribute it to your friends (or customers), even redistributing it in commercial products. Various people also sell CD-ROM distributions of BSD (generally for around $40), but what you're paying for in such cases is the convenient media and fancy packaging, not BSD itself.
See the "Where to Get BSD" section for more information on obtaining such distributions.
How do I compile my own kernel?
First, you need the kernel sources, obviously, and if you haven't got a directory called /usr/src/sys on your system, then you need to load it first. You can generally find the kernel sources as part of the larger src distributions in a given BSD release.
BSD systems also use a utility called a config to generate the kernel build area; it takes the name of a kernel configuration file as an argument. The kernel configuration file specifies which device drivers and compile-time options should be enabled for your new kernel and, after config is run successfully on it, a new directory called /sys/compile/kernel is created (where kernel is the name of your kernel config file).
Two existing kernel configuration files are probably of the most interest to beginning BSD users:
How do I compile my own complete system?
Because BSD has a fully integrated source tree, you can simply go to the /usr/src directory (assuming that you have the sources installed) and type make to build the entire system. Most BSDs also have specialized build targets that are used to compile the tools in whichever special order will best guarantee a successful build (because many tools depend on others being built first). One such target is called world, meaning that you can rebuild and reinstall everything in the OS by typing make world and then going out to dinner (or perhaps several, depending on the speed of your system).
Can I use BSD to implement a NAT device and/or an IP firewall?
Network Address Translation, or NAT, is useful when you have multiple machines on a local LAN but only one valid IP address to the outside word. In such cases, you can have the machine with the valid IP address "masquerade" for the others somehow and route their packets through. NAT handles this job, and the free BSDs offer something called natd, which does exactly this task. FreeBSD has also modified the ppp utility to support an -alias flag, which does the same job if you're already using ppp to talk to your ISP (it saves the extra step of running natd). For more information, consult the man pages for natd and ppp.
An IP firewall selectively blocks packets to or from the outside world to prevent unauthorized access. FreeBSD offers two utilities for this job: ipfw and ipfilter (the latter being also available in the other BSDs). Both essentially do the same thing; they are simply different implementations that suit different people's preferences.
For more information, see the man pages for ipfw and ipfilter.
Installation is another issue that is something of a mixed bag in the world of BSD. Given that NetBSD and OpenBSD support over 10 different architectures, the job of installing the OS on any given machine depends a great deal on the hardware in question, and the hardware obviously can vary widely over such a large range of machine types.
The fact that NetBSD and OpenBSD also aim their installation and maintenance tools more at the computer scientist than the general computer user doesn't help if the user has no prior UNIX experience, so trying to describe the installation tools in any case is probably beyond the scope of this FAQ.
In contrast, the FreeBSD project recognized this problem early on and chose not to attempt to support so many architectures, electing instead to go after the single platform that the group felt offered the most "bang for buck," the Intel x86 architecture. Having this smaller problem domain allowed them to focus more on advanced installation tools and user support than on cross-platform porting issues, the result being an installation that is widely regarded as being the easiest of all the *BSDs for a new user to deal with. For this reason, I cover the FreeBSD installation here.
Creating the FreeBSD Installation Boot Floppy
The first step in installing FreeBSD is the creation of the installation boot floppy, available from ftp://ftp.freebsd.org/pub/FreeBSD/2.2.2-RELEASE/floppies/boot.flp (at the time of this writing--a more recent release may exist by the time you read this chapter--check around at ftp.freebsd.org). It is provided as a single 1.44MB image that you must "raw copy" to a 3.5-inch floppy. If you're using MS-DOS, download fdimage.exe (available from ftp://ftp.FreeBSD.ORG/pub/FreeBSD/tools/fdimage.exe) and run it as follows:
C:\> fdimage boot.flp a:
The program formats the A: drive and then copies the boot.flp image onto it.
If you're using a UNIX system, the technique is somewhat different. In this case, you type
# dd if=boot.flp of=disk_device
where disk_device is the /dev entry for the floppy drive. On FreeBSD systems, you use /dev/fd0 for the A: drive and /dev/fd1 for the B: drive. On others, you might use something more like /dev/floppy.
After you create the installation disk, put it in your A: drive and reboot your computer. After a certain amount of load time, you should get a boot prompt looking something like this:
>> FreeBSD BOOT ... Usage: [[[0:][wd](0,a)]/kernel][-abcCdhrsv] Use 1:sd(0,a)kernel to boot sd0 if it is BIOS drive 1 Use ? for file list or press Enter for defaults Boot:
You can simply press Enter here or wait for the system to time out and begin booting the floppy kernel. You then come to a screen asking whether you want to configure the kernel to match your hardware. It is generally a good idea to select the Visual Configuration Utility and quickly verify that FreeBSD's default settings match your hardware configuration. When and where they do not match, you should adjust FreeBSD's settings to agree with your hardware's actual configuration. (PCI and EISA devices have their settings probed automatically, but ISA/VLB devices are somewhat more tricky.)
After you proceed through the visual configuration utility, FreeBSD's kernel then completes the boot process, informing you of all the supported devices it finds in your machine. If the output scrolls by too quickly to read, don't worry; after the initial installation screen appears, you can press the Scroll Lock key and then Page Up and Page Down to move through the boot text. When you're done, simply press Scroll Lock again to get back into input mode.
At the first installation screen, select Novice Install, and you should be on your way. The installation allows you to select from a wide variety of installation media, including any of the FreeBSD FTP mirror sites or a local NFS server if your machine has an Ethernet card or a modem and PPP account into which you can dial. You don't need to download anything but the initial boot floppy; FreeBSD's installer fetches whatever else it needs over the Net automatically. Machines lacking Internet connectivity can also install from CD-ROM, tape, DOS partition, or floppies. For more information on creating or obtaining such media, see the FreeBSD installation guide in INSTALL.TXT for a given release.
Where to Get BSD
FreeBSD, being the most popular of the freely available BSD-derived operating systems, is probably the easiest to obtain. It is available from several sources--over 50 mirrors in some 25 countries.
Each FreeBSD mirror site is organized by country code; for example, the French primary mirror is ftp://ftp.fr.FreeBSD.ORG/pub/FreeBSD, and the Australian primary mirror is ftp://ftp.au.FreeBSD.ORG/pub/FreeBSD. When additional mirrors exist, they are numbered starting from two--for example, ftp://ftp2.de.freebsd.org/pub/FreeBSD for the second German mirror or ftp4.br.freebsd.org for the fourth Brazilian mirror. Also try these sites if and when the primary one is unreachable or busy. The master FreeBSD site's URL is ftp://ftp.FreeBSD.org/pub/FreeBSD and always contains the latest release. (The other mirrors sometimes require some time to catch up right after a new version is released.)
NetBSD is also available from a number of FTP mirror sites, the master site being ftp.NetBSD.org. It has also apparently begun to organize along the same basic naming scheme as FreeBSD. Currently, six international mirrors exist.
OpenBSD is available from ftp://ftp.OpenBSD.org and has several mirrors (listed there).
On CD-ROM, FreeBSD is available from both Walnut Creek CD-ROM and InfoMagic; NetBSD is available only from InfoMagic; and, currently, it is not known whether a CD-ROM distribution for OpenBSD is available at all.
Walnut Creek CD-ROM
1547 Palos Verdes Mall, Suite 260
Walnut Creek CA 94596 USA
P.O. Box 30370
Flagstaff, AZ 86003-0370
Types of Hardware Supported by BSD
Determining exactly what types of hardware are supported by BSD can sometimes be a rather difficult proposition given that several different variants of BSD are currently on the market. Each variant has a somewhat different market focus than its siblings, and the "supported hardware list" varies for each one, also changing from release to release. What follows is therefore only the best approximation at the time of this writing and subject to change without notice. The following sections also focus only on the hardware requirements for FreeBSD and NetBSD, those being the two currently most popular free variants of BSD. (OpenBSD's hardware requirements also closely mirror those of NetBSD's.) On the commercial side of things, you can find the supported hardware list for BSDI's BSD/OS product on the BSDI home page (http://www.bsdi.com).
FreeBSD Supported Hardware
The types of hardware listed in the following sections are supported under FreeBSD on the x86 (PC) architecture.
Miscellaneous CD-ROM Drives
NetBSD Supported Hardware
The types of hardware listed in the following sections are supported across the wide assortment of architectures supported by NetBSD.
Digital ALPHA architecture
The supported hardware list for NetBSD/x86 is essentially a close subset of the FreeBSD hardware list. Some of the more esoteric devices are not supported, but it's close enough that the FreeBSD hardware section should serve as a reasonable guide to NetBSD/x86.
Sun 3 (68K)
An operating system is fairly useless if you can't actually do anything with it, and fortunately the things that BSD can do for you are limited only by your imagination. Tens of thousands of applications and general utilities are available for UNIX, with more appearing every day. Many of these applications are also free, and the FreeBSD Ports Collection (http://www.freebsd.org/ports) was devised as a way of keeping track of all of them. Currently, well over 1,000 ports are available, and at the current rate of growth, this number will probably double over the next 12 months. The FreeBSD ports collection is also being ported to some of the other *BSD variants, OpenBSD already using much of it in its current system.
The beauty of the ports collection is that it does not attempt to keep local copies of the many hundreds of applications out there; it merely "encapsulates" them, providing all the information that FreeBSD needs to fetch, unpack, potentially customize (or patch) for FreeBSD, and build and install the software. You simply type make install, and the ports collection does all the rest.
The ports collection comprises some 35 different categories of software, containing everything from Web servers to obscure (and not so obscure) programming languages. Some of the applications in the ports collection include:
The list of commercial software applications for BSD is small but growing, with packages such as CDE (Common Desktop Environment) from Xi Graphics (http://www.xig.com) and RealAudio (http://www.realaudio.com) from Progressive Networks now providing more support for desktop users.
BSD on the x86 platform is also quite capable of running Linux a.out and ELF binaries, giving you access to a wealth of desktop applications in the Linux market, such as StarOffice (http://www.stardivision.de) and ApplixWare (http://www.applix.com/appware/appware.htm).
Actually more well-suited for the Internet server market than for desktop applications in any case, the BSD world also offers a number of commercial Internet firewall products, high-performance Web servers (such as Zeus at http://www.zeus.co.uk), database servers, and many other tools for creating fully featured, highly cost-effective Internet and intranet server systems.
Because covering the full range of BSD topics in this chapter would be impossible, I've listed the following publications, many of which are indispensable if you want to know more about BSD, BSD system administration, or the internals of the OS.
These publications are tailored to a general user's area of interest:
These publications are aimed at system administrators and others who need to maintain BSD systems in production environments:
These publications are aimed at software developers:
Operating System Internals
These publications are for the serious enthusiast or developer who wants to work on the operating system itself:
Magazines and Journals