Why Configure a Custom Kernel?


FreeBSD comes with the GENERIC kernel installed by default. This kernel is tuned to support as wide a user base as possible so that FreeBSD will work out of the box on as many different machines as there are users in the world. Given the nature of x 86-based hardware, this means that the FreeBSD kernel must hold a truly astounding number of built-in drivers. An operating system built for a tightly controlled set of hardware (such as SGI's IRIX or Apple's Mac OS X) can afford to get away with much less of this generic support, but FreeBSD is stuck with it. The GENERIC kernel also has various options for memory allocation and optimization set to lowest-common-denominator levels, and other optional elements are left out in order to keep the kernel as streamlined as possible under the circumstances. These are all aspects of the kernel that can almost certainly be configured more efficiently for your particular system.

Note

One reason for having as many devices compiled into the GENERIC kernel as possible is to ease installation; you don't want to boot into a stripped-down installation kernel, hoping to do a network install, only to find that your Ethernet card isn't supported in the kernel!


Streamlining the Kernel

The kernel probes at boot time for every single kind of device it knows about. This is where you see that scrolling screen full of white text while the system is coming up; the kernel is looking for dozens of different kinds of devices that are enabled in the GENERIC kernel. Although it doesn't hurt anything for the kernel not to find most of them, it does take time to perform each probe. You can speed up boot time significantly by removing the unnecessary devices from the kernel. This also helps reduce the size of the kernel. Modern systems with gigabytes of RAM don't need to worry about this streamlining, but it's a worthy consideration on a machine that barely meets FreeBSD's minimum requirements.

