UNIX System Administration Handbook - Evi Nemeth [146]
Remember to check what the generic kernel reports about your hardware at boot time; its output can give you hints as to which drivers you should keep in your kernel. You can check the current kernel’s idea of your hardware with the dmesg command. You can also use the SYS/i386/conf/LINT file as an extra reference.
Create a configuration file in SYS/i386/conf
Once you know how you want your kernel configured, you must put this information into a form that config can understand. To do this, you create a configuration file in SYS/i386/conf. The name can be any valid filename, but it should be descriptive enough that a stranger to your SYS directory can tell what each kernel is for.
Don’t create the configuration file from scratch. Instead, copy the GENERIC configuration and delete the parts you don’t want. If you get stuck on something related to the configuration file and can’t figure it out from the material here, refer to the documentation for config. The man pages for individual device drivers are also a good source of information and usually show any kernel config lines you might need. For example, the man page for de begins with
SYNOPSIS
device de
which is the exact line you need to put in the kernel config file to include that device. (Of course, this method is still a bit backward because you need to know the name of the device driver before you can look up the man page. man -k is your friend.)
The format of a kernel configuration file requires quite a few pages to describe, so instead of interrupting our overview of the kernel building process with a complete discussion, we’ll defer the details until page 237.
Run config
You must cd to SYS/i386/conf before running config; it expects to find the configuration file specified on the command line in the current directory. Simple versions of config take the name of the configuration file as their only argument. Fancier versions support a number of options. To set up the compilation directory for the kernel described in SYS/i386/conf/EXAMPLE, we would use the following commands:
# cd SYS/i386/conf
# config EXAMPLE
If the config command produces error messages, you must go back and fix your configuration file before continuing. If you get through config without any errors, you can assume that your configuration was at least syntactically valid and that the kernel compilation can proceed.
Run make depend
After config finishes, change your working directory to the new kernel’s compilation directory (cd ../../compile/EXAMPLE) and do an ls. You should see lots and lots of files. Don’t worry about their contents; config knows what it’s doing.
Now run make depend inside the compilation directory. This command initializes the file dependency information used by make. make depend may produce voluminous output.
Build the kernel
In the compilation directory, simply type make.You must watch carefully for error messages during the compilation. make will usually detect errors and abort the compilation, but it always helps to be alert. For extra protection, use the tee command to have make keep a record of everything that gets sent to your screen.
# make |& tee ERRS.LOG
The & behind the vertical bar ensures that both error messages and status messages will be directed through the pipe. Bourne shell users should use
# make 2>&1 | tee ERRS.LOG
to achieve similar results.
If an error occurs during compilation, you should first suspect your configuration file. If you get messages about missing files or undefined routines, you have probably