Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
25
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

USB Devices

Finally, after the pseudo−devices you have USB devices, which can all be dynamically loaded via kldload. Many Internet servers don't use USB, so you might be able to delete them entirely from your kernel.

[5]Actually placing such a label on the outside of the chip would be far too convenient, so computer manufacturers generally don't bother.

Building Your Kernel

The previous sections have shown you how to gut your kernel configuration. Before you start adding other things in, I recommend trying to build and boot this minimal kernel to learn what your kernel really needs before adding customizations.

Note Use the steps described in this section when building a kernel without upgrading. If you're upgrading (as discussed in Chapter 6), you must follow a slightly different procedure.

Once you've selected and modified your kernel options, it's time to build your kernel. To do so, first use config(8) to assemble the necessary files and check your configuration's syntax. For example, to run config on MYKERNEL, enter the following command:

...............................................................................................

# config MYKERNEL

Kernel build directory is ../../compile/MYKERNEL Don't forget to do a "make depend"

#

...............................................................................................

While config cannot detect a good kernel configuration, it will find a variety of configuration mistakes if they exist. If config detects a problem, it will report an error and stop. For example, if you include a nonexistent option, config will complain, loudly. (Config always reminds you to run a make depend. We haven't discussed this yet, but forgetting this step is the single most common error in building a kernel.)

Some error messages are blatantly obvious—for example, you might have accidentally deleted support for the Unix File System (UFS), but included support for booting off of UFS. One requires the other, and config will tell you exactly what's wrong. Other messages are strange and obscure, and you should investigate them as discussed in Chapter 2.

Assuming that config runs correctly, config tells you which directory it has assembled your kernel pieces in. In our example, this is ../../compile/ MYKERNEL. Go to the directory shown and do this:

...............................................................................................

# make depend && make all install

...............................................................................................

The "make depend" stage of the command ties the pieces of your kernel and the kernel modules together, making sure that everything has the pieces it needs. The second command, "make all install", takes all the source code and dependencies and compiles a kernel out of source code.

89

Then wait. The kernel building process will take a few hours on a 25 MHz 486, or a few minutes on a dual−processor 1 GHz Pentium. You will see all sorts of cryptic compiler messages scrolling down your screen while this is happening. In the install step, your current kernel will be moved to /kernel.old, and your new kernel installed as /kernel.

Once the build is finished, reboot your server and watch your boot messages. Near the top of these messages you should see the directory where your new kernel was compiled, as shown here in bold:

...............................................................................................

Copyright (c) 1992−2001 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 5.0−CURRENT #0: Sun May 20 16:49:05 EDT 2001

mwlucas@turtledawn.blackhelicopters.org:/usr/src/sys/compile/MYKERNEL

...

...............................................................................................

If you see a message like this, you have been successful. You're up on your new kernel!

Troubleshooting Kernel Builds

If your kernel build fails, the first step in troubleshooting is to look at the last lines of the compile output. You saw the compile output after typing the make depend && make all install command. You might be able to guess at the meaning of an error, but it can be very cryptic to people who don't breathe, eat, and live kernel code.[6]

Here's an example of something you might see in a failed kernel build:

...............................................................................................

===> sys/modules/xl

cc −0 −pipe −D_KERNEL −Wall −Wredundant−decls −Wnested−externs −Wstrict−prototy pes −Wmissing−prototypes −Wpointer−arith −Winline −Wcast−qual −fformat−extensions −ansi −DKLD_MODULE −nostdinc −I− −I. −I@ −I@/../include −mpreferred−stack− boundary=2 −c /usr/src/sys/modules/xl/../../pci/if/xl.c

v /usr/src/sys/modules/xl/../../pci/if_.c:155: syntax error before`<' cpp: output pipe has been closed

*** Error code 1

Stop in /usr/src/sys/modules/xl.

*** Error code 1

Stop in /usr/src/sys/modules.

*** Error code 1

Stop in /usr/src/sys.

*** Error code 1

Stop in /usr/src.

*** Error code 1

Stop in /usr/src.

*** Error code 1

...............................................................................................

90