Online Book Reader

Home Category

UNIX System Administration Handbook - Evi Nemeth [145]

By Root 2788 0
cannot be written. (Hmm, do you see a theme developing here?)

For example, to change the maximum number of open files a process can have, try

# echo 32768 >> /proc/sys/fs/file-max

Once you get used to this unorthodox interface, you’ll find it quite useful, especially for changing configuration options. A word of caution, however: changes are not remembered across reboots. If you want to make permanent changes, you must add echo commands to your startup scripts. Table 12.5 lists some useful options.

Table 12.5 Files in /proc for commonly tuned kernel parameters

a. F = /proc/sys/fs, N = /proc/sys/net/ipv4

12.6 BUILDING A FREEBSD KERNEL


Although the examples in this section are specifically from a FreeBSD machine, configuration for NetBSD, OpenBSD, and BSD/OS is similar.

BSD kernels each have a name that is used throughout the configuration process. The kernel name can be anything you like, but it should be descriptive of the system or systems on which the kernel is to run. If the kernel is being built for one particular machine, that machine’s hostname makes a good kernel name.

To build a FreeBSD kernel, you first create a configuration file that lists that parameters of the new kernel. You then run the config command to build a kernel compilation directory as specified in your config file. The name you give the configuration file becomes the name of the compilation directory and ultimately of the kernel.

The files needed to build a BSD kernel reside in /usr/src/sys, which is usually symbolically linked to /sys. In the following discussion, we use the uppercase name SYS to refer to this directory, just to emphasize that it doesn’t really matter where it’s located. If you cannot find the kernel configuration directory for your machine, consult your manuals.

Here is an ls -F of the SYS directory for FreeBSD:

# ls -F

Makefile ddb/ libkern/ netinet/ pccard/

alpha/ dev/ miscfs/ netipx/ pci/

boot/ gnu/ modules/ netkey/ posix4/

cam/ i386/ msdosfs/ netnatm/ sys/

coda/ i4b/ net/ netns/ ufs/

compile/ isa/ netatalk/ nfs/ vm/

conf/ isofs/ netatm/ ntfs/

contrib/ kern/ netgraph/ pc98/

The i386 directory contains architecture-specific modules:

% ls -F i386

Makefile boot/ eisa/ ibcs2/ isa/

apm/ conf/ i386/ include/ linux/

Another important directory in the SYS area is SYS/arch/conf, where the kernel configuration files are stored; each file corresponds to one kernel. In this book we assume that you are using the Intel i386 architecture, although FreeBSD also supports the Alpha architecture. config reads a configuration file from SYS/arch/conf and creates the corresponding compilation directory in SYS/compile/KERNEL_NAME.

For example, when the system is first installed, it comes with a generic kernel named GENERIC. The default kernel configuration file is SYS/i386/conf/GENERIC, so the default compilation directory would be SYS/compile/GENERIC.

The rest of the directories in SYS contain various parts of the kernel that are assembled to create the executable image. The exact files and subdirectories vary widely among BSD systems.

The master recipe for building a kernel


The following list details the eight steps involved in building a kernel. We take up each of these steps in the subsequent sections.

• Audit the system’s hardware.

• Create and edit the kernel’s configuration file in SYS/i386/conf.

• Run the config program from the conf directory.

• Run make depend in the compilation directory.

• Build the kernel with make.

• Archive the old kernel and install the new one.

• Test and debug the new kernel.

• Document the new kernel.

Audit the system’s hardware


Before you can configure a kernel, you need to know what devices it must handle. Start by taking a hardware inventory of your system. Make a list of all the devices connected to the computer, including

• Disks and CD-ROM drives, and their controllers

• Network interfaces

• Specialty hardware

• The keyboard and mouse

This hardware audit can be a grueling task in the PC world. PC manufacturers

Return Main Page Previous Page Next Page

®Online Book Reader