As you add devices such as USB peripherals, sound cards, SCSI controllers, and others to your system, you won't be able to use many of them unless you add support for them in the kernel. The same is true of new filesystem types (such as Linux's EXT2FS, as you saw in Chapter 12, "The FreeBSD Filesystem"). Many devices and filesystems are available today as kernel modules, but the majority still have to be compiled into the kernel, so you have little choice but to rebuild it. However, rebuilding gives you the chance to tweak other things in the system (such as the number of memory buffers, custom memory management features, and the kernel's name), so you can enhance your system's performance significantly with one rebuild.

Note

Symmetric Multi-Processing (SMP) support is not present in the GENERIC kernel either. If you have a system with more than one CPU or processor core, you'll need to build a custom kernel in order to take advantage of all of them.


Using dmesg to Get Information About the Kernel Startup

If you will be stripping unnecessary devices out of your kernel, it is imperative that you find out what devices you do have so that you don't end up accidentally removing support for your existing hardware. As mentioned earlier, the kernel probes for all its known devices at boot time, and it prints out the status of each probe, telling you which devices you must keep in the new kernel. This information isn't just printed out to the screen at boot time; it's also echoed into an internal runtime message buffer for reference at any time. The tool to use for recalling this information is dmesg.

The output of dmesg can be very long, so you'll probably want to pipe it through less, as shown in Listing 18.1.

Listing 18.1. Partial Output from dmesg Piped Through less for Improved Readability

[View full width]

# dmesg | less Copyright (c) 1992-2005 The FreeBSD Project. Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994         The Regents of the University of California. All rights reserved. FreeBSD 6.0-RELEASE #0: Thu Nov 3 09:36:13 UTC 2005     root@x64.samsco.home:/usr/obj/usr/src/sys/GENERIC ACPI APIC Table: <DELL   PE1750  > Timecounter "i8254" frequency 1193182 Hz quality 0 CPU: Intel(R) Xeon(TM) CPU 2.40GHz (2386.76-MHz 686-class CPU)   Origin = "GenuineIntel"  Id = 0xf29  Stepping = 9   Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,C MOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>   Features2=0x4400<CNTX-ID,<b14>>   Hyperthreading: 2 logical CPUs real memory  = 2147315712 (2047 MB) avail memory = 2096508928 (1999 MB) config> di sn0 config> di lnc0 config> di ie0 config> di fe0 config> di ed0 config> di cs0 config> di bt0 config> di aic0 config> di aha0 config> di adv0 config> q npx0: [FAST] npx0: <math processor> on motherboard npx0: INT 16 interface cpu0 on motherboard pcib0: <Intel 82443BX (440 BX) host to PCI bridge> pcibus 0 on motherboard pir0: <PCI Interrupt Routing Table: 7 Entries> on motherboard pci0: <PCI bus> on pcib0 agp0: <Intel 82443BX (440 BX) host to PCI bridge> mem 0xe0000000-0xe3ffffff at device 0.0  on pci0 pcib1: <PCI-PCI bridge> at device 1.0 on pci0 pci1: <PCI bus> on pcib1 $PIR: ROUTE_INTERRUPT failed. pci1: <display, VGA> at device 0.0 (no driver attached) isab0: <PCI-ISA bridge> at device 7.0 on pci0 isa0: <ISA bus> on isab0 atapci0: <Intel PIIX4 UDMA33 controller> port 0x1f0-0x1f7,0x3f6,0x170-0x177,0x376 ,0xf000-0xf00f at device 7.1 on pci0 ata0: <ATA channel 0> on atapci0 ata1: <ATA channel 1> on atapci0 uhci0: <Intel 82371AB/EB (PIIX4) USB controller> port 0xe000-0xe01f irq 10 at device 7.2  on pci0 uhci0: [GIANT-LOCKED] usb0: <Intel 82371AB/EB (PIIX4) USB controller> on uhci0 usb0: USB revision 1.0 uhub0: Intel UHCI root hub, class 9/0, rev 1.00/1.00, addr 1 uhub0: 2 ports with 2 removable, self powered pci0: <bridge> at device 7.3 (no driver attached) fxp0: <Intel 82557 Pro/100 Ethernet> port 0xe400-0xe41f mem 0xe9200000-0xe9200fff,  0xe9100000-0xe91fffff irq 9 at device 11.0 on pci0 miibus0: <MII bus> on fxp0 inphy0: <i82555 10/100 media interface> on miibus0 inphy0: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto fxp0: Ethernet address: 00:a0:c9:66:7b:32 fxp1: <Intel 82557 Pro/100 Ethernet> port 0xe800-0xe81f mem 0xe9201000-0xe9201fff,  0xe9000000-0xe90fffff irq 5 at device 13.0 on pci0 miibus1: <MII bus> on fxp1 inphy1: <i82555 10/100 media interface> on miibus1 inphy1: 10baseT, 10baseT-FDX, 100baseTX, 100baseTX-FDX, auto fxp1: Ethernet address: 00:a0:c9:8e:8e:ba pmtimer0 on isa0 orm0: <ISA Option ROM> at iomem 0xc0000-0xc7fff on isa0 atkbdc0: <Keyboard controller (i8042)> at port 0x60,0x64 on isa0 atkbd0: <AT Keyboard> irq 1 on atkbdc0 kbd0 at atkbd0 atkbd0: [GIANT-LOCKED]

Tip

If your system has been online for a long time, the boot messages might have scrolled out of the dmesg buffer; however, you can always see the messages from the last boot in /var/run/dmesg.boot.


The output continues throughout all device checks, filesystem validations, and daemon startup blocks and then continues into runtime errors generated by various devices since you booted. You can ignore everything after you begin seeing date stamps and regular error messages. What you're interested in is the boot messages, such as the ones in the preceding listing.

The first part of the boot messages, after the copyright and CPU information lines, is the kernel configuration you have set in the boot configurator. Each line beginning with config>, if present, is a command you issued in visual config mode, most likely (as with the di lines) to delete unwanted devices from the probe process. These devices won't appear later in the dmesg output. If you haven't removed these devices in the configurator, the kernel will probe for them.

Any driver accompanied in the listing by a "not found" message is a driver you can delete from the kernel. You may want to keep two SSH terminal windows open to your FreeBSD machine: one to read the output of dmesg and another to configure the kernel. This will help ensure you don't delete anything that the system reports as "found."




FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net